gpt4 book ai didi

ios - 当应用程序在后台运行或关闭时,Flutter Firebase Messaging 在 IOS 上不起作用

转载 作者:行者123 更新时间:2023-12-02 10:40:40 25 4
gpt4 key购买 nike

我已经配置了带有 flutter 通知的firebase云消息传递在前台工作。但在后台运行或应用程序被杀死时不起作用。

完成以下步骤。

  • 生成app ID并push Key
    https://developer.apple.com/account/resources/certificates/
  • 将 info.plist 添加到 ios/Runner 文件夹
  • 开启推送功能
  • 已将 APNS 证书上传到 Firebase 控制台
  • 在 AppDelegate.swift
  • 中添加了行

    还尝试按照 Flutter Firebase Cloud Messaging - Notification when app in background 上的建议删除以下行但它仍然无法正常工作。

    if (@available(iOS 10.0, *)) {
    [UNUserNotificationCenter currentNotificationCenter].delegate = (id) self;
    }
    Flutter Doctor

    [✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.14.5 18F132, locale en-IN)

    [✗] Android toolchain - develop for Android devices

    ✗ Unable to locate Android SDK.

    Install Android Studio from: https://developer.android.com/studio/index.html

    On first launch it will assist you in installing the Android SDK components.

    (or visit https://flutter.dev/setup/#android-setup for detailed instructions).

    If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.

    You may also want to add it to your PATH environment variable.



    [✓] Xcode - develop for iOS and macOS (Xcode 11.3)

    [✓] Chrome - develop for the web

    [!] Android Studio (not installed)

    [✓] Connected device (3 available)

    我注意到一件事,当第一次安装应用程序时,它并没有要求我检查我是否允许应用程序发送推送通知。

    登录页面后,我的代码在页面上有以下行。
    _firebaseMessaging.requestNotificationPermissions(
    const IosNotificationSettings(sound: true, badge: true, alert: true));
    _firebaseMessaging.onIosSettingsRegistered
    .listen((IosNotificationSettings settings) {
    print("Settings registered: $settings");
    });

    还交叉检查是否勾选了所有以下设置。

    enter image description here

    最佳答案

    经过很长时间寻找修复程序,这为我解决了问题:

  • 在您的 info.plist 中:
     FirebaseAppDelegateProxyEnabled: false
  • 将此添加到您的 AppDelegate:
    override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

    Messaging.messaging().apnsToken = deviceToken
    super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
    }
  • 关于ios - 当应用程序在后台运行或关闭时,Flutter Firebase Messaging 在 IOS 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60350461/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com