Fatmajk
Fatmajk

Reputation: 2009

Firebase token error TOO_MANY_REGISTRATIONS

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.

Upvotes: 58

Views: 29890

Answers (7)

user26866926
user26866926

Reputation: 1

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

Upvotes: -2

James Abuser
James Abuser

Reputation: 58

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.

Upvotes: 1

Usman Cygnet
Usman Cygnet

Reputation: 11

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.

Upvotes: 1

Manuel Garcia
Manuel Garcia

Reputation: 11

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)
        }
    }

Upvotes: 0

aprilmintacpineda
aprilmintacpineda

Reputation: 1274

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

Upvotes: 1

Elvis Aron Andrade
Elvis Aron Andrade

Reputation: 111

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.

Upvotes: 11

Fatmajk
Fatmajk

Reputation: 2009

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.

Upvotes: 65

Related Questions