why can not I see the notification when i put my application in the background?
If I use the Firebase console, the application also works when I insert it in the background or close it.
this is the code:
If I use the Firebase console, the application also works when I insert it in the background or close it.
this is the code:
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Private const API_KEY As String = "KJJKJKJKJKJKJKKJJHHJ"
End Sub
Sub AppStart (Args() As String)
SendMessage("all","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)
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
StopMessageLoop '<-- non ui app only
End Sub