且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当应用程序关闭时,Android 重复通知不起作用

更新时间:2023-02-27 08:56:26

您不应使用应用程序的任何部分来执行此操作.服务、JobScheduler 或 Work Manager 迟早会被系统杀死以防止电池耗尽.

You shouldn't use any part of application to do that. Services, JobScheduler, or Work Manager sooner or later will be killed by the system to prevent battery drain.

在我看来,发送重复通知的***方式是使用由外部 cron 作业触发的 firebase 云消息传递(例如 firebase 函数上的 php).

In my opinion the best way to send repeated notifications is to use firebase cloud messaging triggered with external cron job (e.g. php on firebase functions).

还要确保将通知发送到系统托盘而不是应用程序.为此,请使用 FCM DataMessages.数据消息传送到系统托盘并始终显示 - 即使服务未运行.

Also make sure to deliver the notification to the system tray not to the application. To do that use FCM DataMessages. Data messages are delivered to system tray and are always display - even if service is not running.