中所述。
我正在将FCM集成到Flutter Demo Application。(。
我尝试过通知 数据消息,它正常工作。如FireBase_Messaging插件中所述。
{
"to" :"firebase-token",
"data" : {
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"body" : {
"message":"this is data message"
},
"title" : "data title",
"content_available" : true,
"priority" : "high"
}
}
这是Postman的通知请求的内容
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
Fimber.d("onMessage: $message");
Fluttertoast.showToast(msg: "onMessage: $message",
toastLength: Toast.LENGTH_LONG
);
},
onLaunch: (Map<String, dynamic> message) async {
Fimber.d("onLaunch: $message");
Fluttertoast.showToast(msg: "onLaunch: $message",
toastLength: Toast.LENGTH_LONG
);
},
onResume: (Map<String, dynamic> message) async {
Fimber.d("onResume: $message");
Fluttertoast.showToast(msg: "onResume: $message",
toastLength: Toast.LENGTH_LONG
);
},
);
_firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(sound: true, badge: true, alert: true));
_firebaseMessaging.onIosSettingsRegistered
.listen((IosNotificationSettings settings) {
Fimber.d("Settings registered: $settings");
});
_firebaseMessaging.getToken().then((String token) {
Fimber.d("token: $token");
});
它是在主页的初始状态。
我在iOS中有许可通知,并且可以很好地与Notification Data合作。
- 应如https://pub.dartlang.org/packages/firebase_messaging#-readme-tab--
- 我已经从这里找到了工作
像这样的JSON添加通知和声音
{
"content_available" : true,
"priority" : "high",
"to" :"fcm-token",
"notification":{
"sound": ""
},
"data" : {
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"body" : {
"message":"3:57pm"
},
"title" : "data title",
"content_available" : true,
"priority" : "normal"
}
}