Android Question Firebase messaging token

Mehrzad238

Member
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
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.

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?

B4X:
If fm.Token.Length = 0  Then
    StopService(Me)
    StartServiceAt(Me,DateTime.Now + 200, False)
End If
 
Upvote 0

Mehrzad238

Member
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?


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

Active Member
Licensed User
Longtime User
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
why you stop the firebasemessaging service and starting it at another time?!
 
Upvote 0

Mehrzad238

Member
why you stop the firebasemessaging service and starting it at another time?!

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
Top