Skip to content
Cai Dongsheng edited this page Nov 21, 2019 · 13 revisions

AirNotifier API V2

Devices

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

  • ios
  • fcm
  • android-fcm
  • ios-fcm
  • wns
  • sms

Authentication

Headers are used to authenticate the request. The headers are

  • X-AN-APP-NAME - The "short name" of the application you added to AirNotifier.
  • X-AN-APP-KEY - The access key you added to your application. One application can have multiple access keys each having its own set of webservice permissions. Make sure you pick the right one.

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