Send a notification to all recipients (v2)
Purpose
Sends a notification to all recipients in a given application.
URL
Sandbox
https://sandbox.httpush.com/ACCOUNT_KEY/v2/application/notification.json
https://sandbox.httpush.com/ACCOUNT_KEY/v2/application/notification.xml
Production
https://production.httpush.com/ACCOUNT_KEY/v2/application/notification.json
https://production.httpush.com/ACCOUNT_KEY/v2/application/notification.xml
Find your ACCOUNT_KEY on
the dashboard at the management web site.
HTTP Method
POST
Formats
JSON, XML
Requires Authentication
Yes (about Authentication)
Parameters
Send the parameters as either JSON or XML data as the body of your request.
a: The application_hash. Provided by the management site. Identifies under which application the recipient should be created.-
b: Have a look at the documentation provided by Apple, to learn how the payload should be formated, basically it is:
{"aps":{"badge":1,"alert":"Hi from the API"}}
Usage Notes
json_body is not allowed to be larger than 256 byte.
Example JSON data
{"a": "05673b6d12c796afc0cb74849e60573949bf2521", "b": "{\"aps\":{\"badge\":1,\"alert\":\"Hi from squidshot!\"}}"}
Example XML data
<?xml version="1.0" encoding="UTF-8"?> <notification> <a>05673b6d12c796afc0cb74849e60573949bf2521</a> <b>{"aps":{"badge":1,"alert":"Hi from squidshot!"}}</b> </notification>
Responses
See return codes for all codes, here are specific ones:
400 {"error" : "error parsing the json input"}
400 {"error" : "application_hash missing in notification"}
400 {"error" : "json body is missing in notification"}
400 {"error" : "recipient missing in notification"}
400 {"error" : "recipient not found"}
400 {"error" : "application_hash not found"}
400 {"error" : "no apns token set registered for user"}
XML returns the same errors string like JSON.
<?xml version="1.0" encoding="UTF-8"?> <errors> <error>application_hash has wrong length</error> </errors>
Usage examples
cURL (about cURL)
curl -k -X POST -d '{"a": "05673b6d12c796afc0cb74849e60573949bf2521", "b": "{\"aps":{\"badge\":1,\"alert\":\"Hi from squidshot!\"}}"}' -u 'c3bb3b10864278055b3873503629904b98862895:1ab182418e3bca321dab504f96dd0339869eef0c' https://sandbox.httpush.com/ACCOUNT_KEY/v2/application/notification.json
curl -k -X POST -d '<?xml version="1.0" encoding="UTF-8"?><notification><a>05673b6d12c796afc0cb74849e60573949bf2521</a><b>{"aps":{"badge":1,"alert":"Hi from squidshot!"}}</b></notification>' -u 'c3bb3b10864278055b3873503629904b98862895:1ab182418e3bca321dab504f96dd0339869eef0c' https://sandbox.httpush.com/ACCOUNT_KEY/v2/application/notification.xml
Do you have an example to share in the language of your choice? Please share!