Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't send push notifications using the server API

Im using the new Firebase platform. Am trying to get a push notification sent by my app server and delivered to my iPhone.

I have the setup working where I manually send the message with the Firebase notifications area on the website, but when I try and send the message with a POST to https://fcm.googleapis.com/fcm/send I get no message being delivered to the device.

I'm sending the following (with auth headers)

{ "notification": {
    "title": "Portugal vs. Denmark",
    "text": "5 to 1"
  },
  "to" : "<registration token>"
  }

I'm getting a 200 response from the POST with the following body:

    {
  "multicast_id": 5511974093763495964,
  "success": 1,
  "failure": 0,
  "canonical_ids": 0,
  "results": [
    {
      "message_id": "0:1463685441784359%3ad254b53ad254b5"
    }
  ]
}

If I try and send to this device directly through the Firebase website it works, but the above form post doesn't. No idea where to go from here!

like image 821
DaBeeeenster Avatar asked May 19 '16 19:05

DaBeeeenster


People also ask

How do I enable push notifications on my server?

Open your app on other browsers or devices and try subscribing them to push notifications and then clicking the Notify all button. You should receive the same notification on all of your subscribed devices (i.e. the ID in the body of the push notification should be the same).

How do I send notifications from server to client?

At a high-level, the key steps for implementing push notifications are: Adding client logic to ask the user for permission to send push notifications, and then sending client identifier information to your server for storage in a database. Adding server logic to push messages to client devices.

What is an API push notification?

Android Notification API Android apps give developers and businesses access to the operating system's large user base. Android has its own notification system and API to display app notifications for the OS. The API's syntax and logic must be followed to effectively make use of the Android notification system.


1 Answers

On iOS the priority field seems mandatory.

{   
  "to": "cHPpZ_s14EA:APA91bG56znW...",
  "priority": "high",
  "notification" : {
    "body" : "hello!",
    "title": "afruz",
    "sound": "default"
  }
} 
like image 72
emmekappa Avatar answered Sep 27 '22 22:09

emmekappa