简体   繁体   English

如何阅读通知Firebase oncreate动作

[英]How To Read Notification Firebase oncreate Action

I'm using fireBase to recive notifcation and handle it in backgroud and i need to get data on onCreate() Method : 我正在使用fireBase接收通知并在backgroud中处理它,我需要在onCreate()方法上获取数据:

public class MyFirebaseMessagingService extends FirebaseMessagingService {
   @Override
    public void onCreate() {
        super.onCreate();
//how to get notification body here not in onMessageReceived(RemoteMessage remoteMessage) 
    }
}

Messages are handled in onMessageReceived() , see the example at the bottom. 消息在onMessageReceived()中处理,请参见底部的示例。

Firebase has multiple message types - notification messages and data messages: https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages Firebase具有多种消息类型-通知消息和数据消息: https : //firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);

    //notification message
    RemoteMessage.Notification notification = remoteMessage.getNotification();
    String body = notification.getBody();

    //data message
    Map<String, String> data = remoteMessage.getData();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:如何避免点击通知调用onCreate() - Android: How to avoid that clicking on a Notification calls onCreate() 如何在更改方向时禁用onCreate操作? - How to disable onCreate action when will orientation be changed? 在create上调用firebase getvalue - Call firebase getvalue oncreate 如何通过单击通知操作按钮删除通知? - How to delete a Notification by clicking on a notification action button? 如何清除通知操作点击的通知? - How to clear notification on notification action click? Firebase通知-如何设置通知语言? - Firebase Notification - How to set language of a notification? 如何检查用户是否已从操作栏中读取或删除某些通知消息? - How do I check if some notification message is already read or deleted from action bar by user? 如何通过通知动作打开正在运行的活动? - How to open an running activity with a notification action? Firebase推送通知云消息传递如何访问附加数据作为通知 - Firebase push notification cloud messaging how to access Additional Data as Notification 如何在Android主类的oncreate中调用ic_action_overflow按钮(选项菜单)onclicklistner - How to call ic_action_overflow button(option menu )onclicklistner in oncreate of main class in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM