【发布时间】:2016-06-03 13:29:50
【问题描述】:
我目前正在使用 MeteorJS 开发移动推送通知 (android)。我正在使用这个包:
https://github.com/katzer/cordova-plugin-local-notifications
应用程序打开时它工作正常,但关闭时没有任何反应。有没有办法使用这个包来使推送通知在应用程序关闭或最小化时也能正常工作?是否有可以做后台推送通知的流星替代包?到目前为止,这是我的代码:
if(Meteor.isCordova){
Meteor.startup(function () {
cordova.plugins.notification.local.registerPermission(function (granted) {
if(confirm("Sample App would like to send you notifications: ") === true) {
alert('permission granted '+granted)
} else {
alert('permission denied')
}
});
});
Template.hello.events({
'click button': function () {
var msg = $('[name=msg]').val();
cordova.plugins.notification.local.add({ title: 'This is a sample push', message: msg });
}
});
};
仅在应用打开时才有效的非常简单的代码。我对后台通知的实际工作方式一无所知。谢谢
【问题讨论】: