首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >FirebaseMessaging.instance.getAPNSToken总是返回null

FirebaseMessaging.instance.getAPNSToken总是返回null
EN

Stack Overflow用户
提问于 2021-11-01 01:44:24
回答 1查看 709关注 0票数 4

描述了我在ios上无法获得APN令牌的bug。推送通知在android上运行良好。我在没有运气的情况下重复了FCM苹果集成步骤。我在这个问题上被困了几个星期。

封装版本和测试设备

  • 颤振: 2.2.3
  • firebase_core: 1.8.0
  • firebase_messaging: 10.0.9
  • iPhone 7: 14.4.1 (真实设备)

xcode配置

在调试和发布模式下,我启用了推送通知和后台模式(后台获取、远程通知、后台处理)功能。

代码语言:javascript
运行
复制
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) }}

代码语言:javascript
运行
复制
</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.}
代码语言:javascript
运行
复制
 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) 

·没有发现任何问题!`

提前谢谢你。

EN

回答 1

Stack Overflow用户

发布于 2022-03-17 08:12:19

检查是否使用iOS模拟器:https://firebase.flutter.dev/docs/messaging/notifications

通过APN进行的FCM在iOS模拟器上不工作。要接收消息和通知,需要一个真正的设备。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69791928

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档