应用程序关闭时运行cordova本地通知“触发”代码

时间:2021-05-12 04:38:22

标签: android cordova ionic-framework android-notifications localnotification

我正在开发一款适用于 Android 的应用,用于将文件备份到服务器。每天一次,该应用程序检查新文件并将它们复制到备份服务器。我正在使用 Ionic 和 localnotifications 科尔多瓦插件,配置每日通知和订阅触发事件以启动检查和备份过程。 如果应用程序在前台或后台运行正常,但如果应用程序关闭/终止,则显示通知,但不会执行订阅“on trigger”事件中的代码。

示例:

this.localNotifications.on("trigger").subscribe( n =>{
    //This is the code that is executed if the app is in foreground or 
    background, but not if it's closed, even if the scheduled alarm is 
    triggered
})

这是因为应用程序已关闭且无法执行代码而按预期工作,还是错误?有什么解决方法可以做到这一点吗?我不希望应用程序始终打开,即使在后台也是如此。

Cordova 本地通知插件版本:0.9.0-beta.3 平台:安卓 科尔多瓦版本 10.0.0 Cordova 平台版本:android 9.1.0 离子版本:CLI 6.13.1,框架:@ionic/angular 5.5.4

谢谢。

0 个答案:

没有答案