Push-API

Click-AP provides a RESTful API for communicating with PushTW clients. The following describes the API.

Web service URL:

https://your-pushtw-server/api/v2

 

Tokens

Add device token

Web service URL:

https://your-pushtw-server/api/v2/tokens

Headers:

Accept:application/json

Host:localhost:8000

X-AN-APP-NAME: moodltw

X-AN-APP-KEY: 56cb5fcec97496c3a296533fa069a5f3

JSON contents:

{

  "device":"ios-fcm",

  "token":"faHw_kNaU:APA91bEr0BSXaSENxYXpvzyDqinLCSazrXQURSue7GGZpp45xfgpw1JmFnid192809sdfi23uwdifj",

  "channel":"default"

}

 key 的說明:


Response:

HTTP/1.1 200 OK

Send Nofificatios

Send Notifications 推播訊息

Web service URL:

https://your-pushtw-server/api/v2/push

Headers:

Accept:application/json

Host:localhost:8000

X-AN-APP-NAME: moodltw

X-AN-APP-KEY: 56cb5fcec97496c3a296533fa069a5f3

JSON contents:

{

  "device":"ios-fcm",

  "token":"faHw_kNaU:APA91bEr0BSXaSENxYXpvzyDqinLCSazrXQURSue7GGZpp45xfgpw1JmFnid192809sdfi23uwdifj",

  "alert": "Hello from Moodle-TW",

  "sound":"Submaring.aiff",

  "badge": 1

}

 key 的說明:


Response:

HTTP/1.1 202 ACCEPTED

Delete Tokens

Remove device token

Web service URL:

https://your-pushtw-server/api/v2/tokens

Headers:

DELETE /api/v2/tokens/faHw_kNaU:APA91bEr0BSXaSENxY.............XpvzyDqinLCSazrXQURSue7GGZp809sdfi23uwdifj

Accept:application/json

Host:localhost:8000

X-AN-APP-NAME: moodltw

X-AN-APP-KEY: 56cb5fcec97496c3a296533fa069a5f3

Response:

HTTP/1.1 200 OK