无法通过 Flutter/Firebase 云消息接收 iOS 通知 10.0.1+

问题描述

很长一段时间以来,我一直在努力通过 FCM 在 Flutter 上处理 iOS 推送通知。在 Flutter 和 firebase 的最新重大更新之前,情况似乎要复杂得多,但我不确定到底发生了什么变化。

我在 Android 上收到通知,所以我假设我的问题在于使用 APN 的特殊 iOS 设置,但确切的问题仍然没有解决

我已经遵循了所有的 special iOS steps(除了图像有效载荷的东西,因为我不需要它)。一两个星期前,我从虚拟机转移到了真正的机器,我重新编写了所有证书/密钥/配置文件/标识符的东西,认为问题可能是用另一台机器签名,但这并没有解决。我也不是“自动管理签名”(在 xcode 中的“签名和功能”下)。我已启用后台模式和远程通知。我正在使用的 PHYSICAL iOS 设备上的 testflight 应用程序的通知已打开。

我的 AppDelegate.swift 文件中有以下代码

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedpluginRegistrant.register(with: self)

//for push notifications
if #available(iOS 10.0,*) {
    //for ios 10 display notification sent via APNS
    UNUserNotificationCenter.current().delegate = self
    let authOptions: UNAuthorizationoptions = [.alert,.badge,.sound]
    UNUserNotificationCenter.current().requestAuthorization(
        options: authOptions,completionHandler: {_,_ in })
} else {
    let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert,.sound],categories: nil)
    application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()

return super.application(application,didFinishLaunchingWithOptions: launchOptions)
  }
}

我的 Info.plist 文件中也有以下行(不是确切的格式,但您知道 info.plist 文件的样子):

FirebaseAppDelegateProxyEnabled: NO

此外,我知道 FCM 至少是部分集成的,因为我的 iOS 应用程序正在获取写入我的数据库的 FCM 通知令牌。但是,当我从 FCM 控制台发送消息时,它们永远不会到达 iOS 设备(前台后台)。

我真的不知道发生了什么。但我一直在拔头发。任何帮助将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)