1173468456@qq.com
1173468456@qq.com
  • 发布:2021-02-23 14:33
  • 更新:2021-02-23 17:49
  • 阅读:31

plus.push.addEventListener('receive', function(msg) {},false)

分类:HTML5+

不管APP是离线还是在线都不能监听和触发plus.push.addEventListener('receive')求大佬解答
plus.push.addEventListener('receive', function(msg) { console.log('receive', msg); }, false);

2021-02-23 14:33 负责人:无 分享
已邀请:
老哥教教我

老哥教教我 - 踏实工作

代码没问题,ios必须打包后才能推送。你可以用官方本地推送试试

plus.push.addEventListener('receive', function(message) {  
                if (localStorage.getItem('IOS')) {  
                    switch (message.payload) {  
                        case 'LocalMSG':  
                            break;  
                        default:  
                            function toJson(str) {  
                                var json = (new Function('return ' + str))();  
                                return json;  
                            }  
                            var json1042 = toJson(message.content);  
                            plus.push.createMessage(json1042.title + '\n' + json1042.content, 'LocalMSG');  
                            localStorage.setItem('tztg05id', json1042.payload);  
                            break;  
                    }  
                }  
            }, false);  
            plus.push.addEventListener('click', function(message) {  
                if (localStorage.getItem('IOS')) {  
                    switch (message.payload) {  
                        case 'LocalMSG':  
                            localStorage.setItem('tztgid', localStorage.getItem('tztg05id'))  
                            break;  
                        default:  
                            localStorage.setItem('tztgid', (message.aps.alert.title.split('\n')[1]));  
                            break;  
                    }  
                } else {  
                    localStorage.setItem('tztgid', message.payload);  
                }  
            }, false);
老哥教教我

老哥教教我 - 踏实工作

要申请证书,添加测试设备后才能试,你看官方演示app

要回复问题请先登录注册