Firebase Fcm Error: 'invalidregistration'
Solution 1:
In my case, I was sending notifications to topic ("topics/my-topic
"). I was missing prepending /
in the starting of topic so I was getting the same issue. SO topic should be /topics/my-topic
.
May be this helps!!
Solution 2:
There is an easier way to send a message to a device group from a Cloud Function. Use admin.messaging().sendToDeviceGroup(). Sample code and instructions are in this guide.
I think your current method is failing because there is something wrong with the group notification key provided in groupId
. It should be the string key value that was returned when you created the device group. The error codes are listed in this table. For 200/InvalidRegistration it says:
Check the format of the registration token you pass to the server. Make sure it matches the registration token the client app receives from registering with Firebase Notifications. Do not truncate or add additional characters.
Solution 3:
A registration token is tied to a certain group of senders. When a client app registers for FCM, it must specify which senders are allowed to send messages. You should use one of those sender IDs when sending messages to the client app.
Al you need to do is add a http header 'project_id' with your sender id.
Solution 4:
I was getting InvalidRegistration
:
Basic meaning: you are using the wrong token. Why? This may happen when you a new registrationToken
is given to you in onNewToken
(docs), but for some reason you are using the old token. That could happen when:
You're using a different push notification library which remembers token (stores it somewhere locally) and you didn't update that library with the new token.
Your application (or other library dependencies) implements another
FirebaseMessagingService
, and they conflict. Only one service can accept (react to) to the action sent by the FirebaseMessaging Android library's when a new token is given to it. You can double check this by opening theAndroidManifest.xml
in Android Studio and selecting theMerged Manifest
tab at the bottom of the tab. You can also place debuggers in each Service from each library you use. You'll see that only one service'sonNewToken
gets called.When they conflict, one doesn't get the correct token, and the FCM registration token that gets registered would be wrong. Sending a message to a wrong registration, gets you
InvalidRegistration
.
Solution 5:
InvalidRegistration
simply means that the token is either invalid or expired. You can uninstall the app and then reinstall and get a new token and then try with that token. This will definitely solve your problem.
You can read more here.
Post a Comment for "Firebase Fcm Error: 'invalidregistration'"