I am looking for this functionality:
I am looking for pointers. Could not find any tutorials or packages providing this kind of functionality.
Thank you for your help!
I am looking for this functionality:
I am looking for pointers. Could not find any tutorials or packages providing this kind of functionality.
Thank you for your help!
有一个名为awesome_notifications的包,您可以将其用于此目的。要添加自定义操作按钮,您可以这样做:
await AwesomeNotifications().createNotification(
content: NotificationContent(
id: 0,
channelKey: 'basic_channel',
title: 'Simple title',
body: 'Simple body ',
),
actionButtons: [
NotificationActionButton(
key: 'accept',
label: 'Accept',
),
NotificationActionButton(
key: 'cancel',
label: 'Cancel',
),
],
);
对于基于操作的操作,您必须收听此流:
AwesomeNotifications().actionStream.listen((event) {
if (event.buttonKeyInput == 'cancel') //...
else // ...
});
您可以在应用程序启动并运行时使用此库,但当应用程序终止时您实际上无法使用它,您最好使用 FCM 通知,然后打开应用程序,然后根据通知类型采取措施。
firebase_messaging 包不为操作按钮提供任何解决方案。你可以data
用你的onMessageReceived()
方法。您可以创建自己的自定义通知。