0

I want to receive a message, I send with Firebase Cloud Messaging. If my app is in the foreground I can receive the message and send an own notification (change logo, send extraData, ...). But if my App wasn't in the foreground or closed, Android gets a notification from the Firebase-System. I can't catch them. So I'm not able to put some extraData into the notification. I need extraData, because I want to open my App by onclick on the notification AND load some special data inside the app dependent from the message.

public class MyFirebaseMessagingService extends FirebaseMessagingService {

public MyFirebaseMessagingService() {
    super();
}

@Override
public void onMessageReceived(RemoteMessage message) {
    // enters only, if app is in the foreground
    super.onMessageReceived (message);

    final String msg = message.getData().get("body");

    sendMyNotification(msg);

    Log.d("MyFirebaseIIDService","new Notification");
 }
ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
Felix
  • 1
  • please check this, https://stackoverflow.com/questions/37711082/how-to-handle-notification-when-app-in-background-in-firebase?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Paraskevas Ntsounos May 30 '18 at 08:10
  • also check this video https://www.youtube.com/watch?v=PGMt11DK2uo – Paraskevas Ntsounos May 30 '18 at 08:13
  • Hey Felix. I would suggest looking into the [Message Types documentation](https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages). What you're experiencing could possibly be a default behavior, depending on your payload. – AL. May 30 '18 at 14:50

0 Answers0