iOS Question Proper way to manage tokens (Firebase)

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, i managed to get firebase working, with KEY approach instead of certificates.
Now i need to send notification with topics, and tokens.

on iOS i get the token when FCM connects with:
B4X:
Sub GetToken As String
    Dim no As NativeObject
    Dim token As NativeObject = no.Initialize("FIRInstanceID").RunMethod("instanceID", Null).RunMethod("token", Null)
    If token.IsInitialized Then Return token.AsString Else Return ""
End Sub


My questions are:
Is there a proper way to mange the tokens?*
How frequently they change?
Is there a sub that fires when the token changes, or I've to check every time the app is opened?

*now i've an api to update the token of the user on my online DB, that it's called everytime the app opens up and the token is different from the preovius stored (i don't know if doing so is correct)


Thanks in advance for the suggestions
 

Mike1970

Well-Known Member
Licensed User
Longtime User
Why use tokens?
Because i need to send "personal" notifications.

E.g.
Bob have to receive the notification
Anna have not
Carl have not
etc...

Do you mean to create a topic for every user?
like:
topic_bob, topic_anna, topic_carl?
In this case, is there not a limit of topics that i can create?
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
Save it in your backend. Save the token on the device and compare it with the token you receive with GetToken, if he changes, then update it in your backend.
How frequently they change?
[/QUOTE]
Thanks for answering
that was the method I wanted to use, but actually if there is no limit to how many topics I can use, is better using topics instead of tokens that changes and do strange things, as Erel say
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…