android上的颤振应用程序在单击通知时不会打开应用程序
按照上的说明,我已实施FCM。虽然我已设置了android上的颤振应用程序在单击通知时不会打开应用程序,android,firebase,flutter,firebase-cloud-messaging,firebase-notifications,Android,Firebase,Flutter,Firebase Cloud Messaging,Firebase Notifications,按照上的说明,我已实施FCM。虽然我已设置了单击\u操作:颤振\u通知\u单击,但当我单击通知托盘项目时,它不会打开应用程序。颤振应用程序从云功能接收的数据如下所示。我如何至少在通知单击时打开应用程序 onMessage: {notification: {title: pi, body: text message.}, data: {USER_NAME: pi, click_action: FLUTTER_NOTIFICATION_CLICK, }} 云功能有效载荷 c
单击\u操作:颤振\u通知\u单击
,但当我单击通知托盘项目时,它不会打开应用程序。颤振应用程序从云功能接收的数据如下所示。我如何至少在通知单击时打开应用程序
onMessage: {notification: {title: pi, body: text message.},
data: {USER_NAME: pi, click_action: FLUTTER_NOTIFICATION_CLICK, }}
云功能有效载荷
const payload = {
notification: {
title: sender,
body: content,
clickAction: 'ChatActivity',
},
data: {
"click_action": 'FLUTTER_NOTIFICATION_CLICK',
"USER_NAME": sender,
}
};
我还创建了通知通道,并且正确配置了AndroidManifest
private void createNotificationChannel() {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = getString(R.string.app_name);
String description = getString(R.string.notification_channel_description);
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel channel = new NotificationChannel(getString(R.string.default_notification_channel_id), name, importance);
channel.setDescription(description);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
}
我已经将单击操作放到了通知json中,它对我来说是有效的
notification: {
title: sender,
body: content,
click_action: 'FLUTTER_NOTIFICATION_CLICK'
}
单击操作仅适用于onResume
和onLaunch
回调,因此请确保按照pub.dev文档中的说明实施该操作:
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
_showItemDialog(message);
},
onBackgroundMessage: myBackgroundMessageHandler,
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
_navigateToItemDetail(message);
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
_navigateToItemDetail(message);
},
);
\u firebaseMessaging.configure(
onMessage:(映射消息)异步{
打印(“onMessage:$message”);
_showItemDialog(消息);
},
onBackgroundMessage:myBackgroundMessageHandler,
onLaunch:(映射消息)异步{
打印(“onLaunch:$message”);
_导航项目详细信息(消息);
},
onResume:(映射消息)异步{
打印(“onResume:$message”);
_导航项目详细信息(消息);
},
);
我试过了,但没用。当我在onMessage上打印有效负载时,它不会显示clickAction:“ChatActivity”或click_action:“Flatter_NOTIFICATION_click”。它只显示了主体和内容。