我已经在Android上制作了一个Flutter应用程序,并使用firebase进行了推送通知..一切都做得很好...在任何情况下我都收到了通知
我的问题是当我单击通知时: 我想打开“通知给传递到特定屏幕(称为SingleNotification)”的通知并在“数据集”上接收到的数据,并显示其中的内容。
并正确显示数据。
代码:
var android = new AndroidInitializationSettings("mipmap/ic_launcher");
var ios = new IOSInitializationSettings();
var platform = new InitializationSettings(android, ios);
flutterLocalNotificationsPlugin.initialize(platform);
if (Platform.isIOS) iOS_Permission();
_firebaseMessaging.getToken().then((token){
if(deviceToken == "") {
_saveFirbaseToken(token);
print(token);
}
});
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print('on message $message');
_showNotification(message);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SingleNotification(message['notification']['title'],message['notification']['body']),
));
},
onResume: (Map<String, dynamic> message) async {
print('on Resume $message');
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SingleNotification(message['data']['title'],message['data']['body'])),
},
onLaunch: (Map<String, dynamic> message) async {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SingleNotification(message['data']['title'],message['data']['body']),
));
},
);
_showNotification(Map<String, dynamic> message) async{
var android = new AndroidNotificationDetails('channel_id', "CHANNEL NAME", "Channel Description");
var iOS = new IOSNotificationDetails();
var platform = new NotificationDetails(android, iOS);
// Read Data
String title = message['data']['title'];
String description = message['data']['body'];
await flutterLocalNotificationsPlugin.show(0,title, description, platform);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SingleNotification(message['data']['title'],message['data']['body']),
));
}
任何帮助将不胜感激...谢谢