我正在使用firebase和很棒的通知包。
firebase_core:^2.20.0
firebase_messaging:^14.7.2
awesome_notifications_core:^0.8.1#<~始终确保使用最新版本
令人敬畏的通知:任何
Flutter awesome_notification actionButton在应用程序终止时不显示。
它显示应用程序何时处于前台和后台。
这些是我的密码。
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
AwesomeNotificationHelper.createNewNotification(message);
return Future<void>.value();
}
static Future<void> createNewNotification(RemoteMessage message) async {
RemoteNotification? notification = message.notification;
bool isAllowed = await AwesomeNotifications().isNotificationAllowed();
if (!isAllowed || notification == null) return;
await AwesomeNotifications().createNotification(
content: NotificationContent(
id: -1,
channelKey: 'alerts',
title: notification.title,
body: notification.body,
payload: {'notificationId': '1234567890'}),
actionButtons: [
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,
)
],
);
}