No error FCM works fine when app is open, if it is closed or swiped off, notification will not trigger.
Asked
Active
Viewed 957 times
1 Answers
0
Firebase notifications behave differently depending on the foreground/background state of the receiving app. If you want foregrounded apps to receive notification messages or data messages, you’ll need to write code to handle the onMessageReceived callback.
If your app is in the background or closed then a notification message is shown in the notification center, and any data from that message is passed to the intent that is launched as a result of the user tapping on the notification.
https://firebase.google.com/docs/cloud-messaging/android/receive

Chirag
- 56,621
- 29
- 151
- 198
-
' super.onMessageReceived(remoteMessage); Log.d(TAG, "From: " + remoteMessage.getFrom()); String messageBody = ""; if (remoteMessage.getData().size() > 0) { Log.d(TAG, "Message data payload: " + remoteMessage.getData()); messageBody = remoteMessage.getData().values().toArray()[0].toString(); } if (remoteMessage.getNotification() != null) { Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody()); } sendNotification(messageBody);' this is my onMessageRecieved() code – Supz Nov 24 '16 at 11:16