Private Sub SendMessageToSingleDevice(Devtoken As String, MyData As String)
Dim Job As HttpJob
Job.Initialize("SendMessage", Me)
Dim m As Map = CreateMap("to": $"${Devtoken}"$)
Dim data As Map = CreateMap("data": MyData)
m.Put("data", data)
Dim jg As JSONGenerator
jg.Initialize(m)
Job.Tag=jg
Log(jg.ToString)
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
Private Sub SendMessageToTopic(Top As String, datastring As String)
Dim Job As HttpJob
Job.Initialize("SendMessage", Me)
DateTime.DateFormat="dd.MM.yyyy"
Dim DatumZeit As String
DatumZeit=DateTime.Date(DateTime.Now)
DatumZeit=DatumZeit & " " & DateTime.Time(DateTime.Now)
Dim m As Map = CreateMap("to": $"/topics/${Top}"$)
Dim noti As Map = CreateMap("body":"Notification " ,"title":"New message")
Dim data As Map = CreateMap("data": datastring)
m.Put("notification", noti)
m.Put("data", data)
m.Put("content_available": True)
Dim jg As JSONGenerator
jg.Initialize(m)
Job.Tag=jg
Log(jg.ToString)
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