My app need instant receive the notification when server sent out the messages, how can I do that?
My app already add the gps location method to not let system kill my app, but sometimes devices sleep too long, devices can't receive the message.
server side send notification code:
I refer the link from firebase website https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages and https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidmessagepriority
How to add the ttl, notification_priority and AndroidMessagePriority to server send notification code?
Thank you.
My app already add the gps location method to not let system kill my app, but sometimes devices sleep too long, devices can't receive the message.
server side send notification code:
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)
If Topic.StartsWith("ios_") Then
Dim iosalert As Map = CreateMap("title": Title, "body": Body, "sound": "default")
m.Put("notification", iosalert)
m.Put("priority", 10)
End If
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
I refer the link from firebase website https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages and https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidmessagepriority
How to add the ttl, notification_priority and AndroidMessagePriority to server send notification code?
Thank you.