iOS not receiving Firebase Push Notification sent through the API
Asked Answered
P

1

10

I'm using Google's Firebase Cloud Messaging to send push-notifications to my iOS and Android applications. The push-notifications sent through the Cloud Messaging console work just as intended, however when I send a push-notification through the API, the iOS application only receives it when in foreground. On Android, it is working correctly (both in foreground and background).

Reading the documentation, the iOS system would then transfer the "notification" object to the system tray, as intended, showing the "body" message. However, this is not working.

Here's the content of the JSON I'm sending:

{
    "notification":
        {
            "body": "This a test notification"
        },
        "to":"eQ5tiy0cMZ8:APA91bE4CCjDXEJxEIRxKY18pXMMGUBqY1OKJFhVbR-pNhvQjJuhPcc7pXa..."
}

Did anyone have similar problems using Firebase Cloud Messaging recently? Thank you.

Plunge answered 1/7, 2016 at 19:30 Comment(3)
I've been dealing with the same issue lately, pretty sure it used to work before.Grandmamma
Do you know when it started to happen? Did you manage to find any solutions? ThanksBellarmine
I actually found out that the productions notifications seem to work fine but sandbox notifications don't seem to be delivered.Grandmamma
P
25

I managed to fix the problem thanks to this answer: https://mcmap.net/q/1118062/-can-39-t-send-push-notifications-using-the-server-api

Basically, although NOT in the documents, you have to set the "priority" field to "high" on iOS, like this:

{   
  "to": "cHPpZ_s14EA:APA91bG56znW...",
  "priority": "high",
  "notification" : {
    "body" : "hello!",
    "title": "afruz",
    "sound": "default"
  }
}  
Plunge answered 2/7, 2016 at 9:45 Comment(3)
I want to test static notification.how can i test using fcmid?and where can i find fcmid?Loydloydie
@ Krutarth Patel, let refreshedToken = FIRInstanceID.instanceID().token() at didRegisterForRemoteNotificationsWithDeviceTokenJocasta
I was getting a success on the send but never received the message on my device. The docs mention having the "to" after the notification dictionary and changing it to this structure solved my problem. I also noticed not including a title made it stop working. It at least had to be blank.Surbase

© 2022 - 2024 — McMap. All rights reserved.