Firebase云消息传递捕获通知

时间:2018-05-30 07:54:33

标签: android firebase push-notification firebase-cloud-messaging message

我想收到一条消息,我发送Firebase Cloud Messaging。如果我的应用程序在前台,我可以收到消息并发送自己的通知(更改徽标,发送额外数据,...)。但如果我的应用程序不在前台或已关闭,Android会从Firebase-System收到通知。我无法抓住他们。所以我无法在通知中加入一些extraData。我需要extraData,因为我想通过onclick打开我的应用程序并在应用程序中加载一些依赖于消息的特殊数据。

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");
 }

0 个答案:

没有答案