zey*_*zey 7 flutter flutter-notification awesome-notifications
我正在使用 Flutter 很棒的通知。当应用程序关闭时单击通知时,我想将其定向到应用程序内的特殊页面。对我来说最简单的方法是什么?
为此,首先您需要在initialize AwesomeNotifications之前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
);
Run Code Online (Sandbox Code Playgroud)
listenActionStream(){
AwesomeNotifications().actionStream.listen((receivedAction) {
var payload = receivedAction.payload;
if(receivedAction.channelKey == 'normal_channel'){
//do something here
}
});
}
Run Code Online (Sandbox Code Playgroud)
initState在导航到应用程序的主屏幕之前,您可以将该列表放在启动屏幕或其他位置。
| 归档时间: |
|
| 查看次数: |
4902 次 |
| 最近记录: |