[英]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.