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
What can I do? Should I take a look at services like Parse? Any help is greatly appreciated.
- Firebase queryOrderedByChild() method not giving sorted data
- Firebase + swift retrieving user data
- Firebase, how do I return a handle so that I can call removeObserver?
- Firebase Offline Storage Advanced - Manual Sync and Progress Information
- Converting to Swift 3 (Swift and Firebase Project)
- How to pull users from database and list them in a table view using firebase?
2 Solutions Collect From Internet About “Scheduled Notifications with Firebase and background running”
Notification messages don’t execute your application code when your app is in the background. All messages sent from the Firebase console are Notification messages. So you can’t currently use the Firebase console for what you are describing.
However you can send Data messages from your app server which can trigger background execution of code. You will have to manage the scheduling yourself on your app server.
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.
- Is there a keyboard shortcut for cycling through pragma marks or methods in Xcode?
- Pick random element of NSArray in Objective-C
- Indent second line of UILabel
- How to map a realm list of custom objects using Mappable protocol in Swift
- UIView resizing after rotation with CGAffineTransform
- How to change textfield font size programmatically?
- What is the difference and purpose of auto and escaping closure in Swift?
- iOS: Programmatically add custom font during runtime
- With autolayout, label position is reset when I change label text
- Swift 2 to 3 Migration dispatch_get_global_queue
- Two persistent stores for one managed object context – possible?
- Could not find a storyboard named 'Main' in bundle
- How to bring a subview to the front when you tap it?
- CoreMotion updates in background state