打开通知时,我尝试不推送其他页面。但是没事。我使用此代码
OneSignal.shared
.setNotificationOpenedHandler((OSNotificationOpenedResult result) {
// will be called whenever a notification is opened/button pressed.
Navigator.pushNamed(context, '/setting') ;
});
然后我用此代码接收数据
OneSignal.shared
.setNotificationReceivedHandler((OSNotification notification) {
Map<String, dynamic> asm = notification.payload.additionalData;
String titles = notification.payload.title;
String bodys = notification.payload.body;
// textf = titles;
// print(asm);
// print(titles);
// print(bodys);
});