0

When I open the app and send notification from the Firebase console , the onMessageReceived works fine. The app has its small icon , Notification sound ,etc.. But when the app is killed or is closed , no notification sound or a small icon appears.

AL.
  • 36,815
  • 10
  • 142
  • 281
Mahmoud Ashour
  • 327
  • 4
  • 11
  • have you followed this https://firebase.google.com/docs/cloud-messaging/android/receive? – Kasnady Feb 13 '18 at 04:08
  • Follow this answer [Here](https://stackoverflow.com/questions/37711082/how-to-handle-notification-when-app-in-background-in-firebase) you will have what you needed. – Mohammed Farhan Feb 13 '18 at 04:40
  • Please Refer this link.It may help you. [link](https://stackoverflow.com/questions/44969637/android-firebase-push-notification-not-working-when-application-is-killed/44971894#44971894) – Patel Dhara Feb 13 '18 at 07:46
  • Possible duplicate of [Not receiving Firebase Cloud Messaging Notifications](https://stackoverflow.com/questions/45178957/not-receiving-firebase-cloud-messaging-notifications) – AL. Feb 13 '18 at 18:10

1 Answers1

0

After GCM the google changed the GCM as FCM, And FCM are containing two type of payload one is Notification and another One is Data payload when you are posting notification with Notification Payload then app will be in background then onMessageReceived not called but when in foreground onMessageReceived called, But if you put Data payload then all-time onMessageReceived is called.

Using Notification Payload

onMessageReceived called in the only foreground not in background

Using Data Payload

onMessageReceived called every time

Mohammed Farhan
  • 1,120
  • 8
  • 14
Dhaval Solanki
  • 4,589
  • 1
  • 23
  • 39