Firebase token error TOO_MANY_REGISTRATIONS
Asked Answered
P

7

57

After reading 100's of threads and googling I am still confused about this following error message.

Currently, I am using Firebase Cloud Messaging and in very short terms I am trying to get my token from Firebase to be able to send messages to my server. I've tried with both these methods:

String token = FirebaseInstanceId.getInstance().getToken(mySenderId, "FCM");

String token = FirebaseInstanceId.getInstance().getToken();

So in the logs, I read this:

E/FirebaseInstanceId: Token retrieval failed: TOO_MANY_REGISTRATIONS
                                 java.io.IOException: TOO_MANY_REGISTRATIONS

According to other posts and answers, it's a cause of "Too many installed applications on the device that are registered with C2DM/GCM/FCM". I've also read there was a limitation of "Max 100 GCM/FCM registered applications installed on the device".

But this is not simply true, is it? I mean, it may be true but it isn't the whole answer to this issue. I am constantly working and testing with different devices and my current device DOES NOT have 100 applications registered with FCM. In fact, my device does not even have 100 applications installed at all, far from it!

Is there any way to manage previous registered devices and tokens? I've tried to run the following code without any luck:

FirebaseInstanceId.getInstance().deleteInstanceId();

I've tried to nail down information from different sources (including the documentation) without luck of understanding how this actually works. I've had the same issue with old the C2DM a while ago and also with GCM lately. I've merged with Firebase a few days ago to use its features instead which the thoughts of improvements on this, but it still echoes back at me.

Perineuritis answered 28/11, 2017 at 11:3 Comment(5)
Have you tried running on different devices or an emulator to see if all produce the same error?Demoiselle
I have been trying on different devices yes. I've had the issue on basically 2 of 4 devices I've tested on. Currently I am testing on a Nexus 6P and it works fine for the moment, no error when receiving the token. With for example Huawei P10 the error consists. Haven't tried with an emulator no. Worth adding is that it was working with my Huawei P10 before.Perineuritis
When I read your error, two problems came to mind. 1)The senderId is linked with more than 1 token. 2)(which is impossible I guess) is that the same token is linked with multiple senderIds. So could you please ensure that none of the above is true? And if you could post the code of how you're registering the client to firebase?Lockridge
Can you explain a bit more what you mean please? What do you mean that the senderId is linked to more than 1 token? The token is generated by Firebase no? So the only thing I am providing in the getToken(...) method is the senderId itself along with "FCM". But anyway the getToken() method doesn't specify anything and is also suppose to be use for token generation. If I login into Firebase console there is only 1 senderId to use.Perineuritis
I am seeing same errors in Firebase Crashlytics. Did you ever fix the issue? If yes then how? If no then, were you getting the errors all the time and you were ignoring them.Lamonicalamont
P
65

After spoken directly with the Google team I got the following answer from them:

The team confirmed and clarified their data indicated that the device is not really a normal device and this is either:

  1. a virtual device (emulator) being reused too many times

  2. a real device used in automated way to test too many apps

  3. a real device which has been customized with a CLONE image of the system partition, CLONED from a different device

If this is a real device, the best way to solve it is to factory reset to the real system image of the device. Since this device is prob currently stuck in 2 or 3, would you mind factory resetting the device and let us know if the issue still reproduce?

I have performed a factory reset on my device and the issue is gone. I still don't see exactly how this can appear and why.

Perineuritis answered 25/1, 2018 at 9:44 Comment(10)
I encountered the TOO_MANY_REGISTRATIONS error today while testing with a Firebase Test Lab device. This appears to be explained by case 2: a real device used in automated way to test too many apps .Demoiselle
Or it can be that every time you call .getToken(mySenderId, "FCM") it adds another entry and counts it as another app. So maybe find a way to remove all previous tokens.Shikari
@Shikari - are you sure this is the case? It wouldn't make sense since Google recommends the app request getId() on app startup. In my experience, FCM simply returns the same id - unless the app has been deleted and reinstalled.Quincy
@StinkyTowel No I am not sure, but then why if my app is literally the only app on my device, It spews this error onto me? What google says sometimes and what actually happens is not always the same. Then this might be a bug on the GCM service.Shikari
is there a way to prevent this from happening?Exosmosis
I have same issue. Actually happened to me twice, I don't use any robot tests, just normal app test so switch a lot between dev/prod version of the app. Factory reset is not an option :(Wyman
In my case it's coming from real users not from bots.Lamonicalamont
I agree with @Wyman it is not possible as a developer to factory reset your user's device It's not even possible.Lamonicalamont
Folks, it's a real thing. I can confirm. I faced this problem since yesterday with 3 different apps (3 different clients). It's a joke from Google. Cannot be possible they had not figured out a solution for that. The point is I use my personal cellphone to test among other devices and emulators. I'm not gonna factory reset my personal smartphone at all.Alli
I have same problem while upload the app for Apple to review and they rejected my app.Thresathresh
H
10

