Android Question push notification not send.

Fadi-l

Member
Hi ...

I have a problem with sending push notification from app to another one.

the first app (admin) can send message to all his clients

sending code:

B4X:
SendMessage("customer","title","text")


Sub SendMessage(Topic As String, Title As String, Body As String)
    Dim Job As HttpJob
    Job.Initialize("fcm", "")
    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;charset=UTF-8")
    Job.GetRequest.SetHeader("Authorization", "key=" & API)
End Sub


The client app

receiving code:

B4X:
Sub Service_Create
    fm.Initialize("fm")
End Sub

Public Sub SubscribeToTopics
     fm.SubscribeToTopic("customer")
End Sub

Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
    Sleep(0)
    Service.StopAutomaticForeground 'remove if not using B4A v8+.
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    Dim n As AdvancedNotification
    n.Initialize
    n.Icon = "icon"
    n.AutoCancel = True
    n.SetInfo(Application.LabelName, Message.GetData.Get("body"), Main)
    n.Notify(9)
End Sub

the message sent from first app without any errors but didn't arrive to the second one

Note:
I tried to send the message from Firebase Console , received immediately (worked just fine).

How can I fix this problem ?

Thank you ...
 

Fadi-l

Member
Thank you ...

I saw the logs on the receiver device and found that the message arrived but the AdvancedNotification not fired on android 9.

Thank you again
 
Upvote 0
Top