【发布时间】:2020-04-27 01:58:30
【问题描述】:
当我收到来自 firebase 的通知时,我需要显示自定义对话框。但我不知道如何从通知负载中获取我的数据
我已经尝试过下面的代码,但它是机器人为我工作
Future<void> _handleNotification(
Map<dynamic, dynamic> message, bool dialog) async {
final dynamic data = message['data'] ?? message;
final dynamic notification = message['notification']['body'] ?? message;
final String itemId = data['body'];
debugPrint("DATA ->> $data");
debugPrint("notification ->> $notification");
message.forEach((k, v) => debugPrint("${k} - ${v}"));
}
这是我在控制台中的有效负载
flutter: 通知消息 {gcm.message_id: 1578573493122232, id: 30, google.cae: 1, type: test, aps: {alert: {title: notification title, body: Message of Push notification}, sound: 1 }}
任何机构都可以帮助从通知负载中获取数据吗?
【问题讨论】:
标签: flutter dart firebase-cloud-messaging