Hey guys
About not getting push notifications using the on-ui B4J tools
the log:
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
thanks
About not getting push notifications using the on-ui B4J tools
the log:
but I don't get the push notification.[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}
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
FirebaseNotifications - Push messages / Firebase Cloud Messaging (FCM)
Updated tutorial: https://www.b4x.com/android/forum/threads/b4x-firebase-push-notifications-2023.148715/ Clarification: The nice thing about FCM is that your app doesn't need to run in order to receive messages. The FirebaseMessaging receiver will be started by the OS when a new message...
www.b4x.com
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