Android Question Firebase how to insert time_to_live and delivery_receipt_requested

tigrot

Well-Known Member
Licensed User
Longtime User
Hi everybody,
I'm using Firebase with happy results. I'd like to put a cherry on my APP and set time_to_live and delivery_receipt_requested in my request, the first is to terminate delivery action after a time and the second is to get a receipt.
Anybody succeded in that?

Regards
Mauro Zanin
Logic Data
 

tigrot

Well-Known Member
Licensed User
Longtime User
Hi Erel, the issue is that time_to_live works fine while delivery_receipt_requested is not recognised by Firebase server
B4X:
Private Sub SendMessageToSingleDevice(Devtoken As String, datastring As String)

    Dim Job As HttpJob
    Job.Initialize("SendMessage", Me)

    Dim m As Map = CreateMap("to": $"${Devtoken}"$)
    Dim noti As Map = CreateMap("body":"Notification ", "title":"New message!")
    Dim data As Map = CreateMap("data": datastring, "key": tokenstore, "tel": Starter.telefono)
    m.Put("notification", noti)
    m.Put("data", data)
    m.Put("content_available": True)
    m.Put("delivery_receipt_requested":True)
    m.Put("time_to_live":600)
    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

the log shows:
** Service (firebasemessaging) Start **
** Service (httputils2service) Create **
** Service (httputils2service) Start **


** Activity (main) Pause, UserClosed = false **
{"content_available":true,"data":{"data":"sendgps","key":"diEXJxxm2Ac:APA91bE5qbnSQO1Je8HV-l24NKBhmUdVBPraU7DdMnjRFIKa_qCLPQ3zavUJQoHWxAqUkyk5NKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","tel":"34xxxxxxxxx,39"},"to":"diEXJxxm2Ac:APA91bE5qbnSQO1Jxxxxxxxxxxxxxx-l24NKBhmUdVBPraU7DdMnjRFIKa_qCLPQ3zavUJQoHWxAqUkyk5NKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","time_to_live":600,"notification":{"body":"Notification ","title":"New message!"},"delivery_receipt_requested":true}
** Activity (gps) Create, isFirst = true **
** Activity (gps) Resume **
Invalid field "delivery_receipt_requested"
[errormessage=Bad Request, httputils2service=null, jobname=SendMessage
, password=, req=anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest@41780ed8, username=
, tag=anywheresoftware.b4a.objects.collections.JSONParser$JSONGenerator@4177e560, target=class it.whereami.logicdata.firebasemessaging, taskid=3
, success=false]
--------------------------------------------------------------------------

Red is the JSON sent, while green message and answer below is the answer from the engine.

Ciao
Mauro
 
Upvote 0
Top