使用 firebase 在我的 flutter 应用程序中接收双推送通知

问题描述 投票:0回答:1

我在我的 flutter 应用程序中接收推送通知并使用 firebase。通过 firebase 发送时,我只收到一次,而通过后端服务器发送时,我收到两次。

我正在使用 flutter 本地通知来显示 Android 中的通知。

如文档中所述 - https://pub.dev/packages/flutter_local_notifications#handling-notifications-whilst-the-app-is-in-the-foreground

我已启用演示选项如下

 const DarwinInitializationSettings initializationSettingsDarwin =
        DarwinInitializationSettings(
      requestAlertPermission: false,
      requestBadgePermission: false,
      requestSoundPermission: false,
    );

Future<void> enableIOSNotifications() async {
    await FirebaseMessaging.instance
        .setForegroundNotificationPresentationOptions(
      alert: true, // Required to display a heads up notification
      badge: true,
      sound: true,
    );
  }

如果我需要编辑 AppDelegate.swift 中的代码来解决此问题或我缺少的任何其他重要配置,请告诉我。

flutter firebase push-notification firebase-cloud-messaging apple-push-notifications
1个回答
0
投票

从服务器发送此内容

{
    "to":"_some_fcm_token_",
    "notification": {},//remove this line
    "type": "post_like",
    "data": {
        "model":{"id":"dsaflkdskfklgdkgjdksakdk"},
        "body": "this is subtitle",
        "title": "this is title",
        "click_action": "FLUTTER_NOTIFICATION_CLICK"
    },
    "priority": "normal"
}

发送无通知键值

© www.soinside.com 2019 - 2024. All rights reserved.