Authenticate user and send notifications with Firebase

1

I am working with a webservice rest in java in which the users access the data of a base de datos mysql , the authentication was done with JWT .

Then, looking for how to send the notifications I stumbled upon Firebase and I see that I can implement the authentication, but the question that arises is that taking into account that when sending the token in the way that it did at the beginning I did not store it in my base de datos but I did it in the device in your preferences.

Now to send you the use notification Firebase , you would have to store the token that I send you to associate it with the user and thus be able to send you the notificaciones that you want (I send them when there is a change in the database) or Can I, based on username and password, "consult" at Firebase what token did he give to identify which user he is and thus send him his notification?

    
asked by Matias Blanco 23.08.2016 в 00:42
source

1 answer

0
  

Now to send you the Firebase notification, you would have to   store the token that I send to associate it with the user and thus be able to   send you the notifications you want

Yes, if you need to send individual notifications you should register the FCM token in your BD with the user. Keep in mind that these tokens are automatically renewed when they expire and they vary if the user enters different devices (you should use FCM groups or topics to group them).

  

or I can, based on username and password, "ask" Firebase what   token gave it to be able to identify which user is

This is not possible because unless you duplicate the auth logic you should not have a Firebase username and password, but only the UID that the user is assigned by firebase. Unfortunately, currently, firebase does not allow (neither by API nor console) to send notifications by UID :(.

    
answered by 14.09.2016 / 20:18
source