MUI消息推送

  一、push通过H5+实现

简单实现方式:通过轮询服务器是否有新消息推送过来

mui.plusReady(function() {
plus.navigator.closeSplashscreen();
//关闭等待框
plus.nativeUI.closeWaiting();
//显示当前页面
plus.webview.currentWebview().show();

document.getElementById("btn").addEventListener('tap',function(){
plus.push.clear()//清除掉所有的推送消息,清空系统消息中的所有信息
})
document.getElementById("btn1").addEventListener('tap',function(){
plus.push.createMessage("测试消息", "LocalMSG", {cover:false});//创建本地消息,这个可以通过判断服务器端是否有新消息推送,获取到推送消息之后,创建本地推送消息
})
plus.push.addEventListener( "click", function(msg){alert( "推送事件监听You clicked: " + msg.content );}, false );//监听系统消息点击,click为从系统消息中心点击启动应用程序,或者receive应用从推送服务器接收到推送消息事件
});

plus.push.getAllMessage()//获取所有的推送消息

plus.push.getClientInfo()//获取客户端标识信息

测试出现:测试时使用定时器推送多条消息的时候,系统消息栏还是只显示一个,退出应用程序的时候,不再推送消息

var ua = navigator.userAgent.toLowerCase();	
if (/iphone|ipad|ipod/.test(ua)) {
//alert("iphone");
} else if (/android/.test(ua)) {
alert("android");
}//判断手机是安卓还是iPhone
二.使用个推

原文地址:https://www.cnblogs.com/0828-li/p/8412541.html