Android Question FirebaseMessaging token is longer than 50 characters

Darsiar

Member
Hello!
After long manipulations with the FCM_Show example, on the advice of Eral, we still managed to get the FirebaseMessaging object to be initialized correctly.

But now a strange error occurs when trying to send a control message from the Firenase console to the device.
The token that FirebaseMessaging generates is too long (over 120 characters), although no more than 50 characters are required.

To study the situation, so as not to annoy Erel with stupid questions, we created a control application for the Kotlin language in Android Studio. We connected it to the same project that we use in BASIC 4 Android.

There, when initialized with the same json file, a token of the correct length is generated.

We really don’t understand where to dig further?

What are the suggestions?
Dear Erel! Your Baysik is really wonderful, and it is suitable for schoolchildren and students. But its documentation is clearly not sufficient. Let's improve documentation together, no offense.
For example: where is it written about the length of the token?
B4X:
Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.
    fm.Initialize("fm")
    MyFCMToken=fm.Token   '    <------- long > 50 ??? !!!
    Log (MyFCMToken)

TOKIN:
dsGZObTUaGk:APA91bEgeKawJk5qK-hEgiOGWRVnRjFvWvJVafoVG--s3kSVdwxbxr8yydmQ2U2HA2nPLcb79caGBNu7f9xXzcT-CcuSZJVgvgvTxPbk4q11KVF7GCKtSpCY7V8gxzaaes9OxbdxavNJ



The event is not triggering at all!

B4X:
Sub fm_TokenRefresh    
    MyFCMToken=fm.Token
    Log (MyFCMToken)
End Sub
Where to dig?
 

Attachments

  • Backup manifest2020.manifest2020 2020-06-05 14.31.zip
    13.3 KB · Views: 134
Last edited:

udg

Expert
Licensed User
Longtime User
Upvote 0

Darsiar

Member
Thank UDG. It is very interesting.
But I still don’t understand how to use this with a length of 152 and more characters? The error "Error: length greater than 59 characters!" Occurs in the firebase console The question is to physically locate the device and send him a message. The IP address of the mobile device changes all the time. Therefore, only the firebase service can find it on the Web, with which the device supports synchronization at the kernel level of the Android OS. Any third-party server cannot find the physical address of the device if the push ip synchronization mechanism is not emulated there.
Therefore, if firebase swears at the length of the token, then what should I do?
What don’t I understand?
Please explain to me as for beginner.
thank
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Occurs in the firebase console
AFAIK, we shouldn't use the console to send messages. Erel gave us a B4J example to use instead.
In my case I measured a token of 152 chars but DonManfred showed that it could be upto 4096. So when a new user registers to our service, we should record both its FCM token (any length up to 4096) and a simpler uniqe ID we generate and manage (if needed by our app).
When its time to send a message to a specific device, we read its token from our DB and use the code sample written by Erel to send out our message.
If the message is of general nature, we send it to a topic subscribed by all the devices, otherwise its sent using the FCM token just for a single device.
 
Upvote 0
Top