【发布时间】:2021-03-02 17:32:26
【问题描述】:
这是我的 Java 服务类 FCM
公共类 MyFirebaseMessagingService 扩展 FirebaseMessagingService { private static final String TAG = "FCM 数据标签" ;
@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
// TODO(developer): Handle FCM messages here.
Log.d(TAG, "From: " + remoteMessage.getFrom());
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
String data= remoteMessage.getNotification().getBody();
String details[] = (data.split("\n"));
String username,location,serviceType,date,time,area;
username=details[0];
location=details[1];
serviceType=details[2];
date=details[3];
time=details[4];
area=details[5];
Intent i=new Intent(getApplicationContext(),FragmentHome.class);
i.putExtra("user",username);
i.putExtra("loc",location);
i.putExtra("type",serviceType);
i.putExtra("Date",date);
i.putExtra("Time",time);
i.putExtra("Area",area);
}
我不知道如何在 kotlin 类中接收数据。
【问题讨论】:
-
查找本地广播接收器
-
在这种情况下,如果您想要在应用程序运行时点击通知的数据,请使用本地广播。
标签: java android kotlin android-intent broadcastreceiver