【发布时间】:2022-01-13 06:02:12
【问题描述】:
我正在使用awesome_notifications 显示通知,并且有关闭通知的操作按钮,但问题是如果应用程序在后台,并且单击操作按钮,那么它会关闭通知但也打开应用程序我不想要。那么如何在不打开应用程序的情况下单击操作按钮时关闭通知?该通知还包含另一个打开应用程序的操作按钮,但第二个不应该。 这种情况我该怎么办?
显示通知的代码:
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 333,
title: 'Incoming Call',
body: 'from $callerName',
category: NotificationCategory.Call,
channelKey: 'call_channel',
largeIcon: 'asset://assets/images/logo_square.png',
wakeUpScreen: true,
fullScreenIntent: true,
autoDismissible: false,
showWhen: true,
displayOnBackground: true,
displayOnForeground: true,
payload: {
"callerName": callerName,
"callerUsername": callerUsername,
"callerID": callerID,
"callerToken": callerToken,
"callerImage": callerImage,
},
),
actionButtons: [
NotificationActionButton(
key: 'ACCEPT',
label: 'Accept Call',
color: Colors.green,
autoDismissible: true,
),
NotificationActionButton(
key: 'REJECT',
label: 'Reject Call',
isDangerousOption: true,
autoDismissible: true,
),
]
);
【问题讨论】:
-
添加通知操作按钮的代码。
-
代码已添加,请查看!
-
他们的网站 (pub.dev/packages/awesome_notifications) 在“后续步骤”部分显示
Add an option to choose if a notification action should bring the app to foreground or not.,所以我认为该软件包尚不支持。 -
好的,我找到了答案,感谢您的帮助!
标签: android flutter push-notification notifications dismiss