firebase_messaging/unknown: An unknown error has occured on Flutter IOS
Asked Answered
S

9

8

Everything was working fine before but now firebase can't seem to create a new token. I'm trying to call await FirebaseMessaging.instance.getToken(); but getting this error


FLTFirebaseMessaging: An error occurred while calling method Messaging#getToken, errorOrNil => {
    NSLocalizedFailureReason = "Too many server requests.";
}
[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: [firebase_messaging/unknown] An unknown error has occurred.
#0      MethodChannelFirebaseMessaging.getToken (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:226:7)
<asynchronous suspension>
#1      _SignUpState._sendVerificationCode (package:shuri_parent/src/pages/sign_up.dart:343:25)
<asynchronous suspension>
#2      _SignUpState.build.<anonymous closure> (package:shuri_parent/src/pages/sign_up.dart:252:43)
<asynchronous suspension>

I'm using firebase_messaging: : ^10.0.9

My application is broken in production, I really need your help guys.

This is my flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 2.3.0-17.0.pre.121, on Mac OS X 10.15.7 19H1419
    darwin-x64, locale en-RW)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.61.0)
[✓] Connected device (2 available)

• No issues found!

Also my app is just recently deployed and doesn't have more than 10 users, other can't seem to use the app due to this blocker. Your help will be much appreciated.

Stutsman answered 27/10, 2021 at 8:54 Comment(0)
S
6

Oh! my bad, I found the issue. My issue was a wrong api key of firebase in the GoogleServices-info.plist file

Thanks for all the support you gave me.

Stutsman answered 28/10, 2021 at 12:39 Comment(0)
B
5

This issue is caused by limited permission to your api key from Google cloud console, here are steps that fixed my issue,

  1. Login to Google cloud console and select your current project

  2. Select **API Credentials - APIs & Services ** or IAM Permissions on left sidebar.

  3. Select iOS key(auto created by firebase)'s menu on right if you have selected **API Credentials - APIs & Services **

  4. Select Edit API key

  5. Under Selected APIs: dropdown menu select these options, Firebase Installation API Firebase Cloud Messaging API FCM Registration API

enter image description here

Bakke answered 29/4, 2023 at 9:38 Comment(0)
I
4

I resolved this issue by redownloading the GoogleService-Info.plist from the firebase & replace the current file.

Immunize answered 17/1, 2023 at 11:14 Comment(3)
Doesn't works for me :(Overscrupulous
this will work .Panties
In Firebase, go to Project (iOS) -> click gear icon -> Apple apps -> click download of GoogleService-Info.plistThrombokinase
A
3

in my case I have different bundle identifier on Xcode and in Firebase Console.

I have this issue after implementing Flavor on Flutter app. the Bundle Identifier is created dynamically based on the scheme on my Xcode

Aeolipile answered 27/4, 2022 at 8:54 Comment(0)
S
1

make sure you add push notification config in xcodeenter image description here

Shirting answered 11/6, 2023 at 9:27 Comment(0)
C
0

Make sure that your Flutter app targets iOS 8 or later. Please check this link below

https://firebase.google.com/docs/flutter/setup?platform=ios

in some android and ios devices not receiving firbase base responce because of its versions and api level

Clubbable answered 27/10, 2021 at 10:48 Comment(1)
Yes it has target IOS 10.0, Befor It was working fine in production until it started showing that error only on getToken() on users mobile phones.Stutsman
B
0

In my case, i was using a different bundle id in debug and profile, and the key under APIs & Services => Credentials => iOS key (could be 2 keys, auto created by Firebase and auto created by Google Service) was set to iOS app restriction using the release bundle id, so, you need to add your debug bundle id here in the restrictions.

enter image description here

enter image description here enter image description here enter image description here

Barbbarba answered 11/3 at 22:55 Comment(0)
R
0

I have already faced this problem and searched a lot but did not find a solution.. But when I changed the emulator the problem was solved

Change the emulator

Rhizocarpous answered 8/8 at 7:8 Comment(0)
P
-1

Turn out the error throw because I'm using a vpn app. Try to change your network to a different network then try again

Paleface answered 28/9, 2022 at 14:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.