Future<void> create({
required String key,
required String title,
required String body,
required String bigPicture,
}) async {
await _notiff.createNotification(
content: NotificationContent(
id: DateTime.now().millisecondsSinceEpoch.remainder(10),
channelKey: key,
title: title,
body: body,
bigPicture: bigPicture,
notificationLayout: NotificationLayout.BigPicture,
),
actionButtons: [
NotificationActionButton(
buttonType: ActionButtonType.InputField,
enabled: true,
label: "Comment",
key: "COMMENT_BUTTON_KEY")
]);
}
您是否需要创建侦听器来获取这样的新通知:
AwesomeNotifications().actionStream.listen(
(ReceivedNotification receivedNotification){
Navigator.of(context).pushNamed(
'/NotificationPage',
arguments: {
// your page params. I recommend you to pass the
// entire *receivedNotification* object
id: receivedNotification.id
}
);
}
);
PD:您是否需要替换为您的数据,此信息在文档中(5.如何显示本地通知)
AwesomeNotifications().actionStream.listen( (收到通知收到通知){
if (event.buttonKeyPressed == "COMMENT_BUTTON_KEY"){
String userComment = event.buttonKeyInput;}
);