当应用进入前台时,Flutter FirebaseMessaging 通知会自动删除



当我点击应用程序(不是通知(时,每个通知都会自动删除。 这是一个大问题,当用户打开应用程序并删除所有通知时

当应用程序进入前台时,我发现了不需要的自动清理通知场景。它在 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;
}

这似乎是徽章计数器的解决方法。我还打开了一个问题:https://github.com/FirebaseExtended/flutterfire/issues/114

相关内容

  • 没有找到相关文章

最新更新