Android Question Firebase Messaging Not Responding

Sofian

Member
Hi, I have problem with fm. If apps state open, fm notif show properly not problem, bu if my apps close (exit application) and I send fm push message it make my apps unable to show properly, blank screen appear if open apps.
On coding log it show (if working) :
fm2:
** Receiver (firebasemessaging) OnReceive **
** Service (firebasemessaging) Start **

and if not working it only :
fm2:
** Receiver (firebasemessaging) OnReceive **
and apps freeze with blank screen
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try it with this code:
B4X:
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)
    If Topic.StartsWith("ios_") Then
        Dim iosalert As Map =  CreateMap("title": Title, "body": Body, "sound": "default")
        m.Put("notification", iosalert)
    End If
    m.Put("priority", 10)
    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;charset=UTF-8")
    Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
End Sub

0. Make sure to run in release mode.
1. Post the logs.
 
Upvote 0
Top