提交 eb7c8a05 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

update: 创建通知时,增加通知权限的判断。

上级 0252135c
...@@ -32,26 +32,33 @@ ...@@ -32,26 +32,33 @@
const manager = uni.getChannelManager() const manager = uni.getChannelManager()
console.log("channels : " + manager.getAllChannels()); console.log("channels : " + manager.getAllChannels());
}, },
handleCreateLocalNotification() { handleCreateLocalNotification() {
uni.createPushMessage({ if(uni.getAppAuthorizeSetting().notificationAuthorized == "authorized"){
title: "halo", uni.createPushMessage({
content: "world", title: "halo",
// cover:true, content: "world",
channelId: this.isXM ? "112735" : "msg-pass", // cover:true,
when: Date.now() + 10000, channelId: this.isXM ? "112735" : "msg-pass",
icon: "/static/logo.jpg", when: Date.now() + 10000,
// delay:5, icon: "/static/logo.jpg",
payload: { // delay:5,
pkey: "pvalue1" payload: {
}, pkey: "pvalue1"
category: "IM", },
success(res) { category: "IM",
console.log("res: " + res); success(res) {
}, console.log("res: " + res);
fail(e) { },
console.log("fail :" + e); fail(e) {
} console.log("fail :" + e);
}) }
})
}else{
uni.showToast({
title:"请在设置中开启通知权限",
icon:"error"
})
}
}, },
handleGetClientId() { handleGetClientId() {
uni.getPushClientId({ uni.getPushClientId({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册