After receiving a push notification, you need to parse the data.
Rewrite the FirebaseMessagingService.onMessageReceived
method to get the custom extension field in the RemoteMessage
object. The sample code is as follows:
_29public class FCMMSGService extends FirebaseMessagingService {
_29 public void onMessageReceived(RemoteMessage remoteMessage) {
_29 super.onMessageReceived(remoteMessage);
_29 if (remoteMessage.getData().size() > 0) {
_29 String f = remoteMessage.getData().get("f");
_29 String t = remoteMessage.getData().get("t");
_29 String m = remoteMessage.getData().get("m");
_29 String g = remoteMessage.getData().get("g");
_29 Object e = remoteMessage.getData().get("e");
_29 public void handleIntent ( @NonNull Intent intent ) {
_29 super.handleIntent(intent);
_29 Bundle bundle = intent . getExtras();
_29 if (bundle != null) {
_29 Map<String, Object> map = new HashMap<>();
_29 for (String key : bundle.keySet()) {
_29 if (!TextUtils.isEmpty(key)) {
_29 Object content = bundle.get(key);
_29 map.put(key, content);
_29 Log.i(TAG, "handleIntent: " + map);
Parameter | Description |
---|
f | The user ID of the push notification sender. |
t | The user ID of the push notification recipient. |
m | The message ID: A unique identifier of the message. |
g | The group ID: This field exists only for group messages. |
e | The user-defined extension field. |
e
is a completely user-defined extension. The data source is em_push_ext.custom
of the message extension. The data structure is as follows:
The data structure of the extension in the RemoteMessage
object is as follows: