Hi.
I wrote this post just to understand why the TokenRefresh seems not to work. For my use this is not actually a problem, as pointed out in what follows.
I tried to insert the fm_TokenRefreh event, like in the following code. My purpose is to set a variable declared in Main module: Main.Token. The log shows that:
1) During SubscribeToTopics the token is empty
2) No call to TokenRefresh (so, I ask myself what I am missing..)
3) In MessageArrived the Token exists. (This is enough, for my use, anyway)
The code:
Sub Process_Globals
Private fm As FirebaseMessaging
'Dim RefreshDataFlag As Boolean
End Sub
Sub Service_Create
fm.Initialize("fm")
Log("Messaging_Create")
End Sub
Public Sub SubscribeToTopics
fm.SubscribeToTopic("nessuno") 'you can subscribe to more topics
Log("In Subscribe " & $"Token(${fm.Token})"$)
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then Return
Log("Messaging start")
End Sub
Sub fm_TokenRefresh
Log("In Refresh " & $"Token(${fm.Token})"$)
Main.Token=fm.Token
End Sub
Sub fm_MessageArrived (Message As RemoteMessage)
Main.MessageArrived=Message.GetData.Get("message")
Main.Token=fm.Token
Log("In Arrived " & $"Token(${fm.Token})"$)
If IsPaused(Main) Then
StartActivity(Main)
CallSub(Main,"SaveData")
Else
CallSub(Main,"SaveData")
CallSub(Main, "RefreshData")
End If
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("message"),Main)
n.Notify(1)
End Sub
The Log:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Resume
resume :
resume :
** Service (firebasemessaging) Create **
Messaging_Create
** Service (firebasemessaging) Start **
Messaging start
In Subscribe Token() <<<<<<<<< here token is empty
** Service (firebasemessaging) Start **
In Arrived Token(ckjOv0zMpZc:APA91bG7rNQ3XemLfL2VmVRCn5dzB9Xf6eHKwp6A6oLIp3CtlzX_OBf9USENVyf_xjMTzeJrM6oIbT9mubv7BlDXP4pFxjn5J9Xop9FHMYgTy6OujimHO6ThwGkKPWDoVSF7-azyCFDQ)
Thanks for attention.