Android Question i still can't get HMS token

hamll

Member
for HMS server needs tokens to push message to phones, so i need to get token ,but i can't get it by this code.

B4X:
Sub Class_Globals
Private hms As HMSManager
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
    hms.Initialize
    hms.EnableLogs
    Root = Root1
    Root.LoadLayout("MainPage")

Wait For (GetToken) Complete (Token As String)
log(token)
End Sub

Public Sub GetToken As ResumableSub
  For i = 1 To 5
   Wait For (hms.GetPushToken("104***63")) complete(Token As String)
   If Token <> "" Then Return Token
   Sleep(500)
 Next
 Return ""
End Sub

I think there may has a bug in the HMS lib
 
Last edited:

hamll

Member
it dose not work, no token, but I got onNewToken in log, and the onNewToken can be used to receive push message from HMS server. but i don't know how to get onNewToken in app ,not in log
B4X:
Logger connected to:  HUAWEI TRT-AL00A
--------- beginning of crash
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Service (hmsmessagingservice) Create ***
onNewToken: 086614703************************CN01
** Service (hmsmessagingservice) Destroy **
--------- beginning of crash
Tokens:
*** Service (hmsmessagingservice) Create ***
onNewToken: 086614703************************CN01
** Service (hmsmessagingservice) Destroy **
--------- beginning of main
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…