屏幕无法在onLaunh()
和onResume()
Firebase消息传递方法中导航,并且我尝试显示本地通知以导航碎石,但仍然失败。
我的有效载荷
onResume payload======{notification: {}, data: {notification_type: VideoCalling, role: ROLE_CONSILIER_CARIERA,google.original_priority:高, google.sent_time:1576478554401,google.delivered_priority:高, 约会: {"video_duration":"0","mod_desfasurare":"3","observatii_destinatar":","发起人":"204","observatii_initiator":"chdh","data_sfarsit_programare":"2019-12-14 12:00:00","created_by_user":"204","data_inceput_programare":"2019-12-14 11:00:00","status_destinatar":"1","status_initiator":"1","descriere":"chhxsh","destinatar":"246","tip":"0","id":"241","data_adaugarii":"2019-12-13 15:56:39","titlu":"test 13 dc","disponibilitate":"346"}, body: Apelul 视频节目在Este Activ acum Pentru学生,标题:Escouniv, click_action: FLUTTER_NOTIFICATION_CLICK, google.message_id: 0:1576478554409777%dd3b8f6edd3b8f6e, collapse_key: com.sys.escouniv, google.ttl: 2419200, 来自: 347273381579, 编号: 50, 状态: 完成}}
onLaunch: (Map<String, dynamic> msg) async {
Log.e('onLaunch====== ', msg);
Log.e('onLaunch data====== ', msg['data']);
// showNotification(msg);
_navigateToItemDetail(msg);
/* Future.delayed(
const Duration(seconds: 4),
() => Navigator.push(
context,
new MaterialPageRoute(builder: (context) => new StudentTutorials(user:UserType.Student,)),
));*/
},
@Anand Saga在这里我遵循了同样的事情, 正如我理解为什么我得到的密钥notification
空,但onMessage
我得到了标题和正文notification
。
添加一个布尔标志,并在构建完成后将其设置为 true,如下所示
WidgetsBinding.instance.addPostFrameCallback((_){ flag = true; });
并在您的onLaunch
内使用此计时器
Timer.periodic(Duration(seconds: 1), (timer){
if(flag) {
timer.cancel();
doNavigation();
}
});