Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS not receiving Firebase Push Notification sent through the API

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.

like image 404
Luís Jesus Avatar asked Jul 01 '16 19:07

Luís Jesus


People also ask

Can I use Firebase for push notification to iOS?

For Apple client apps, you can receive notification and data payloads up to 4000 bytes over the Firebase Cloud Messaging APNs interface.

How do I get push notifications on iOS?

Go to Settings and tap Notifications. Select an app under Notification Style. Under Alerts, choose the alert style that you want. If you turn on Allow Notifications, choose when you want the notifications delivered — immediately or in the scheduled notification summary.


1 Answers

I managed to fix the problem thanks to this answer: https://stackoverflow.com/a/37550067/516338

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"
  }
}  
like image 190
Luís Jesus Avatar answered Oct 10 '22 23:10

Luís Jesus