Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter FCM iOS Issue - APNS device token not set before retrieving FCM Token

I am using firebase_messaging v9.0.1 in my Flutter application. On configuring this library based on the https://pub.dev/packages/firebase_messaging/example, I am able to receive the notification for android in both foreground and background states. But the same for iOS is not working. I am getting the below error,

APNS device token not set before retrieving FCM Token for Sender ID ''. 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.

My iOS device is connected to internet and there were no network related issues while running this.

Do I want to call any other function apart from FirebaseMessaging.instance.getToken() for iOS? Please help.

Thanks.

like image 363
Karthikeyan P Avatar asked Apr 01 '21 05:04

Karthikeyan P


People also ask

Does FCM token change iOS?

Instead, you should expect that the device token can change at any time. Because your app might unexpectedly get a new token, you should record that token for the user every time your app launches.

What is FCM token in iOS?

By default, the FCM SDK generates a registration token for the client app instance on app launch. Similar to the APNs device token, this token allows you to send targeted notifications to any particular instance of your app.

Is the APNS device token not set before retrieve FCM token?

" APNS device token not set before retrieving FCM Token for Sender ID 'XXXXXXXXXXXXX'. 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."

Why can't flutter generate debug token for Firebase Storage with app check?

Flutter - apns device token not set before retrieving fcm token Can not generate a debug token for Firebase Storage with App Check Your bucket has not been set up properly for Firebase Storage a release for internal test in google play not retrieving or uploading any data from/to firebase

What is the FCM SDK registration token?

By default, the FCM SDK generates a registration token for the client app instance on app launch. Similar to the APNs device token, this token allows you to send targeted notifications to any particular instance of your app.

How to listen to FCM refresh events with apnstoken?

APNSToken = deviceToken; After the FCM registration token is generated, you can access it and listen for refresh events using the same methods as with swizzling enabled. When an FCM registration token is generated, the library uploads the identifier and configuration data to Firebase.


2 Answers

I had the same problem, I went step by step again with firebase documentation and realize that the push notification capability was missing on debug and release modes.

Steps to solve the issue:

  1. Go to xcode
  2. Select runner
  3. Signing & Capabilities
  4. Check debug and release capabilities you need to have background modes and push notification

push notification capability

https://firebase.flutter.dev/docs/messaging/apple-integration

like image 124
George Hoss Avatar answered Nov 05 '22 00:11

George Hoss


The way I solve this issue, instead of running the application thru debug mode, I archive the app and download it thru ad hoc and somehow this solves the issue

like image 35
Ezra Avatar answered Nov 05 '22 01:11

Ezra