如果应用程序被杀死,使用 firebase 发送静默推送通知以唤醒应用程序

Send silent push notification using firebase to wake the app if it was killed

我知道如何使用 firebase 发送静默通知并且它工作正常但是当应用程序被杀死时它不会唤醒应用程序来执行注册本地通知的代码!

那么,如果应用未处于活动状态(也不在后台),我该如何发送静默推送通知以使用 Firebase 唤醒应用以注册本地通知??

更新:

我正在使用此功能接收静默推送通知并注册本地通知,它工作正常,但当应用程序强制退出时,它不会注册本地通知,这意味着静默通知不会唤醒启动应用程序

application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

我还发现有人说如果用户强制退出它。在这种情况下,用户必须在系统尝试再次自动启动您的应用程序之前重新启动您的应用程序或重新启动设备。

因此,如果有人知道我可以发出静默通知,在用户强行退出时唤醒应用程序,这将非常有帮助。

似乎没有办法在用户杀死应用程序时重新启动应用程序。

来自 Apple 论坛:

Also keep in mind that if you kill your app from the app switcher (i.e. swiping up to kill the app) then the OS will never relaunch the app regardless of push notification or background fetch. In this case the user has to manually relaunch the app once and then from that point forward the background activities will be invoked. -pmarcos (Apple worker)

https://devforums.apple.com/message/873265#873265