兼容端
安卓 | 苹果 | Web | 鸿蒙 | 小程序 |
---|---|---|---|---|
✅ | ❌ | ❌ | ❌ | ❌ |
配置文档
- 在项目根目录创建
nativeResources
->android
->manifestPlaceholders.json
json
{
"HONOR_APPID": "你的APPID"
}
- 在项目根目录创建
AndroidManifest.xml
xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="你的包名">
<application>
<meta-data android:name="com.hihonor.push.app_id" android:value="${HONOR_APPID}" />
</application>
</manifest>
使用文档
- 先初始化
- 然后再注册,会拿到registerID。
vue
<script setup lang="uts">
import * as tHonorPushApi from "@/uni_modules/t-honor-push-api"
import { THonorPushResult,THonorPushOptions } from "@/uni_modules/t-honor-push-api"
const handleHonorInit = () => {
tHonorPushApi.TInit({
success: (result:THonorPushResult) => {
console.log(result)
},
fail: (result:THonorPushResult) => {
console.log(result)
}
} as THonorPushOptions)
}
const handleHonorRegister = () => {
tHonorPushApi.TRegister({
success: (result:THonorPushResult) => {
console.log(result)
},
fail: (result:THonorPushResult) => {
console.log(result)
}
} as THonorPushOptions)
}
</script>
暴露的类型
ts
export type THonorPushResult = {
code: number;
msg: string;
data?: any;
}
export type THonorPushOptions = {
appkey?: string;
appsecret?: string;
success?: (result: THonorPushResult) => void;
fail?: (result: THonorPushResult) => void;
}