react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

[🐛] Error getting token: NativeFirebaseError: [messaging/unknown] The operation couldn’t be completed. No APNS token specified before fetching FCM Token in iOS 26.0

Open nikhilsmartdata-123 opened this issue 1 year ago • 23 comments

Issue: The operation couldn’t be completed. No APNS token specified before fetching FCM Token

On iOS versions up to 18.6, it works fine, and I am able to generate the FCM token successfully. However, on iOS 26.0, this issue occurs.

I have already tried updating the following libraries to their latest versions, but it did not resolve the problem: "@react-native-firebase/app": "19.3.0", "@react-native-firebase/messaging": "19.3.0",

Could you please advise if there is any additional configuration or change required for iOS 26 to generate the FCM token correctly?


Project Files

Javascript

Click To Expand

package.json:

    "@react-native-firebase/app": "19.3.0",
    "@react-native-firebase/messaging": "19.3.0",
     "react": "19.1.0",
     "react-native": "0.80.0",
    "react-native-splash-view": "^0.0.18",

NotificationService.js:

import {useEffect} from 'react';
import messaging from '@react-native-firebase/messaging';
import notifee, {EventType} from '@notifee/react-native';
import {useDispatch} from 'react-redux';
import {fcmTokenStore} from '../redux/actions';

export default function NotificationService() {
  const dispatch = useDispatch();
  // Call notification permission
  const registerForPushNotifications = async () => {
    const authStatus = await messaging().requestPermission();
    const enabled =
      authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
      authStatus === messaging.AuthorizationStatus.PROVISIONAL;
    console.log(enabled, 'notification permission');
    if (enabled) {
      getFcmToken();
    }
  };

  const getFcmToken = async () => {
    try {
      await notifee.requestPermission();
      const token = await messaging().getToken();
      console.log('FireBase Token ====', token);
      dispatch(fcmTokenStore(token));
    } catch (error) {
      console.error('Error getting token:', error);
    }
  };

  useEffect(() => {
    registerForPushNotifications();
    messaging().onMessage(async remoteMessage => {
      const channelId = await notifee.createChannel({
        id: 'default',
        name: 'Default Channel',
        // Ensure the channel has high importance
        sound: 'default',
      });
      let id = new Date().getTime().toString();

      // Display Notification in forground state
      await notifee.displayNotification({
        title: remoteMessage.notification.title,
        body: remoteMessage.notification.body,
        name: 'Default Channel',
        id: id,
        ios: {
          // iOS resource (.wav, aiff, .caf)
          sound: 'default',
        },
        data: remoteMessage.data,
        android: {
          channelId,
          smallIcon: 'ic_notification',
        },
      });
    });

    // handle the notification when app open from background state
    messaging().onNotificationOpenedApp(remoteMessage => {
      console.log(
        '***********NOTIFICATION_OPENED_APP_FROM_BACKGROUND_STATE**********',
        remoteMessage,
      );
    });

    // Check whether an initial notification is available
    messaging()
      .getInitialNotification()
      .then(remoteMessage => {
        console.log('Initial Notification', remoteMessage);
      });

    return notifee.onForegroundEvent(({type, detail}) => {
      switch (type) {
        case EventType.DISMISSED:
          console.log('User dismissed notification', detail.notification);
          break;
        case EventType.PRESS:
          console.log('User pressed notification', detail.notification);  
          break;
      }
    });
  }, []);
}

iOS

Click To Expand

AppDelegate.swift:

import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
import Firebase

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
  var window: UIWindow?

  var reactNativeDelegate: ReactNativeDelegate?
  var reactNativeFactory: RCTReactNativeFactory?

  func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
  ) -> Bool {
    FirebaseApp.configure()
    let delegate = ReactNativeDelegate()
    let factory = RCTReactNativeFactory(delegate: delegate)
    delegate.dependencyProvider = RCTAppDependencyProvider()

    reactNativeDelegate = delegate
    reactNativeFactory = factory
    showSplashScreen()
    application.registerForRemoteNotifications()
    window = UIWindow(frame: UIScreen.main.bounds)

    factory.startReactNative(
      withModuleName: "projectName",
      in: window,
      launchOptions: launchOptions
    )

    return true
  }
  private func showSplashScreen() {
      if let splashClass = NSClassFromString("SplashView") as? NSObject.Type,
          let splashInstance = splashClass.perform(NSSelectorFromString("sharedInstance"))?.takeUnretainedValue() as? NSObject {
          splashInstance.perform(NSSelectorFromString("showSplash"))
          print("✅ Splash Screen Shown Successfully")
      } else {
          print("⚠️ SplashView module not found")
      }
    }

}

class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
  override func sourceURL(for bridge: RCTBridge) -> URL? {
    self.bundleURL()
  }

  override func bundleURL() -> URL? {
#if DEBUG
    RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
    Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
  }
}


nikhilsmartdata-123 avatar Sep 26 '25 06:09 nikhilsmartdata-123

can confirm same behaviour, works fine on iOS 18 and fails on iOS 26

tastydev avatar Sep 27 '25 00:09 tastydev

I'm experiencing the same issue. iOS 26: the 'getMessaging().requestPermission()' returns AUTHORIZED = 1', but 'getMessaging().getToken()' returns [Error: [messaging/unknown] The operation couldn’t be completed. No APNS token specified before fetching FCM Token]

dmitriyvgladkov avatar Sep 29 '25 01:09 dmitriyvgladkov

