Android Question Problem in firebase B4i and B4a server

Pooya1

Active Member
Licensed User
Hi
I can implement Firebase push notification in B4a and B4i successfully and there is no problem
I use below code for send notification
B4X:
    Dim Job As HttpJob
    Job.Initialize("fcm", Me)
    Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)
    Dim data As Map = CreateMap("title": "https://google.com", "body": Body , "type":"link")
    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)

This code is working for B4i and B4a
In B4a there is no problem in Background and Foreground app and my app receive message in all state
But in B4i when i go to background,my app dont receive message
I searched about receive message in background and i understood i have to use "notification" tag in data
Example :
B4X:
    Dim Job As HttpJob
    Job.Initialize("fcm", Me)
    Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)
    Dim data As Map = CreateMap("title": "https://google.com", "body": Body , "type":"link")
    m.Put("data": data)
    m.Put("notification": 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)

When i add notification tag and send push,My app (in B4i) receive message in background
But there is issue about B4a
When i use notification tag in data,In android,when i go to background,My app can receive message but it only show firebase's notification and dont raise fm_MessageArrived event
Why?
I need send message for all device (android,ios) with one code
Thanks
 

Pooya1

Active Member
Licensed User
Use the sending code from the B4i tutorial. It supports both B4A and B4i messages. The ios topics should start with ios_.
I want to send push from C#
Can i use mention sending code for send push?
Actually i need use this code in all languages that i use it
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…