Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flatter中的Firebase clod消息传递:单击通知时打开特定路由(获取上下文)_Firebase_Dart_Push Notification_Flutter_Firebase Cloud Messaging - Fatal编程技术网

Flatter中的Firebase clod消息传递:单击通知时打开特定路由(获取上下文)

Flatter中的Firebase clod消息传递:单击通知时打开特定路由(获取上下文),firebase,dart,push-notification,flutter,firebase-cloud-messaging,Firebase,Dart,Push Notification,Flutter,Firebase Cloud Messaging,我正在使用firebase_消息获取应用程序上的推送通知。。我将与通知一起发送一条路径,以便在点击通知时显示一个特定页面,并借助flift_local_通知,如下所示: (我没有一个好的上下文) \u firebaseMessaging.configure( onMessage:(映射消息){ 打印('on message$message'); 打印(消息['route']); firebaseIn(消息['route']); }, onResume:(映射消息){ 打印('在简历上$messa

我正在使用firebase_消息获取应用程序上的推送通知。。我将与通知一起发送一条路径,以便在点击通知时显示一个特定页面,并借助flift_local_通知,如下所示: (我没有一个好的上下文)

\u firebaseMessaging.configure(
onMessage:(映射消息){
打印('on message$message');
打印(消息['route']);
firebaseIn(消息['route']);
},
onResume:(映射消息){
打印('在简历上$message');
firebaseOut(消息['route']);
},
onLaunch:(映射消息){
打印('on launch$message');
firebaseOut(消息['route']);
},
);
void firebaseIn(字符串路由){
使用默认声音(路线)显示通知;
}
未来onSelectNotification(字符串负载)异步{
路由器。导航到(当前上下文、有效负载、,
transition:TransitionType.INFOROMRIGHT,
转换持续时间:常量持续时间(毫秒:500));
}
Future showNotificationWithDefaultSound(字符串路由)异步{
var androidPlatformChannelSpecifics=新
AndroidNotificationDetails(
“您的频道id”、“您的频道名称”、“您的频道描述”,
重要性:重要性。最大,优先级:优先级。高);
var iOSPlatformChannelSpecifics=新的IOSNotificationDetails();
var platformChannelSpecifics=新通知详细信息(
androidPlatformChannelSpecifics、iOSPlatformChannelSpecifics);
等待本地通知。显示(
0,
'استطلاع جديد',
'لديك استطلاع جديد',
平台通道细节,
有效载荷:路线,
);
}
无效firebaseOut(字符串路由){
router.navigateTo(当前上下文、路由、,
transition:TransitionType.INFOROMRIGHT,
转换持续时间:常量持续时间(毫秒:500));
}
当在应用程序打开时收到通知时,此功能非常有效。。但是,当应用程序在后台运行或关闭并且收到通知时,当单击通知时,应用程序将从后台打开其状态,如果它已关闭,则从启动时打开

我希望在单击通知时打开特定的路由,即使它在后台或已关闭。。怎么做?有没有办法在颤振中实现这一点

_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) {
  print('on message $message');
  print(message['route']);
  globals.firebaseIn(message['route']);
},
onResume: (Map<String, dynamic> message) {
  print('on resume $message');
  globals.firebaseOut(message['route']);
},
onLaunch: (Map<String, dynamic> message) {
  print('on launch $message');
  globals.firebaseOut(message['route']);
},
);

void firebaseIn(String route) {
showNotificationWithDefaultSound(route);
}

Future onSelectNotification(String payload) async {
 router.navigateTo(currentContext, payload,
  transition: TransitionType.inFromRight,
  transitionDuration: const Duration(milliseconds: 500));
}

Future showNotificationWithDefaultSound(String route) async {
var androidPlatformChannelSpecifics = new 
 AndroidNotificationDetails(
  'your channel id', 'your channel name', 'your channel description',
  importance: Importance.Max, priority: Priority.High);
  var iOSPlatformChannelSpecifics = new IOSNotificationDetails();
  var platformChannelSpecifics = new NotificationDetails(
  androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
 await flutterLocalNotificationsPlugin.show(
0,
'استطلاع جديد',
'لديك استطلاع جديد',
platformChannelSpecifics,
payload: route,
 );
}

 void firebaseOut(String route) {
 router.navigateTo(currentContext, route,
  transition: TransitionType.inFromRight,
  transitionDuration: const Duration(milliseconds: 500));
 }