Yonatan Cherkos
Yonatan Cherkos

Reputation: 51

FirebaseMessaging.instance.getAPNSToken always return null

Describe the bug I have an issue on which i was not able to get APNs token on ios. the push notification works fine on android. I go through FCM apple integration steps repeated with no luck. I am stuck on this issue for weeks.

package versions and testing device

xcode configuration

I enable push notification and background mode(background fetch, remote notification, background process) capabilities in debug and release mode.

AppDelegate.swift ``` import UIKit import Flutter import Firebase

@UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { FirebaseApp.configure() GeneratedPluginRegistrant.register(with: self) if #available(iOS 10.0, *) { UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate } return 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)

• No issues found!Ï```

Thank you in advance.

Upvotes: 5

Views: 3707

Answers (1)

Shawn Lee
Shawn Lee

Reputation: 111

Check if you are using a iOS simulators: https://firebase.flutter.dev/docs/messaging/notifications

FCM via APNs does not work on iOS Simulators. To receive messages & notifications a real device is required.

Upvotes: 0

Related Questions