2

I need to get data from notification even when the app is killed/Not even in task or background. I am able to get data from notifications using broadcast receiver till nougat and saving it in room database. But my broadcast receiver is not being called in Oreo devices. It is called only when the app is in the foreground or background, not when the app is killed. I have read about using job scheduler in Oreo, but I am not sure that even it will be called when the app is killed because Oreo tries to save system resources right. Please suggest what should i do to get data from notification even when app is killed in oreo.

Maximus
  • 189
  • 1
  • 3
  • 15
  • 1
    As per android documentation - " With limited exceptions, apps cannot use their manifest to register for implicit broadcasts. They can still register for these broadcasts at runtime, and they can use the manifest to register for explicit broadcasts targeted specifically at their app." Thats the reason you were able to get the broadcast. – Arpit Nov 12 '18 at 06:16
  • 1
    Yes i read that already, i am trying to get solution for it. I have a requirement where i need to save notifications even when app is killed into an offline db. Its just not working in Oreo. – Maximus Nov 12 '18 at 06:24
  • are you not using FCM, you will get the notification even when the app is killed. Or can you explain a bit about when and how you are generating notification – Arpit Nov 12 '18 at 06:27
  • @Arpit i am using fcm, i am not talking about getting notifications, i am getting notification obviously, its just that i need its data even without clicking on it. So when notification comes, i need to get its data and save it. – Maximus Nov 12 '18 at 06:49
  • i am just confirming. When the app is not in background then you will only get "notification":{ "title":"Portugal vs. Denmark", "body":"great match!" } not the data payload. check the documentation here https://firebase.google.com/docs/cloud-messaging/concept-options – Arpit Nov 12 '18 at 06:54
  • I am taking entire data and even saving it in room db even when app is killed. Its just not working in oreo. Heres how i am doing it: https://stackoverflow.com/questions/53082790/how-to-get-fcm-notification-data-when-app-is-not-in-task-or-killed Please tell me improvement/changes/additions over this for oreo if you know. – Maximus Nov 12 '18 at 07:04
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/183483/discussion-between-arpit-and-maximus). – Arpit Nov 12 '18 at 07:07

0 Answers0