Flutter Awesome Notification 无法将方法绑定到操作按钮
Flutter Awesome Notification couldn't bind a method to action button
我正在开发一个需要回复通知的应用程序。我可以在收到通知时显示按钮。但是,我无法将任何方法绑定到它。这是我的代码:
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 10,
channelKey: 'basic_channel',
title: 'Simple Notification',
body: 'Simple body'),
actionButtons: [
NotificationActionButton(
label: 'TEST',
enabled: true,
buttonType: ActionButtonType.Default,
key: 'test',
)
]);
print("Background message service");
}
感谢您的帮助!
您应该创建一个事件流并监听这样的事件:
AwesomeNotifications().actionStream.listen((event) {
print('event received!');
print(event.toMap().toString());
// do something based on event...
});
我正在开发一个需要回复通知的应用程序。我可以在收到通知时显示按钮。但是,我无法将任何方法绑定到它。这是我的代码:
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 10,
channelKey: 'basic_channel',
title: 'Simple Notification',
body: 'Simple body'),
actionButtons: [
NotificationActionButton(
label: 'TEST',
enabled: true,
buttonType: ActionButtonType.Default,
key: 'test',
)
]);
print("Background message service");
}
感谢您的帮助!
您应该创建一个事件流并监听这样的事件:
AwesomeNotifications().actionStream.listen((event) {
print('event received!');
print(event.toMap().toString());
// do something based on event...
});