Android Question Firebase Notification some problem

pazzokli

Active Member
Licensed User
Longtime User
Hi, untill Yesterday I used firebase notification to comunicate some push notification between a Server (Huawei Mediapad T3) and some smartphone as client
Today I want change my server with a Samsung Tab S2 but notification doesn't work with identical app.
What can I check?
 
Are you using the B4J project to send messages?
I'm using your code
Code: Copy
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
 
Upvote 0
You can get the result like you get it in all other httpjob requests.
Check job.Errormessage when job.success is false

You just do not check for false. Only success....

Code: Copy
Sub JobDone(job As HttpJob)
   Log(job)
   If job.Success Then
     Log(job.GetString)
   else
    log(job.errormessage)
   End If
   job.Release
End Sub
 
Upvote 0
You can get the result like you get it in all other httpjob requests.
Check job.Errormessage when job.success is false

You just do not check for false. Only success....

Code: Copy
Sub JobDone(job As HttpJob)
   Log(job)
   If job.Success Then
     Log(job.GetString)
   else
    log(job.errormessage)
   End If
   job.Release
End Sub

This evening I'll try it and I post results. Thanks a lot
 
Upvote 0
I can't debug it. New terminal send correctly notification but cnnot receive notify from smartphone.
If I use log into jobdone sub I see success because also smartphone receive same notification.

[charts=null, errormessage=, firebasemessaging=null
, gps=null, httputils2service=null, jobname=fcm
, main=null, password=, req=anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest@aac469e
, response=anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpResponse@512657f, richiamo=null, starter=null
, statemanager=null, success=true, tag=java.lang.Object@2fc194c
, target=class com.domos.client.main, taskid=16, username=
]
{"message_id":7756937179682170602}

I don't see these line in the log that I remember before:
** Receiver (firebasemessaging) OnReceive **
** Service (firebasemessaging) Start **
 
Last edited:
Upvote 0
Hi, I think I solved. I don't know why this line was commented
CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")

Probably before send app to new Tablet I put the comment. Strange mistake
Sorry for your time
 
Upvote 0
Back
Top