我试图在单击推送通知时实现打开特定屏幕,我的有效负载如下所示:
var payload = {
notification: {
title: notificationTitle,
body: notificationMessage,
click_action:"/screena",sound:"default",
}
};
我收到通知,但我无法捕捉通知点击事件,如何捕捉它。我正在使用颤振消息传递
https://github.com/flutter/plugins/tree/master/packages/firebase_messaging
我的firebase推送消息服务代码看起来像这样
pushMessagingService() async{
messagingreference.configure(
onMessage: (Map<String, dynamic> message) {
print("I am here in on message");
print(message);
},
onLaunch: (Map<String, dynamic> message) {
print("I am here onLaunch");
print(message);
},
onResume: (Map<String, dynamic> message) {
print("I am hereonResume");
print(message);
},
);
messagingreference.requestNotificationPermissions(
const IosNotificationSettings(sound: true, badge: true, alert: true));
messagingreference.onIosSettingsRegistered
.listen((IosNotificationSettings settings) {
print("Settings registered: $settings");
});
messagingreference.getToken().then((String token) async {
print(token);
});
}
在这里,当我的应用程序在前台时,我可以收到消息,正如@xqwzts 在消息中所说,但我的问题是如何从系统托盘中提出的推送通知中捕获点击事件并导航到所需的屏幕。
原文由 siva kumar 发布,翻译遵循 CC BY-SA 4.0 许可协议