M Mike1970 Well-Known Member Licensed User Longtime User May 25, 2021 #1 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: Copy 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
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: Copy 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
Erel B4X founder Staff member Licensed User Longtime User May 25, 2021 #2 Why use tokens? Subscribe to a unique topics instead. Simpler and with less surprises. Upvote 0
M Mike1970 Well-Known Member Licensed User Longtime User May 25, 2021 #3 Erel said: Why use tokens? Click to expand... 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
Erel said: Why use tokens? Click to expand... 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?
Erel B4X founder Staff member Licensed User Longtime User May 26, 2021 #4 Mike1970 said: Do you mean to create a topic for every user? Click to expand... Yes. Mike1970 said: In this case, is there not a limit of topics that i can create? Click to expand... No. Upvote 0
Mike1970 said: Do you mean to create a topic for every user? Click to expand... Yes. Mike1970 said: In this case, is there not a limit of topics that i can create? Click to expand... No.
Alexander Stolte Expert Licensed User Longtime User May 26, 2021 #5 Mike1970 said: Is there a proper way to mange the tokens?* Click to expand... 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] Get started with Firebase Cloud Messaging in Android apps Learn how to get started with Firebase Cloud Messaging in your Android app. firebase.google.com Upvote 0
Mike1970 said: Is there a proper way to mange the tokens?* Click to expand... 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] Get started with Firebase Cloud Messaging in Android apps Learn how to get started with Firebase Cloud Messaging in your Android app. firebase.google.com
M Mike1970 Well-Known Member Licensed User Longtime User May 26, 2021 #6 Alexander Stolte said: 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? Click to expand... Get started with Firebase Cloud Messaging in Android apps Learn how to get started with Firebase Cloud Messaging in your Android app. firebase.google.com [/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
Alexander Stolte said: 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? Click to expand... Get started with Firebase Cloud Messaging in Android apps Learn how to get started with Firebase Cloud Messaging in your Android app. firebase.google.com [/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