【发布时间】:2020-01-06 22:43:24
【问题描述】:
当我点击应用程序(不是通知)时,每个通知都会自动删除。 这是一个大问题,当用户打开应用程序并删除所有通知时
【问题讨论】:
-
我使用了 Firebase 消息传递 5.14 和颤振 1.74。我在ios 9和ios 12中测试的问题。问题是一样的
标签: firebase flutter push-notification firebase-cloud-messaging
当我点击应用程序(不是通知)时,每个通知都会自动删除。 这是一个大问题,当用户打开应用程序并删除所有通知时
【问题讨论】:
标签: firebase flutter push-notification firebase-cloud-messaging
当应用程序进入前台时,我发现了一个不需要的自动清理通知场景。它位于第 159 行 https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_messaging/ios/Classes/FirebaseMessagingPlugin.m
- (void)applicationDidBecomeActive:(UIApplication *)application {
_resumingFromBackground = NO;
// Clears push notifications from the notification center, with the
// side effect of resetting the badge count. We need to clear notifications
// because otherwise the user could tap notifications in the notification
// center while the app is in the foreground, and we wouldn't be able to
// distinguish that case from the case where a message came in and the
// user dismissed the notification center without tapping anything.
// TODO(goderbauer): Revisit this behavior once we provide an API for managing
// the badge number, or if we add support for running Dart in the background.
// Setting badgeNumber to 0 is a no-op (= notifications will not be cleared)
// if it is already 0,
// therefore the next line is setting it to 1 first before clearing it again
// to remove all
// notifications.
application.applicationIconBadgeNumber = 1;
application.applicationIconBadgeNumber = 0;
}
这似乎是徽章计数器的一种解决方法。我还开了一个issue:https://github.com/FirebaseExtended/flutterfire/issues/114
【讨论】: