Lawris Lawris - 5 months ago 649
iOS Question

Scheduled Notifications with Firebase and background running

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


-Source

What can I do? Should I take a look at services like Parse? Any help is greatly appreciated.

Answer

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.