Flutter 很棒的通知点击打开特定页面
我正在使用 Flutter 很棒的通知。当应用程序关闭时单击通知时,我想将其定向到应用程序内的特殊页面。对我来说最简单的方法是什么?
I am using Flutter awesome notifications. When the notification is clicked when the application is closed, I want to direct it to a special page within the application. What is the easiest way for me to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为此,首先您需要在
runApp< 之前
初始化
AwesomeNotifications /code> 然后简单地放置一个listner
来监听通知点击:初始化:
监听:
您可以在导航之前将该列表器放在启动屏幕的
initState
中或其他位置到应用程序的主屏幕。To do this, firstly you need to
initialize
AwesomeNotifications beforerunApp
and then simply put alistner
to listen to the notification click:Initialize:
Listen:
you can put that lister in the
initState
of your splash screen or something before navigating to Home Screen of the app.因为
actionStream
在 AwesomeNotification() 中不再可用我想提出一个不同的解决方案
NotificationController
Main
我建议将有效负载保存在SharedPreference中并在NotificationPage之后清除它
since
actionStream
isn't available anymore in AwesomeNotification()i would like to propose a different solution
NotificationController
Main
I would advice to save payload in SharedPreference and clear it after the NotificationPage