0

I am making an app which would insert data fetched from FCM payload, into the local SQLite DB on the client mobile.

I am aware "onMessageReceived" will not be called when the app is in background, so I am using putExtra and getStringExtra in my main activity to fetch the payload once the notification is clicked, post which I insert the data into my DB.

However my issue is that, if the user ends up clearing the notification without opening it, he/she will not get the data inserted into his/her local DB.

Is there a way around to ensure, the onMessageReceived is invoked in the background, or any other method where I can implement similar DB insert activities without having the user to either have the app in foreground or explicitly click on the notification for the insert actions to get triggered.

KENdi
  • 7,576
  • 2
  • 16
  • 31
  • remove "notification" from payload and use "data" only – Tim Dec 21 '18 at 11:50
  • @TimCastelijns Thanks a lot !! Short and simple answer to a very basic query, I should have read below URL more carefully, https://firebase.google.com/docs/cloud-messaging/android/receive I did read it, but it did not make things clear for me until this very simple one line explanation from you ! Thanks again :) – Jotinder Singh Dec 21 '18 at 13:17

0 Answers0