If I send more than one message with b4j to b4a the messages are not queued,
but they are overwritten.
I tried to use collapse_key but I can not solve it.
but they are overwritten.
I tried to use collapse_key but I can not solve it.
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("collapse_key", "body" & Rnd(1, 1000000))
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")
Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
Log("Map"& m)
' Use Wait For
Wait For (Job) JobDone(Job As HttpJob)
Log(Job)
If Job.Success Then
Log(Job.GetString)
Else
Log($"Something went wrong: ${Job.ErrorMessage}"$)
End If
Job.Release
End Sub