鸿蒙端 阿里云移动推送
插件 ID: 26518
来源: https://ext.dcloud.net.cn/plugin?id=26518
移动推送(Mobile Push)是提供给移动开发者的移动端消息推送服务,通过在App中集成推送功能,进行高效、精准、实时的消息推送,从而使业务及时触达用户,提高用户粘性。
更新记录
1.0.1(2026-01-10)
优化
1.0.0(2026-01-10)
初始化
平台兼容性
uni-app(4.75)
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 | | |
- |
- |
- |
- |
- |
- |
- |
- | √ | | | 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 | | |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- | |
uni-app x(4.85)
| Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 | | |
- |
- |
- |
- | √ |
- | |
xtf-aliyunpush
import {initSdk,InitPara,registerPush,MyApiResult,receiveMessage,registerThirdToken, listAliases, TagPara, bindTag, listTags, removeAlias, addAlias, unbindAccount, bindAccount, bindPhoneNumber, unbindPhoneNumber, turnOffPushChannel, turnOnPushChannel, checkPushChannelStatus} from "@/uni_modules/xtf-aliyunpush"export type InitPara={
appKey:string,
appSecret:string,
onReceiveNotification?:(data:MyApiResult)=>void, //收到通知回调
onShowNotification?:(data:MyApiResult)=>void,// 显示通知回调
onReceiveMessage?:(data:MyApiResult)=>void,// 收到信息回调
onClickNotification?:(data:MyApiResult)=>void,// 点击通知栏回调
}"初始化",
uniappx
initSdk({
appKey:"xxx",
appSecret:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
onReceiveNotification:function(b:MyApiResult) {
console.log(b)
},
onShowNotification:function(b:MyApiResult){
console.log(b)
},
onReceiveMessage:function(b:MyApiResult){
console.log(b)
},
onClickNotification:function(b:MyApiResult){
console.log(b)
}
} as InitPara);uniappx
initSdk({
appKey:"xxx",
appSecret:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
onReceiveNotification:function(b) {
console.log(b)
},
onShowNotification:function(b){
console.log(b)
},
onReceiveMessage:function(b){
console.log(b)
},
onClickNotification:function(b){
console.log(b)
}
});"注册推送",
uniappx
registerPush(function(b:MyApiResult){
console.log(b)
})uniapp
registerPush(function(b){
console.log(b)
})"注册鸿蒙Push Token",
uniappx
registerThirdToken(function(b:MyApiResult){
console.log(b)
})uniapp
registerThirdToken(function(b){
console.log(b)
})"绑定账号",
uniappx
bindAccount("test",function(b:MyApiResult){
console.log(b)
})uniapp
bindAccount("test",function(b){
console.log(b)
})"解绑账号"
uniappx
unbindAccount(function(b:MyApiResult){
console.log(b)
})uniapp
unbindAccount(function(b){
console.log(b)
})"添加别名",
uniappx
addAlias("123",function(b:MyApiResult){
console.log(b)
})uniapp
addAlias("123",function(b){
console.log(b)
})"移除别名",
uniappx
removeAlias("123",function(b:MyApiResult){
console.log(b)
})uniapp
removeAlias("123",function(b){
console.log(b)
})"查询别名",
uniappx
listAliases(function(b:MyApiResult){
console.log(b)
})uniapp
listAliases(function(b){
console.log(b)
})export type TagPara= {
bindTag:boolean,
tagType:number,// 0 设备绑定标 1 账号绑定标签时 2 别名绑定标签时
tags:string[],
alias?:string,
callback:(b:MyApiResult)=>void
}"绑定标签",
uniappx
bindTag({
tagType:0,
bindTag:true,
tags:["123"] as string[],
callback:function(b:MyApiResult){
console.log(b)
}
} as TagPara)uniapp
bindTag({
tagType:0,
bindTag:true,
tags:["123"],
callback:function(b){
console.log(b)
}
} as TagPara)"解绑标签",
uniappx
bindTag({
tagType:0,
bindTag:false,
tags:["123"] as string[],
callback:function(b:MyApiResult){
console.log(b)
}
} as TagPara)uniapp
registerThirdToken(function(b){
console.log(b)
})"查询标签",
uniappx
listTags(function(b:MyApiResult){
console.log(b)
})uniapp
listTags(function(b:MyApiResult){
console.log(b)
})"绑定手机号",
uniappx
bindPhoneNumber("12345678901",function(b:MyApiResult){
console.log(b)
})uniapp
bindPhoneNumber("12345678901",function(b){
console.log(b)
})"解绑手机号",
uniappx
unbindPhoneNumber(function(b:MyApiResult){
console.log(b)
})uniapp
unbindPhoneNumber(function(b){
console.log(b)
})"打开推送",
uniappx
turnOnPushChannel(function(b:MyApiResult){
console.log(b)
})uniapp
turnOnPushChannel(function(b){
console.log(b)
})"关闭推送",
uniappx
checkPushChannelStatus(function(b:MyApiResult){
console.log(b)
})uniapp
checkPushChannelStatus(function(b){
console.log(b)
})"推送开启状态"
uniappx
turnOnPushChannel(function(b:MyApiResult){
console.log(b)
})uniapp
registerThirdToken(function(b){
console.log(b)
})