One thing to note: when I use a real device, I don't encounter any issues with iOS 26. The 'getMessaging().getToken()' function returns the actual token. Therefore, the iOS simulator is not functioning properly. I'm not sure if this qualifies as an issue, but iOS 18 worked on both the simulator and the device.

dmitriyvgladkov avatar Sep 29 '25 02:09 dmitriyvgladkov

Hey there, version specific issues like iOS 26 is not something we will be able to address here. If it works on real device at least then that is positive as you can still test it anyways. As as far I know there isn't any more version specific things to address in your local configuration, it should just work out of the box after following the usual steps. We had a similar version specific issue with one of the iOS 18.x versions on FlutterFire. It is likely a something mild that breaks it on Apples side. Therefore i will be closing this issue but please feel free to reopen if you are experiencing this issue on multiple versions as that will tell us it is something we may need to fix here.

MichaelVerdon avatar Sep 29 '25 07:09 MichaelVerdon

I have same issue in simulator with iOS 26. I don't have any real device with iOS26 to check. I agree that error with a specific version and in an emulator is not the objective of this library but I think that this will generate problems for developers who do not have access to a physical terminal and with that version. If, as my colleagues say, it does not happen physically and only happens with 26, then it is not urgent but in my humble opinion, it is something that should be in your backlog to check it when possible.

goltra avatar Sep 29 '25 10:09 goltra

Hey there, version specific issues like iOS 26 is not something we will be able to address here. If it works on real device at least then that is positive as you can still test it anyways. As as far I know there isn't any more version specific things to address in your local configuration, it should just work out of the box after following the usual steps. We had a similar version specific issue with one of the iOS 18.x versions on FlutterFire. It is likely a something mild that breaks it on Apples side. Therefore i will be closing this issue but please feel free to reopen if you are experiencing this issue on multiple versions as that will tell us it is something we may need to fix here.

Of course, but I believe it’s important to update the documentation section for iOS Messaging Setup (https://rnfirebase.io/messaging/usage/ios-setup)

dmitriyvgladkov avatar Sep 29 '25 13:09 dmitriyvgladkov

Same issue on iOS 26 (simulator), but working on iOS 18.5

"react-native": "0.79.4"
"@react-native-firebase/analytics": "23.2.2",
"@react-native-firebase/app": "23.2.2",
"@react-native-firebase/messaging": "23.2.2"

denysoleksiienko avatar Sep 29 '25 14:09 denysoleksiienko

Hey there, version specific issues like iOS 26 is not something we will be able to address here. If it works on real device at least then that is positive as you can still test it anyways. As as far I know there isn't any more version specific things to address in your local configuration, it should just work out of the box after following the usual steps. We had a similar version specific issue with one of the iOS 18.x versions on FlutterFire. It is likely a something mild that breaks it on Apples side. Therefore i will be closing this issue but please feel free to reopen if you are experiencing this issue on multiple versions as that will tell us it is something we may need to fix here.

Of course, but I believe it’s important to update the documentation section for iOS Messaging Setup (https://rnfirebase.io/messaging/usage/ios-setup)

On my side, same issue (i already followed the iOS setup),

React Native 0.81.1

iOS 18.x ✅ Work on real device ✅ Work on simulator

iOS 26 ❌ Fail on real device ❌ Fail on simulator

Tested with 23.3.1 and 23.4.0

kevinmartin33 avatar Sep 29 '25 21:09 kevinmartin33

Same issue on simulator 26 and 26.1 (beta).

So 26.1 did not fix this. Is this considered now multiple version issue and can be reopened?

dendroman avatar Oct 02 '25 10:10 dendroman

Confirm same issue with simulator 26

annx10kn avatar Oct 09 '25 09:10 annx10kn

can confirm same behaviour, works fine on iOS 18 and fails on iOS 26

olitynskyi-mtb avatar Oct 10 '25 13:10 olitynskyi-mtb

18.6 is already broken. The last simulator release where it works for me is 18.4

compojoom avatar Oct 15 '25 10:10 compojoom

Confirmed, iOS 26 simulator no longer works.

sohail-wayland avatar Oct 24 '25 09:10 sohail-wayland

any updates? same issue on iOS 26

AmirSalahY avatar Oct 28 '25 13:10 AmirSalahY

+1

Haider-Ali-7 avatar Oct 28 '25 18:10 Haider-Ali-7

Upgrade to the latest iOS SDK 26.1 beta 4, and everything works.

dmitriyvgladkov avatar Oct 28 '25 18:10 dmitriyvgladkov

Yeah unfortunately I can't convince the client with this solution 😅

Upgrade to the latest iOS SDK 26.1 beta 4, and everything works.

AmirSalahY avatar Oct 28 '25 19:10 AmirSalahY

any updates? same issue on iOS 26

Did you check this on real device? The issue occurs only with ios simulator having os version 26. On real device, it works.

nikhilsmartdata-123 avatar Oct 29 '25 05:10 nikhilsmartdata-123

I had this problem when I upgraded from Xcode 16.0 to Xcode 26 and iOS 26.0.1 simulator. I upgraded further to Xcode 26.1 RC and iOS 26.1 simulator then the problem disappeared.

PaperMonster avatar Oct 31 '25 09:10 PaperMonster

I cannot get it to work on any 26+ release. For anyone experiencing the same issue expo-notifications might serve as an alternative. You can send remote notifications using the backend SDK, and get a similar experience as with the Firebase Console.

floppydisken avatar Nov 18 '25 11:11 floppydisken