iOS Question No Firebase_Notifications while in background and through API

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Good day for everyone,

I have a strange problem here:

I create 2 apps (Android and iOS), both registered to receive notifications via Firebase Notifications.

When I send with this method:

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)
   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

working fine in Android in Foreground and Background, with no problem! Perfect

working fine in iOS in Foreground, BUT NO in background. :-(


BUT THE STRANGE THING IS: If I put the same topic or via package name in FireBase page, works, foreground and background, like this:

Screen_Shot_04-05-18_at_12.06_PM.png


and works in background:

Image1.png



So, my question is: Whats the difference to send via method (https://fcm.googleapis.com/fcm/send) and send via Firebase page (https://console.firebase.google.com/u/0/project/xxxxxxxxxxxx)



and Yes, I have all settings in app like this:
B4X:
#ProvisionFile: ProvDevelopxxxxxxx.mobileprovision
#CertificateFile: ios_development.cer   
#Entitlement: <key>aps-environment</key><string>development</string>
#PlistExtra: <key>UIBackgroundModes</key><array><string>remote-notification</string></array>

Again: The push notifications VIA firebase page is working fine, but via Method NO

Thanks
 
Last edited:

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Yes, I check every single post, but non with this problem.

Scenario #1: [OK] iOS APP is opened and I send notifications through API (https://fcm.googleapis.com/fcm/send)
Scenario #2: [NOK] iOS APP is close and I send notifications through API (https://fcm.googleapis.com/fcm/send)
Scenario #3: [OK] iOS APP is opened and I send notifications through Firebase Console (the same topic or via package name)
Scenario #4: [OK] iOS APP is close and I send notifications through Firebase Console (the same topic or via package name)

I don't understand why works via firebase console and not via api....
 
Upvote 0
Top