Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - APNS token has not been set yet. Please ensure the APNS token is available by calling getAPNSToken()

While calling the subscribeToTopic method in iOS, this APNS token exception is coming. I have followed the documentation. I have used the Flutterfire configure command for configuring the Flutter project.

But this error is coming. Anyone know why this error is coming and how to resolve it?

I haven't called the getAPNSToken() method in the code.

Is it needed to initiate this method before calling subscribeToTopic method?

Note: We are not using tokens to send notifications to particular users. We are using the topic to send notifications. So I'm not calling the getToken and getAPNSToken methods.

1970-01-02 04:49:38.216263+0300 Runner[675:161670] flutter: [firebase_messaging/apns-token-not-set] APNS token has not been set yet. Please ensure the APNS token is available by calling `getAPNSToken()`.
1970-01-02 04:49:38.216725+0300 Runner[675:161670] flutter: #0      MethodChannelFirebaseMessaging._APNSTokenCheck (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:138:9)
<asynchronous suspension>
#1      MethodChannelFirebaseMessaging.subscribeToTopic (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:390:5)
<asynchronous suspension>
#2      PushNotificationService.subscribeUserToFirebase (package:team/src/common/notification/firebase/push_notification.dart:70:7)
<asynchronous suspension>
#3      userAPI (package:team/src/features/master_data/application/master_data_providers.dart:116:5)
<asynchronous suspension>
#4      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:337:9)
<asynchronous suspension>
like image 630
MSARKrish Avatar asked Sep 02 '25 18:09

MSARKrish


1 Answers

Did you add Capabilities: BackgroundModes and PushNotifications?

enter image description here

like image 54
samad shukr Avatar answered Sep 04 '25 06:09

samad shukr