我有一个vuejs项目,在我的main.js中有以下代码:
new Vue({
router,
mounted: function(){
document.addEventListener('deviceReady', this.onDeviceReady, false);
},
methods: {
onDeviceReady: function() {
alert('Device is ready!');
var push = window.PushNotification.init({
"android":{},
"ios":{
"badge":"true",
"sound":"true",
"alert":"true"
}
})
push.on('registration',function(data){
localStorage.setItem('platform', window.cordova.platformId)
localStorage.setItem('pushId', data.registrationId)
})
//listeners
//listner called on new push notification
push.on('notification', function(data) {
alert("on notification V");
window.navigator.notification.alert(
'You are the winner!', // message
this.alertDismissed(), // callback
'Game Over', // title
'Done' // buttonName
);
alert(JSON.stringify(data));
});
},
alertDismissed(){
alert('done')
}
},
i18n,
store,
render: h => h(App),
}).$mount('#app')
推送有效,而cordova平台数据有效。但是本地导航警报却没有。从推送中可以看到,我使用window.PushNotification实现了它的工作原理,但是使用导航器却无法实现