描述了我在ios上无法获得APN令牌的bug。推送通知在android上运行良好。我在没有运气的情况下重复了FCM苹果集成步骤。我在这个问题上被困了几个星期。
封装版本和测试设备
xcode配置
在调试和发布模式下,我启用了推送通知和后台模式(后台获取、远程通知、后台处理)功能。
AppDelegate.swift ``` import UIKit import Flutter import Firebase
@UIApplicationMain @objc类AppDelegate: FlutterAppDelegate { override应用程序(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: UIApplication.LaunchOptionsKey: Any?) -> Bool { FirebaseApp.configure() GeneratedPluginRegistrant.register(带: self)如果可用(iOS 10.0,*) { UNUserNotificationCenter.current().delegate = self as?UNUserNotificationCenterDelegate }返回super.application(application,didFinishLaunchingWithOptions: launchOptions) }}
</details>
<details>
<summary>debug console</summary>
```flutter: User granted permission
8.8.0 - [Firebase/Messaging][I-FCM002022] APNS device token not set before retrieving FCM Token for Sender ID '662970956514'. Notifications to this FCM Token will not be delivered over APNS.Be sure to re-retrieve the FCM token once the APNS device token is set.
flutter: APNSToken: null
flutter: Token: c0yzY5QV4EUFudl0fmcCfA:APA91bHzAM9e2jfPEoDBnHQE9xCIG-EwnGatI9RDYPJQ4Apm5tOujBsplHyAqTm2V7DEPXSmDaPcr1okv6qhP-eoWHNmPs3e8IgN9CI4ErS2-W54_EydI2ypZ9ckJNOluLV_ECtWyP4i
[Client] Updating selectors after delegate removal failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 85 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service on pid 85 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
Output of `flutter doctor -v` ```Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.2.3, on macOS 11.6 20G165 darwin-x64, locale en-ET) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 2020.3) [✓] VS Code (version 1.61.1) [✓] Connected device (2 available)
·没有发现任何问题!`
提前谢谢你。
发布于 2022-03-17 08:12:19
检查是否使用iOS模拟器:https://firebase.flutter.dev/docs/messaging/notifications
通过APN进行的FCM在iOS模拟器上不工作。要接收消息和通知,需要一个真正的设备。
https://stackoverflow.com/questions/69791928
复制相似问题