当我在应用程序未运行或在后台深层链接中点击通知不起作用时,它仅打开应用程序主页,并且不执行setNotificationOpenedHandler方法中的代码
class _MyAppState extends State<MyApp> {
String url = "https://www.google.com";
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
if (!mounted) return;
OneSignal.shared.setLogLevel(OSLogLevel.verbose, OSLogLevel.none);
var settings = {
OSiOSSettings.autoPrompt: false,
OSiOSSettings.promptBeforeOpeningPushUrl: true
};
OneSignal.shared.setNotificationOpenedHandler(
(OSNotificationOpenedResult result) {
this.setState(() {
url = result.notification.payload.additionalData['url'].toString() ;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => notification(webUrlNotification)));
});
});
await OneSignal.shared
.init("01589fd3429d-4849-4849-5539-086d22bd", iOSSettings: settings);
OneSignal.shared
.setInFocusDisplayType(OSNotificationDisplayType.notification);
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: const Text('OneSignal Flutter Demo'),
backgroundColor: Color.fromARGB(255, 212, 86, 83),
),
body: Text(url)
),
);
}
}
当用户轻按通知打开安装应用程序的主屏幕时,我需要导航到通知屏幕吗?