B4J Question B4J Failed SendMessage to FCM (Firebase Cloud Messaging)

rad

Member
Licensed User
Longtime User
Hi...all B4X Lovers...
Can anyone help me please...

I'm B4A user, I have try to implement B4A Lirary from Erel "FirebaseNotifications - Push messages / Firebase Cloud Messaging (FCM)" (https://www.b4x.com/android/forum/t...-messages-firebase-cloud-messaging-fcm.67716/) with successful, although sending notification from firebase console sometimes getting null value...

On that thread, Erel attach sample application develop with B4A to sendMessage to Firebase Server.
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)
   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

I have try those script in B4A, but I have nothing notification return.

And then, Erel suggest me to try sendMessage using B4J, which is attached on that thread too.
But when I try, i'm facing this situation and have no idea to solve this...

b4j.jpg
 
Top