Android Question Firebase push messages

Andie

Member
Licensed User
Longtime User
Hi,
the FCM works pretty good. But there is one little problem, I can't get rid of:

When a user opens my app including the FCM features for the very first time, the string variable token_id contains no value:
B4X:
token_id  =  fm.Token
However, when the users closes the app completely so it's longer in the background and starts it again, then the variable token_id contains the token string.

When the user deinstalls the app, this starts all over again, i. e. the first time, you start the app, no token is stored in token_id, you must start it a second time. From that I conclude, it's not problem of Firebase.
 

KMatle

Expert
Licensed User
Longtime User
Please show the code part where you get the token. Must be AFTER you subscribe to a topic (even if you don't use any). If you're getting it too early, it explains why your app seems to get it at the 2nd start (because it was after the subscription anyway)
 
Upvote 0

Andie

Member
Licensed User
Longtime User
Hi KMatle,
indeed, I did subscribe for a topic although not needing it. Due to your advice I inserted a sleep command now, and ... it works:
B4X:
    fm.SubscribeToTopic("dummyTopic")   
    Sleep(1000)
    token_id = fm.Token
Thanks a lot!
 
Upvote 0
Top