APPush v0.1 documentation

This Page

Notification Resource

The purpose of the notification resource is to send notifications to iPhone devices. Notifications can be sent to one or more tags and/or device tokens.

POST

Sends a notification to one or more tags and/or device tokens. This resource returns immediately and makes a best effort to deliver the requested notification. The HTTP request content-type must be application/json.

Authentication Required

  • Root Token
  • Root Secret

URL

Parameters

  • tags - A list of tags that you want to broadcast a notification to.
  • devices - A list of device tokens to send notifications to.
  • exclude - A list of devices to exclude from the notification.
  • payload - A JSON dictionary containing an aps dictionary and arbitrary key/values. The payload cannot exceed 256 bytes. Click here for examples of acceptable payloads.
  • send_datetime - Specify the time, in Unix time (epoch), to send the notification. If not provided the notification will be sent immediately. The Epoch Converter site discusses epoch and provides examples of generating this time in several different languages.

Example JSON:

{
    "tags": [
        "foo",
        "bar",
        "baz"
    ],
    "devices": [
        "3734cc9af9376b8cba3704bccbd7c5c7f0901476d07c3247ead2b55f479fbd76"
    ],
    "exclude": [
        "1232cd9af9376b8cba3704bccbd7c5c6f0901476d07c3247ead2b44f479fbd32"
    ],
    "payload": {
        "aps": {
            "alert": "Hello World",
            "badge": 1,
            "sound": "meow.aiff"
        },
        "spam": "eggs"
    }
}

Result

  • 201 - Created. The request has been fulfilled and resulted in a new resource being created. The response will include a “Location” header which will indicate the location of the newly created notification resource.
  • 400 - Bad Request. The request could not be understood by the server due to malformed syntax.

Example:

$ curl -i -u I6ieYiJtbH3YPriyR3AK3VZtgSP:72781d3c6d508699e8f3918de6dceb25  https://appush.com/api/application/I6ieYiJtbH3YPriyR3AK3VZtgSP/notification/ \
> -d "{\"tags\":[\"foo\",\"bar\",\"baz\"],\"devices\":[\"3734cc9af9376b8cba3704bccbd7c5c7f0901476d07c3247ead2b55f479fbd76\"],\"exclude\":[\"abcdef\"],\"payload\": {\"aps\":{\"alert\": \"Hello World\",\"badge\":1,\"sound\":\"meow.aiff\"},\"spam\":\"eggs\"}}" \
>  -H "Content-Type: application/json" -X POST
HTTP/1.1 201 Created
Server: nginx/0.7.62
Date: Fri, 13 Nov 2009 07:51:33 GMT
Content-Type: application/json
Location: https://appush.com/api/application/I6ieYiJtbH3YPriyR3AK3VZtgSP/notification/P9haDs2EjJmyuYwEpxio2KPZ4SH
Connection: keep-alive
Keep-Alive: timeout=20
Content-Length: 0

GET

Returns the status of the given notification.

Authentication Required

  • Root Token
  • Root Secret

URL

Result

  • 200 - OK. The request was completed. The response body will include the original notification and a count of targeted, delivered, and failed devices.
  • 202 - Accepted. The request has been accepted, but is in progress. The response body will include the original notification and a count of targeted, delivered, and failed devices.
  • 404 - Not Found.

Example:

$ curl -ik -u I6ieYiJtbH3YPriyR3AK3VZtgSP:72781d3c6d508699e8f3918de6dceb25  https://appush.com/api/application/I6ieYiJtbH3YPriyR3AK3VZtgSP/notification/P9haDs2EjJmyuYwEpxio2KPZ4SH
HTTP/1.1 202 Accepted
Server: nginx/0.7.62
Date: Fri, 13 Nov 2009 07:55:02 GMT
Content-Type: application/json
Connection: keep-alive
Keep-Alive: timeout=20
Content-Length: 222

{"original":{"tags":["foo","bar","baz"],"devices":["3734cc9af9376b8cba3704bccbd7c5c7f0901476d07c3247ead2b55f479fbd76"],"payload":{"aps":{"alert":"Hello World","badge":1,"sound":"meow.aiff"},"spam":"eggs"}}, "targeted":10, "delivered":8, "failed":0}