HI
I follow this tutorial and everything works.
https://www.b4x.com/android/forum/t...-messages-firebase-cloud-messaging-fcm.67716/
How to implement / call the "SendMessage" code within a UI (desktop) B4J Application ?
I do it this way, but unfortunately it does not send PUSH messages
After clicking on the button nothing happens. Any suggestions?
I follow this tutorial and everything works.
https://www.b4x.com/android/forum/t...-messages-firebase-cloud-messaging-fcm.67716/
How to implement / call the "SendMessage" code within a UI (desktop) B4J Application ?
I do it this way, but unfortunately it does not send PUSH messages
B4X:
#Region Project Attributes
#MainFormWidth: 1000
#MainFormHeight: 600
#CommandLineArgs:
#MergeLibraries: true
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private const API_KEY As String ="my key..........."
Private Button1 As Button
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1")
MainForm.Show
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)
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")
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
Sub Button1_Click
SendMessage("general","TEST","Message")
End Sub
After clicking on the button nothing happens. Any suggestions?