兼容端
安卓 | 苹果 | Web | 鸿蒙 | 小程序 |
---|---|---|---|---|
✅ | ❌ | ❌ | ❌ | ❌ |
使用文档
- 先初始化
- 然后再注册,会拿到registerID。
vue
<script setup lang="uts">
import * as tXiaomiPushApi from "@/uni_modules/t-xiaomi-push-api"
import { TXiaomiPushResult,TXiaomiPushOptions } from "@/uni_modules/t-xiaomi-push-api"
const handleXiaomiInit = () => {
tXiaomiPushApi.TInit({
appid: "",
appkey: "",
success: (result:TXiaomiPushResult) => {
console.log(result)
},
fail: (result:TXiaomiPushResult) => {
console.log(result)
}
} as TXiaomiPushOptions)
}
const handleXiaomiRegister = () => {
tXiaomiPushApi.TGetRegId({
success: (result:TXiaomiPushResult) => {
console.log(result)
},
fail: (result:TXiaomiPushResult) => {
console.log(result)
}
} as TXiaomiPushOptions)
}
</script>
暴露的类型
ts
export type TXiaomiPushResult = {
code: number;
msg: string;
data?: any;
}
export type TXiaomiPushOptions = {
appid?: string;
appkey?: string;
success?: (result: TXiaomiPushResult) => void;
fail?: (result: TXiaomiPushResult) => void;
}