I have two simple project b4j and b4a.
in b4j a use this code to send message.
in my b4a i have the same function. when i used i received no error,
and return the message id.->{"message_id":5377313106300300542}
but i did not received nothing in my b4a applicacion.
but when i use the firebase console to send a message test works.
i already check my register to the topic. but no l0ke.
victor
in b4j a use this code to send message.
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Private const API_KEY As String = "AIzaSySSSSSSSSSSSSqIa8sRdZzuQxo8"
End Sub
Sub AppStart (Args() As String)
For x = 0 To 10
SendMessage("all", "This is the title", "Hello!!!!")
Next
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)
m.Put("data": data)
Dim jg As JSONGenerator
jg.Initialize(m)
Log( jg.ToString)
Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
Job.GetRequest.SetContentType("application/json;chatset=UTF-8")
Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
Sleep(1000)
End Sub
Sub JobDone(job As HttpJob)
Log(job)
If job.Success Then
Log(job.GetString)
End If
job.Release
StopMessageLoop '<-- non ui app only
End Sub
in my b4a i have the same function. when i used i received no error,
and return the message id.->{"message_id":5377313106300300542}
but i did not received nothing in my b4a applicacion.
but when i use the firebase console to send a message test works.
i already check my register to the topic. but no l0ke.
victor