'Unable to get firebase messaging token. [Error: [messaging/unknown]. Too many server requests.] - React Native IOS

Im implementing Firebase Cloud Messaging notification for my React Native app. For Android, the notification works great, however, for the ios, I faced an error of unable to get the token, too many server request. Here is my snippet of code for getting FCM token + request user's notification permission

const getFcmToken = async () => {
  let fcmToken = await AsyncStorage.getItem("fcmToken");

  console.log("fcmToken", fcmToken);

  if (!fcmToken) {
    try {
      fcmToken = await messaging().getToken();
      if (fcmToken) {
        // user has a device token
        await AsyncStorage.setItem("fcmToken", fcmToken);
      }
    } catch (err) {
      console.log("Unable to get messaging token.", err);
    }
  }
};
export async function requestUserPermission() {
  const authStatus = await messaging().requestPermission();
  const enabled =
    authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
    authStatus === messaging.AuthorizationStatus.PROVISIONAL;

  if (enabled) {
    getFcmToken();
  } else {
    console.log("not enabled");
  }
}

When opening the app, the notification permission work fine, just the get FCM Token failed. Please help me with this issues.



Solution 1:[1]

I faced a similar issue where my app successfully retrieved FCM tokens for Android devices, whereas iOS responded with a Too many server requests error.

I solved it by re-downloading the GoogleService-Info.plist file from the Firebase Console for the iOS app.

I am not sure why, but it seemed my API key had been blocked or was invalid. After re-downloading the GoogleService-Info.plist file, the API key was updated and everything started working again.

The steps for adding the GoogleService-Info.plist to your React Native project can be found in the Getting Started part of the React Native Firebase Docs where you set up your iOS credentials.

Hope this helps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 benjaminekeloef