0

Flutter Environment

  • Flutter Version: 3.29.3 (stable)
  • Dart Version: 3.7.2
  • Xcode Version: 26.0.1
  • CocoaPods Version: 1.16.2

Firebase Packages

  • firebase_core: ^4.1.1
  • firebase_messaging: ^16.0.2

Device / OS

  • Device: iPhone 11 (Physical)
  • iOS Version: 18.6.2

I am facing an issue where the APNs token is always null when trying to retrieve it on a physical iOS device.

Future<void> getAPNSToken() async {
  try {
    debugPrint("getAPNSToken called");
    String apnsToken = await FirebaseMessaging.instance.getAPNSToken() ?? "";
    debugPrint('getAPNSToken APNS Token: $apnsToken');
  } catch (e) {
    debugPrint('getAPNSToken Error getting APNS token: $e');
  }
}

Output:

flutter: getAPNSToken called
flutter: getAPNSToken APNS Token: 

flutter: [firebase_messaging/apns-token-not-set] 
APNS token has not been set yet. Please ensure the APNS token is available by calling `getAPNSToken()`.

#0      MethodChannelFirebaseMessaging._APNSTokenCheck 
(package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:138:9)
<asynchronous suspension>
#1      MethodChannelFirebaseMessaging.getToken 
(package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:244:5)
<asynchronous suspension>
#2      FirebaseApi.initNotifications (package:ev/push_notifications/firebase_api.dart:127:24)
<asynchronous suspension>
#3      _SplashScreenState.initital (package:ev/features/splash/splash_screen.dart:93:5)
<asynchronous suspension>
3
  • This question is similar to: Flutter - APNS token has not been set yet. Please ensure the APNS token is available by calling getAPNSToken(). If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Sep 26 at 9:23
  • Notification services cannot be tested on the iOS simulator. A real device is required. Additionally, you need to enable the Apple Push Notification service to interact with the FCM, vis-a-vis generating a certificate based on your development status, and an APNS auth key that must be uploaded to the Firebase console. Note: You can easily send push notifications from the console itself, not needing to irritate your backend dev to send from the server… Commented Sep 26 at 12:23
  • 1
    @Janvi it was all working fine before update of macos26 and xcode 26 Commented Sep 27 at 7:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.