B4J Question Background notifications do not work

Isac

Active Member
Licensed User
Longtime User
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:

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
 

Isac

Active Member
Licensed User
Longtime User
Thanks Erel but how can i simulate the Curl library (php) with b4j?

I did not use b4a because I used a framework for css.
I do not think that with b4a you can do it.
Then I use a server side page in php to retrieve files via ajax

For sending messages i would like to use b4j so i do not use a php web page

thanks again
 
Upvote 0
Top