My app is for an important part dealing with Instant Messaging and receives FCM notifications. How can the app wake up for a few seconds upon reception of a High Importance notification, do a short fetch from the server and go back to its previous state. I have seen a lot of theoretical explanations but no real example of source code to achieve that. Can somebody help?
Asked
Active
Viewed 3,236 times
1 Answers
2
- Extend FirebaseMessagingService and get the message payload in onMessageReceived. (basic JSON parsing)
- Then, schedule a job to be executed instantly using Firebase JobDispatcher (code to schedule is in the repo itself) or the new WorkManager.
- Call the network request from the job.

Aditya
- 33
- 6
-
Thanks. I tried JobDispatcher and experienced some troubles, but it worked just fine with WorkManager. Hoping that the current version is stable. – men Dec 30 '18 at 07:42