![](/img/trans.png)
[英]How do I open a specific page on onesignal notification click on flutter?
[英]Flutter awesome notification click open specific page
我正在使用 Flutter 很棒的通知。 當應用程序關閉時單擊通知時,我想將其定向到應用程序中的特殊頁面。 對我來說最簡單的方法是什么?
為此,首先您需要在runApp之前initialize
runApp
,然后簡單地放置一個listner
來監聽通知點擊:
AwesomeNotifications().initialize(
'resource://drawable/logo_circle_notification',
[
NotificationChannel(
channelGroupKey: 'normal_channel_group',
channelKey: 'normal_channel',
channelName: 'Normal Notifications',
channelDescription: 'Notification channel for normal notifications',
defaultColor: const Color(0xFF9D50DD),
ledColor: Colors.white
),
],
channelGroups: [
NotificationChannelGroup(
channelGroupkey: 'basic_channel_group',
channelGroupName: 'Basic group'),
],
debug: true
);
listenActionStream(){
AwesomeNotifications().actionStream.listen((receivedAction) {
var payload = receivedAction.payload;
if(receivedAction.channelKey == 'normal_channel'){
//do something here
}
});
}
在導航到應用程序的主屏幕之前,您可以將該列表器放在啟動畫面的initState
或其他內容中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.