I suspect that these tests are from Google robots, I just published my application and in firebase authentication three logins appear with emails that appear to be fake, such as [email protected]. All emails that I suspect are robots end with a period and a number like ".39356" I'm from Brazil and I see through Analytics that the users are from the United States, only 3, so I understand that they are tests, because I haven't published my app for the United States.

Hatchett answered 16/4, 2021 at 16:4 Comment(1)
I’m seeing this issue while uploading my app to the playstore. The automatic testing (pre-launch) start and trigger this error. Yet I’m not able to reproduce locally. I only call getToken() at startup and yes it always returns the same token, unless the token get invalidated by google (very rare).Levon
S
1

I got these errors reported to firebase crashlytics for my app that is in internal testing, the weird part is it happened to 5 users which is just weird because there's only me who have access to the app. So I think it is probably Google's automated testing bots. Here's the logs

Non-fatal Exception: io.invertase.firebase.crashlytics.JavaScriptError: [messaging/unknown] java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: TOO_MANY_REGISTRATIONS
       at .getToken(address at index.android.bundle:1:905545)
       at .?anon_0_(address at index.android.bundle:1:1790016)
       at .next((native):0:0)
       at .asyncGeneratorStep(address at index.android.bundle:1:65498)
       at ._next(address at index.android.bundle:1:65769)
       at .tryCallOne(InternalBytecode.js:53:16)
       at .anonymous(InternalBytecode.js:139:27)
       at .apply((native):0:0)
       at .anonymous(address at index.android.bundle:1:191460)
       at ._callTimer(address at index.android.bundle:1:190409)
       at ._callReactNativeMicrotasksPass(address at index.android.bundle:1:190573)

Even funnier is, I was not testing the app when these crashes were reported.

Also when I open my app on real devices (low end and high end devices), I don't encounter any of these crashes being reported.

The device info is:

Device
Brand:Google
Model:sdk_goog3_x86_64
Orientation: Portrait
RAM free: 2.01 GB
Disk free: 29.95 GB

Operating System
Version:Android 13
Orientation: Portrait
Rooted:No
Syncopation answered 22/1, 2023 at 3:2 Comment(0)
S
1

For me the issue was related to lots of applications installed on a device, more than 100 apps were installed.

So, please remove some of the applications and try restarting your app, it worked for me.

Reference Link here, screenshot in case the link becomes invalid. Ref.

Spiritualism answered 25/10, 2023 at 5:52 Comment(2)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewMentality
@Mentality Thanks for the info, added screenshot for the reference link.Spiritualism
H
1

To elaborate on Usman Cygnet's answer:

Our affected test device had several apps installed that all used the same FCM key. After uninstalling a few of them, the error no longer occurs.

Hoop answered 13/2, 2024 at 10:22 Comment(0)
N
0

We've had the same issue, trusting the accepted answer, we deployed to production (fortunately to only 1% of users) and we noticed the problem also happens in real user devices. The solution that worked in my case was to extend FirebaseMessagingService and get the token overriding onNewToken(token: String)

 class PushNotifService : FirebaseMessagingService() {
       ....
       override fun onNewToken(token: String) {
           // Do whatever you need with the token (eg: sending it to the server that will send you notifications)
           super.onNewToken(token)
        }
    }
Nutting answered 15/2, 2023 at 8:26 Comment(1)
I've already got an overridden onNewToken and am encountering this errorAlephnull
A
-2

I was facing this problem just because of getting FCM token recursively. Yes, factory reset is one of the way to resolve this.

Asperse answered 18/8, 2024 at 14:5 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.