Sign In Register

How can we help you today?

Start a new topic

FCM token is not registered.


Push notifications don't work because the 
FCM token (taken from the GS database) is not registered in Firebase's portal.

They do work for a short period of time after the first installation. Then they stop working.


This is my code (Unity):


image

NOTE: I register it only the first time the user opens the app. Should I keep registering it every other time?


 Hi Andrea


Are you getting errors when trying to send a firebase notification?

Yes you are right a token only needs to be sent to GameSparks once.


Regards

Katie

Yes I do get errors from the Firebase console.
From GameSparks or Unity everything seems to be ok.

I've checked the Firebase token I receive at start it's different from the one stored in the GS database. It seems that Firebase, as well as Apple, changes the token sometimes in some cases. So I think I have to register again, right?

My solution is to save the token locally and check anytime the user opens the app if the token is the same as the previous one, if not send a registration to GS and save the new token. Is this a good solution? Or can I just register anytime the app starts? What if the token is already registered? Does it replace the one in GS's database or does it create a new entry for the same token?

Hi Andrea

A new firebase token is given on every fresh install of  a game on device.
Are you testing by uninstalling  and reinstalling the app?
It is recommended to send gamesparks the token every time OnTokenReceived is called(on fresh install)

Regards
Katie



 

Sometimes it happens that I have to reinstall the app when testing, however if I do reinstall the app then the push registration is sent again and a new token is saved in the database. So reinstalling the app is not a problem. Indeed it temporarily resolve the problem.


It happens, somehow, that Firebase or Apple emit a new token for the same user. Maybe when an update occurs but I am not sure. So then the token saved in the GS database is not valid anymore.

I will keep you updated for new details.

Hi Andrea

This isn't a problem we have run in to before, the tokens are meant to be long lasting.
I will investigate this issue to see if anything has changed regarding push tokens.
Are you using Unity and what versions of Unity?

Regards
Katie


 

Hi Andrea


After doing some digging It appears Firebase has changed the rules regarding token expiration.

I am looking into the best solution to deal with this change at the moment.


I will post my solution here as soon as I can.


Regards

Katie


Hi Katie,

Any updates regarding this issue?

Thanks
Mohamed

I am facing the same problem. For some players push notifications are working and for some they are not. When to send the push registration request from the device. Any updates?

Hi all


Very sorry for the late reply,

When using the Unity Firebase SDK OnTokenReceived will be automatically trigger on a fresh install of the game.

I would recommend creating an event that checks if the player has a push id using Spark.getPlayer().getPushRegistrations();

If the player doesn't have a push id then call the PushRegistrationRequest.

If a push is not working correctly you can remove it by using Spark.getPlayer().removePushRegistration(id) and replace it by sending a PushRegistrationRequest.


Regards

Katie


Login to post a comment