MeteorJS移动应用推送通知在后台

时间:2016-02-22 07:45:36

标签: cordova mobile meteor

我目前正在使用MeteorJS进行移动推送通知(android)。我正在使用包裹:

https://github.com/katzer/cordova-plugin-local-notifications

应用程序打开时工作正常,但关闭时没有任何反应。有没有办法使用此软件包使推送通知工作即使应用程序关闭或最小化?是否有可以进行后台推送通知的流星替代方案?到目前为止,这是我的代码:

rake db:migrate VERSION=20151229013054

一个非常简单的代码,仅在应用程序打开时才有效。我对背景通知的实际工作方式一无所知。感谢

1 个答案:

答案 0 :(得分:1)

这是因为您还没有为通知创建schedule。如果应用程序没有运行,那么您执行插件时编写的代码将无法运行,除非它已安排这样做,因此应用程序创建后台进程已加载并授予权限。

更改通知的初始化:

cordova.plugins.notification.local.add({ 
    title: 'This is a sample push', 
    message: msg });

致:

date = foo; //change this to when you want the notification to fire 
            //for the first time

cordova.plugins.notification.local.**schedule**({
    id: 1,
    title: 'this is a sample push',
    message: msg,
    firstAt: date,
    every: 'minute' //set this to how often you want it repeated.
)};

最终发生的是模板初始化通知,而没有任何关于它应该如何运行的参数。如果您需要进一步的帮助,请在包文档中对此进行详细说明。

相关问题