【发布时间】:2020-06-23 09:21:36
【问题描述】:
我想在接收到 Firebase 通知时打开接听电话或拒绝接听电话。但是当应用程序在前台但当应用程序在后台通知日志显示但从不调用活动时,它会打开活动。
公共类 FirebaseNotificationService 扩展 FirebaseMessagingService {
private static final String TAG = "Firebase";
private int remedyNotificationID = 0;
NotificationManager notificationManagerRemedy;
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e(TAG, "Notification Received ");
Map<String, String> data = null;
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.e(TAG, "Notification Received: " + remoteMessage.getData());
data = remoteMessage.getData();
}
if (data != null) {
Intent intent = new Intent(getApplicationContext(), IncomingVideoCallActivity.class);
Bundle bundle = new Bundle();
bundle.putString("user_id", data.get("user_id"));
bundle.putString("user_full_name", data.get("user_full_name"));
intent.putExtras(bundle);
startActivity(intent);
}
}
}
【问题讨论】:
-
后台场景使用点击动作处理
-
我不明白。你能解释一下吗
标签: android firebase-cloud-messaging