Android Question (Solved) not getting push notifications

f0raster0

Well-Known Member
Licensed User
Longtime User
Hey guys

About not getting push notifications using the on-ui B4J tools

the log:
[jobname=fcm, success=true, username=
, password=, errormessage=, target=class b4j.example.main
, taskid=1, req=anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest@23282c25, response=anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpResponse@7920ba90
, tag=java.lang.Object@6b419da, main=null, httputils2service=null
]
{"message_id":5844806630749632972}
but I don't get the push notification.

If I try from the firebase console it works as normal, I got the push notifications almost immediately.

Question, can any one tell me if the on-ui B4J tool is still used for send push notifications?
I downloaded again the on-ui B4J using b4J 9.10

the code from

B4X:
'Non-UI application (console / server application)
#Region  Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    Private const API_KEY As String = "A............................"
End Sub

Sub AppStart (Args() As String)
    SendMessage("general", "title", "body")
    StartMessageLoop
End Sub

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


Sub JobDone(job As HttpJob)
   Log(job)
   If job.Success Then
     Log(job.GetString)
   End If
   job.Release
   ExitApplication '!
End Sub

thanks
 

f0raster0

Well-Known Member
Licensed User
Longtime User
Thanks. Will do more tests

My app get the push notifications if I send them from firebase console.

In the pass I used the b4j-tool to test the push but now my app don't get the push if i use the b4j-tool..
 
Last edited:
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
Firebase console will not work properly when the app is in the background.
Sorry don't understand.
B4j-tools seem not sending the push or the app not getting them.

But my app get the push notifications if I use the firebase console.

Edit: will do more tests first :)
Edit2: Working now (don't know why didn't work)
 
Last edited:
Upvote 0
Top