I can not recall the sub from a Button
somebody can give me a hand
How can I pass the function variables?
somebody can give me a hand
How can I pass the function variables?
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private Button1 As Button
Private const API_KEY As String = "AAAAVe.............................
End Sub
Sub AppStart (Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
SendMessage("all","test", "test!!!!")
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("idnews":1)
Dim notification 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)
Log(m)
Log(data)
End Sub
Sub JobDone(job As HttpJob)
Log(job)
If job.Success Then
Log(job.GetString)
End If
job.Release
End Sub
Sub Button1_MouseClicked (EventData As MouseEvent)
SendMessage(Topic,Title,Body)
End Sub