【发布时间】:2022-01-16 09:39:24
【问题描述】:
当后台 firebase 中的应用程序首先处理通知然后颤动本地通知在屏幕上显示一个弹出窗口以使 firebase 不显示通知时,我遇到了显示双重通知的问题
p.s 删除
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
让应用不处理后台通知
FirebaseMessaging.onMessage.listen(
(RemoteMessage? message) async {
_showNotification(
id: 0,
title: message?.notification?.title ?? '',
body: message?.notification?.body ?? '');
},
);
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
firebaseMessagingBackgroundHandler:
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage? message) async {
_showNotification(
id: 0,
title: message?.notification?.title ?? '',
body: message?.notification?.body ?? '');
}
即使应用在后台运行,firebase 包也会在通知标志中包含标题和正文 使通知仅由 flutter_local_notification 包处理的任何方式
【问题讨论】:
标签: flutter push-notification firebase-cloud-messaging flutter-local-notification