Skip to content
Paul Poetsma edited this page May 8, 2016 · 13 revisions

AirNotifier API V2

Devices

Each webservice request contains a "device" field. The supported values are:

  • ios
  • android
  • mpns
  • wns
  • sms

Send Notifications

POST

URL: http://localhost:8000/api/v2/push

Accept:application/json
Host:localhost:8000
X-AN-APP-NAME: moodle
X-AN-APP-KEY: XXXXXXXXXXXX

{
    "device": "ios",
    "token": "FE66489F304DC75B8D6E8200DFF8A456E8D0",
    "alert": "Hello from AirNotifier",
    "sound": "Submarine.aiff",
    "badge": 1
}

Response

HTTP/1.1 202 ACCEPTED
Content-Length: 16
Content-Type: application/json; charset=utf-8
Server: TornadoServer/2.2

Add tokens

Request

POST /api/v2/tokens
Accept:application/json
Host:localhost:8000
X-AN-APP-NAME: moodle
X-AN-APP-KEY: XXXXXXXXXXXX
{
  "device":"ios",
  "token":"id192809sdfi23uwdifj",
  "channel":"default"
}

Response

HTTP/1.1 200 OK
Content-Length: 16
X-Powered-By: AirNotifier/1.0
Content-Type: application/json; charset=utf-8
Server: TornadoServer/2.2

Delete token

Request

DELETE /api/v2/tokens/xxxxxxxxxxxxxxxxxxxxxxxx
Accept:application/json
Host:localhost:8000
X-AN-APP-NAME: moodle
X-AN-APP-KEY: XXX

Response

HTTP/1.1 200 OK
Content-Length: 16
X-Powered-By: AirNotifier/1.0
Content-Type: application/json; charset=utf-8
Server: TornadoServer/2.2

#Example using cURL All of the APIs above can be invoked using any programming language of choice. It is often very useful to quick validate if everything is working using curl

Here is an example of adding a token and sending a "Hello" message using curl:

curl -H "Content-Type: application/json" -H "X-AN-APP-NAME:test" -H "X-AN-APP-KEY:480XXXXXXXXXXXXX" -X POST -d '{"device":"ios","token":"0e39d1c9fb2ff567d606XXXXXXXXXXXXXXX", "alert":"Hello"}' https://myserver:8801/api/v2/push -k

The example above adds an iOS token to the app named 'test'. The X-AN-APP-KEY is your access token which you would have created in the UI. Note that I am using HTTPS with a self-signed certificate, hence the '-k' to curl.

Clone this wiki locally