Android Question Multi SubscribeToTopic

Ebic

Member
Licensed User
Longtime User
Hi,
in a multi Subcription of Firebase notify topic,
when i recive a notify , can i know who is the topic from ?
i don't find resolution.
advance thanks
 

DonManfred

Expert
Licensed User
Longtime User
when i recive a notify , can i know who is the topic from ?
No. You could send additional infos in the payload when sending the Notification. Add a field and put the topic used here.

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, "topic": Topic) ' Add the Topic to the data Map too
    If Topic.StartsWith("ios_") Then
        Dim iosalert As Map =  CreateMap("title": Title, "body": Body, "sound": "default")
        m.Put("notification", iosalert)
        m.Put("priority", 10)
    End If
    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
 
Last edited:
Upvote 0
Top