我想在来自 firebase 时显示一条通知,就像这个一样,使用 Awesome_notification
。
我的包裹:
awesome_notifications: ^0.9.3+1
awesome_notifications_fcm: ^0.9.2
目前我只了解如何进行本地通知。 我了解听众
await AwesomeNotifications().setListeners(
onActionReceivedMethod: onActionReceivedMethod,
onNotificationCreatedMethod: onNotificationCreatedMethod,
onNotificationDisplayedMethod: onNotificationDisplayedMethod,
onDismissActionReceivedMethod: onDismissActionReceivedMethod,
);
但我真的不明白如何在不进行无限通知循环的情况下实现我的任务( 我将非常感谢您的想法!
尝试阅读以下材料
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 100,//<-- pass/createUniqueId(),
channelKey: 'basic_channel',
title: message.notification.title,
body: message.notification.body,
bigPicture: 'https://imagePath/eee....png',
largeIcon: 'https://imagePath/larg....png',
notificationLayout: NotificationLayout.BigPicture,
),//
actionButtons: [ //<--if needed
NotificationActionButton(key: 'REDIRECT', label: 'Redirect'),
NotificationActionButton(
key: 'REPLY',
label: 'Reply Message',
requireInputText: true,
actionType: ActionType.SilentAction
),
NotificationActionButton(
key: 'DISMISS',
label: 'Dismiss',
actionType: ActionType.DismissAction,
isDangerousOption: true)
]);
});//