Mehrzad238 Active Member Mar 23, 2020 #1 How many days takes until this SUB work B4X: Sub fm_TokenRefresh (Token As String) Log("Token is :" & Token) End Sub And sometimes gives no token, is this code works for that? B4X: If fm.Token.Length = 0 Then StopService(Me) StartServiceAt(Me,DateTime.Now + 200, False) End If Thanks everybody
How many days takes until this SUB work B4X: Sub fm_TokenRefresh (Token As String) Log("Token is :" & Token) End Sub And sometimes gives no token, is this code works for that? B4X: If fm.Token.Length = 0 Then StopService(Me) StartServiceAt(Me,DateTime.Now + 200, False) End If Thanks everybody
KZero Active Member Licensed User Longtime User Mar 23, 2020 #2 1-According to google The registration token may change when: The app deletes Instance ID The app is restored on a new device The user uninstalls/reinstall the app The user clears app data. Click to expand... so don't expect that your token will change frequently I use FirebaseMessaging service Create to get the token every time the application starts B4X: Sub Service_Create fm.Initialize("fm") fmt=fm.Token End Sub 2-where you put this code? Mehrzad238 said: B4X: If fm.Token.Length = 0 Then StopService(Me) StartServiceAt(Me,DateTime.Now + 200, False) End If Click to expand... Upvote 0
1-According to google The registration token may change when: The app deletes Instance ID The app is restored on a new device The user uninstalls/reinstall the app The user clears app data. Click to expand... so don't expect that your token will change frequently I use FirebaseMessaging service Create to get the token every time the application starts B4X: Sub Service_Create fm.Initialize("fm") fmt=fm.Token End Sub 2-where you put this code? Mehrzad238 said: B4X: If fm.Token.Length = 0 Then StopService(Me) StartServiceAt(Me,DateTime.Now + 200, False) End If Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Mar 23, 2020 #3 Why do you need the token? This is not needed in most cases. Upvote 0
Mehrzad238 Active Member Mar 23, 2020 #4 KZero said: 1-According to google so don't expect that your token will change frequently I use FirebaseMessaging service Create to get the token every time the application starts B4X: Sub Service_Create fm.Initialize("fm") fmt=fm.Token End Sub 2-where you put this code? Click to expand... Here : B4X: Sub Service_Create fm.Initialize("fm") If fm.Token.Length = 0 Then StopService(Me) StartServiceAt(Me,DateTime.Now + 200, False) End If End Sub In FirebaseMessaging Service Upvote 0
KZero said: 1-According to google so don't expect that your token will change frequently I use FirebaseMessaging service Create to get the token every time the application starts B4X: Sub Service_Create fm.Initialize("fm") fmt=fm.Token End Sub 2-where you put this code? Click to expand... Here : B4X: Sub Service_Create fm.Initialize("fm") If fm.Token.Length = 0 Then StopService(Me) StartServiceAt(Me,DateTime.Now + 200, False) End If End Sub In FirebaseMessaging Service
Mehrzad238 Active Member Mar 23, 2020 #5 Erel said: Why do you need the token? This is not needed in most cases. Click to expand... I'm developing a shopping app, and for that, I need to send a push to a user that makes shopping and not everyone Upvote 0
Erel said: Why do you need the token? This is not needed in most cases. Click to expand... I'm developing a shopping app, and for that, I need to send a push to a user that makes shopping and not everyone
KZero Active Member Licensed User Longtime User Mar 23, 2020 #6 Mehrzad238 said: Here : B4X: Sub Service_Create fm.Initialize("fm") If fm.Token.Length = 0 Then StopService(Me) StartServiceAt(Me,DateTime.Now + 200, False) End If End Sub In FirebaseMessaging Service Click to expand... why you stop the firebasemessaging service and starting it at another time?! Upvote 0
Mehrzad238 said: Here : B4X: Sub Service_Create fm.Initialize("fm") If fm.Token.Length = 0 Then StopService(Me) StartServiceAt(Me,DateTime.Now + 200, False) End If End Sub In FirebaseMessaging Service Click to expand... why you stop the firebasemessaging service and starting it at another time?!
Mehrzad238 Active Member Mar 23, 2020 #7 KZero said: why you stop the firebasemessaging service and starting it at another time?! Click to expand... This exactly: B4X: If fm.Token.Length = 0 Then and sometimes gives me nothing, no token so I think that is a solution for having token no matter what if it's wrong, so tell me the right one to know what I should do this is why I start this thread and need guidance from experts thanks, guys Upvote 0
KZero said: why you stop the firebasemessaging service and starting it at another time?! Click to expand... This exactly: B4X: If fm.Token.Length = 0 Then and sometimes gives me nothing, no token so I think that is a solution for having token no matter what if it's wrong, so tell me the right one to know what I should do this is why I start this thread and need guidance from experts thanks, guys
KMatle Expert Licensed User Longtime User Mar 23, 2020 #8 There are rare cases when you don't get a token at once. I've added a sleep(0) after fm.initialize which did the trick for me. Upvote 0
There are rare cases when you don't get a token at once. I've added a sleep(0) after fm.initialize which did the trick for me.
Mehrzad238 Active Member Mar 24, 2020 #9 KMatle said: There are rare cases when you don't get a token at once. I've added a sleep(0) after fm.initialize which did the trick for me. Click to expand... Alright I will try your way I hope this trick of yours works for me as well Upvote 0
KMatle said: There are rare cases when you don't get a token at once. I've added a sleep(0) after fm.initialize which did the trick for me. Click to expand... Alright I will try your way I hope this trick of yours works for me as well