0

I need to send Firebase notification body (Text) from service to activity in case the notification received in background.

How can I achieve that? currently the notification body can be retrieved in foreground only.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Leenah
  • 850
  • 3
  • 15
  • 36
  • This is a great example on how to make it work. http://stackoverflow.com/questions/37711082/how-to-handle-notification-when-app-in-background-in-firebase/37845174#37845174 – Viktor Petrovski Jan 07 '17 at 21:36
  • Could you explain more please? Is that allow me to send the body of the notification to the activity for killed/ in background app? – Leenah Jan 08 '17 at 06:29
  • Well if the app is killed that means that the activity is killed also so you cant actually send data to it. You can use PendingIntent to open the activity when the notification is clicked. Not sure what you want to achieve please send some more examples. – Viktor Petrovski Jan 08 '17 at 10:13
  • @VictorPetrovski Thank you for your reply, Actually I want to pass the notification body (text) when clicked to TextView in the activity. Now It's working only in foreground , so when the app is killed the textView showing "Bundle[mParcelledData.dataSize = 320] " after clicking the notification. – Leenah Jan 08 '17 at 10:26
  • So when the app is in background , you will have to use Pending intent and bundle to pass the data to the activity, and from the activity extract the data there you cant set it directly – Viktor Petrovski Jan 09 '17 at 19:58
  • @VictorPetrovski Thank you so much for the clarification, I will implement it right now. – Leenah Jan 09 '17 at 22:11
  • If you cant make it on your own, i will help you with sending you code snippets on how you should do it. ! Good Luck – Viktor Petrovski Jan 10 '17 at 11:19
  • @VictorPetrovski Yes please I need the code snippets, it does not pass values in background seems there is something missing in my code. Thank you for your continued support. – Leenah Jan 10 '17 at 12:51
  • So guys how to deal with Bundle[mParcelledData. ? – Ali Obeid Aug 03 '17 at 16:03

0 Answers0