1

I am using Firebase cloud messaging in my nativescript app. I receive notifications and they are read when I click them. But is there any way that I can automatically access the data of received notifications (when the app is in background / killed) when I re-open or bring the app in foreground? I want to programmatically read nativescript-firebase-plugin messages from notifications received.

SparkFountain
  • 2,110
  • 15
  • 35
  • Have you tried using `onMessageReceivedCallback` as shown here https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/docs/MESSAGING.md#handling-a-notification – Nick Iliev Jan 29 '20 at 13:45
  • Yes...that works only when i click the notifications. I have to click every notification one by one to get the data. But i want to do same without clicking all the notifications – Soumyadip Chattopadhyay Jan 29 '20 at 14:03
  • You are looking for [Data messages](https://firebase.google.com/docs/cloud-messaging/concept-options), you will just have to set the data attribute not notification when you send the request to FCM. – Manoj Jan 29 '20 at 16:18
  • Yes I'm reading data but that's only when i click the notification to open the app. When there's a notification and I don't click it and instead open the app. I want to read this notification – Soumyadip Chattopadhyay Jan 29 '20 at 21:02
  • Sorry I'm lost, if you don't want a notification but just like to read message use data message not notification. If you want to see the notification and do something before user clicks on it, you will have to customize onMessageReceive callback as Nick mentioned. – Manoj Jan 29 '20 at 21:35
  • We have 3 situations: 1.App is in foreground and we received message----then message data is received 2.App is in background and i get notifications---- on opening notification data is received 3.App in background and i get notification but now open app from app tray and not by clicking notification received ---- in this case notification persists till i click it and data is not read even though app has come from background to foreground....i want to read the data without clicking the notifications in this case. – Soumyadip Chattopadhyay Jan 30 '20 at 02:45

0 Answers0