I have the Notifications working with this code
I have the Token of my device... how can i send a message only to this Token???
I supouse that i nett to change this line "Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)" for something like...
"Dim m As Map = CreateMap("to": $"/ID/${Token}"$)"
Anyone has the answer?
Thanks
Hi,
I have the Token of my device... how can i send a message only to this Token???
I supouse that i nett to change this line "Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)" for something like...
"Dim m As Map = CreateMap("to": $"/ID/${Token}"$)"
Anyone has the answer?
Thanks
B4X:
Private Sub SendMessage(Topic As String, Title As String, Body As String)
Dim Job As HttpJob
Job.Initialize("fcm", Me)
Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)
Dim data As Map = CreateMap("title": Title, "body": Body)
m.Put("data", data)
Dim jg As JSONGenerator
jg.Initialize(m)
Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
Job.GetRequest.SetContentType("application/json;charset=UTF-8")
Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
End Sub
Sub JobDone(job As HttpJob)
Log(job)
If job.Success Then
Log(job.GetString)
End If
job.Release
End Sub