0

I have a problem with Firebase notifications.

When my app is completely closed and I send a notification, the app launcher gets the notification Data and can handle the incoming notification. Everything works fine then. But when I have the application open in the background (by exiting out via the home button) then neither my App launcher nor my onMessageReceived() method get called.

I can't find a reason why this would happen.

(onMessageReceived() is called correctly when app is in foreground)

EDIT: At the moment my onMessageReceived only logs if it got a message

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    Log.d(TAG, "onMessageReceived: Message from: " + remoteMessage.getFrom());
}

SOLUTION: I solved the problem by sending a data notification and then manually checking in the onMessageReceived() function if the app is in foreground and only displaying a notification then

ItsT-Mo
  • 113
  • 12
  • Possible duplicate of [Firebase onMessageReceived not called when app in background](http://stackoverflow.com/questions/37358462/firebase-onmessagereceived-not-called-when-app-in-background) – Hitesh Gehlot May 12 '17 at 08:12
  • Post your onMessageRecived() here for better help – Bruno Ferreira May 12 '17 at 08:13
  • Actually there are two types of message in firebase. for your query try to use "Data" message. see link [https://firebase.google.com/docs/cloud-messaging/concept-options] – RoHiT May 12 '17 at 08:58

0 Answers0