Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

//点击推送消息
createLocalPushMsg(){
    var options = {cover:false};
    var str = this.formatDate(new Date().getTime())
    str += ": 欢迎使用HTML5+创建本地消息!";
    plus.push.createMessage( str, "LocalMSG", options );
    console.log( "创建本地消息成功!" );
    console.log( "请到系统消息中心查看!" );
},
//监听消息点击事件
// 监听plusready事件  
    document.addEventListener( "plusready", function(){
        console.log('+++++++++++++++++++')
        message = document.getElementById("message");
        // 监听点击消息事件
        plus.push.addEventListener( "click", function( msg ) {
            console.log(22222)
            // 判断是从本地创建还是离线推送的消息
            switch( msg.payload ) {
                case "LocalMSG":
                    console.log( "点击本地创建消息启动:" );
                break;
                default:
                    console.log( "点击离线推送消息启动:");
                break;
            }
            // 提示点击的内容
            plus.nativeUI.alert( msg.content );
            // 处理其它数据
            // this.logoutPushMsg( msg );
        }, false );
        // 监听在线消息事件
        plus.push.addEventListener( "receive", function( msg ) {
            if ( msg.aps ) {  // Apple APNS message
                console.log( "接收到在线APNS消息:" );
            } else {
                console.log( "接收到在线透传消息:" );
            }
            this.logoutPushMsg( msg );
        }, false );
    }, false );

下面这个监听事件是要写在哪里?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
760 views
Welcome To Ask or Share your Answers For Others

1 Answer

百度其他大佬提供的方案:https://ask.dcloud.net.cn/que...
直接用 H5+ 的 document.addEventListener('plusready', fn) 在加载时是没有问题的,
但是 mui 加载是比H5要延迟


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...