Hi to all.
is it a way to retrieve the registration token, namely something calling the
FirebaseInstanceID.getToken().
??
Thanks
is it a way to retrieve the registration token, namely something calling the
FirebaseInstanceID.getToken().
??
Thanks
Public Sub SubscribeToTopics
fm.SubscribeToTopic("general") 'you can subscribe to more topics
Log($"Token(${fm.Token})"$)
End Sub
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
Sub Service_Create
fm.Initialize("fm")
UpdateFCMToken 'directly after fm.initialize
Log (fm.Token)
End Sub
Public Sub UpdateFCMToken
fm.SubscribeToTopic("general") 'you can subscribe to more topics
End Sub
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.
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
End Sub
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.
'CallSub(FirebaseMessaging, "SubscribeToTopics") ' seems not useful
StartService(FirebaseMessaging) ' put this
End Sub
Sub Service_Create
fm.Initialize("fm")
Log("Messaging_Create")
SubscribeToTopics
End Sub
Public Sub SubscribeToTopics
fm.SubscribeToTopic("nessuno") 'you can subscribe to more topics
Log("In Subscribe " & $"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)
CallSubDelayed(Main,"SaveData")
Else
CallSubDelayed(Main,"SaveData")
CallSubDelayed(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 confirms the above schema,showing obviously same token during Subscription and Message arrival
probably trivial for you