Firebase Notification and Data

前端 未结 2 1790
闹比i
闹比i 2020-12-20 02:52

I am Creating an App using Firebase cloud messaging API... I am able to send notification and data to my client application from the server. But the problem is When the appl

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-20 03:21

    When you send a notification message with a data payload (notification and data) and the app is in the background you can retrieve the data from the extras of the intent that is launched as a result of the user tapping on the notification.

    From the FCM sample which launches the MainActivity when the notification is tapped:

    if (getIntent().getExtras() != null) {
        for (String key : getIntent().getExtras().keySet()) {
            String value = getIntent().getExtras().getString(key);
            Log.d(TAG, "Key: " + key + " Value: " + value);
        }
    }
    

提交回复
热议问题