计划通知与Firebase和后台运行 [英] Scheduled Notifications with Firebase and background running
问题描述
我希望我的Firebase将预定推送通知发送给我的应用程序的所有用户,并且该应用程序在后台;运行一些代码,并发送一些东西到服务器。
我有点失落,因为从Firebase的通知控制台不可能这样做。
然后,我对Firebase云消息传递感兴趣,但是在文档中说,应该终止与FCM的连接:
当您的应用程序进入后台时,断开与FCM的连接
- 来源
我能做什么?我应该看看像Parse这样的服务吗?任何帮助,非常感谢。
解决方案
我解决了我的问题建立一个服务器,用户注册他的令牌(唯一标识符)数据库。还有一个发送推送通知的PHP脚本。你可以在这里找到所有 。
I编辑PHP脚本以发送包含以下内容的有效内容:
[content-available] =1
这个有效载荷将触发你的应用程序在后台进行的操作。
我在服务器上使用crontab来定期发送推送通知。
$ b Firebase中的通知控制台可以发送推送通知,但不能发送静默推送通知我们希望在我的情况。
I want my Firebase to send scheduled push notifications to all the users of my application and if the app is in the background; run some code and send some stuff to the server.
I'm a bit lost because it's impossible to do so with the notification console from Firebase.
Then, I was interested in Firebase Cloud Messaging, but in the documentation, it says that the connection to FCM should be ended :
When your app goes into the background, disconnect from FCM
What can I do? Should I take a look at services like Parse? Any help is greatly appreciated.
I solved my problem building a server where the user register his token (unique identifier) to a database. There is also a PHP script for sending push notifications. You can find all of this here.
I edited the PHP script to send a payload which contains :
["content-available"] = "1"
This payload will trigger what you want to do when your app is in the background.
I used a crontab on my server to regularly send push notifications.
The notification console from Firebase can send push notification but not silent push notification that we want in my case.
这篇关于计划通知与Firebase和后台运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!