在这篇文章中,我们将使用plus推送消息功能,只有应用上线后才能推送到状态栏。
核心创建通知栏消息
let options={'cover': true, //覆盖上一条,只保留最后一条'when': new Date(),'title': '提醒消息'};let body={' id ': 'id','key': 'key'}let Payload=JSON.stringify(body);//发送消息通知plus.push.createMessage(content, Payload, options);应用程序中的页面
plus.push.addEventListener('click', (msg)={console.log('您点击了:' + JSON.stringify(msg));uni.switchTab({ //登录成功后,点击消息跳转消息list page url: '/pages/warn/index', //修改为你的地址success: function(res) {console.log('跳转成功', res);},fail: function(err) {console.log ('Jump失败', err);},});}, false);
完整代码
getWarnList({pageNum: 1,pageSize: 5}).then(res={if (res res.rows) {//this.warnList=res .rows//this.warnTotal=res.totallet content=`有新警告。点击查看它们`; let options={'cover': true, //覆盖并仅保留最后一个警告。 new Date(),'title': '提醒消息'};let body={'id': 'id','key': 'key'} let payload=JSON.stringify(body);plus .push. createMessage(content, Payload, options);plus.push.addEventListener('click', (msg)={console.log('Clicked :' + JSON.stringify(msg));uni.switchTab( { //成功后登录后,点击消息跳转到消息列表页url: '/pages/warn/index',success: function(res) {console.log( '跳转成功', res);},fail: function(err) ) {console .log('跳转失败', err);},});}, false);}}).catch(()={console.log('异常');})
版权声明:本文转载于网络,版权归作者所有。如有侵权,请联系本站编辑删除。