Cobub Razor
Cobub Toaster
Other Links
Cobub Razor
Cobub Toaster
Other Links
這是本文檔舊的修訂版!
The document introduces usage of PNS Web interface.
Here are the concepts of user channel and tag channel, which must be clarified:
Developers need to POST data to Web interface, and the Web interface will return result in JSON.
If the following is configured in the file of toaster.conf:
[web] bind localhost:8080
Then you can call Web Interface using the following Linux command, or call it by programming of HTTP:
curl –X POST –d POST_DATA http://localhost:8080/METHOD_NAME
inside
POST_DATA is POST data to PNS METHOD_NAME is the method name to be called
METHOD_NAME: pub
POST_DATA:
"expired": "1403521931", "appid": "XXX", "channel": "xxx@qq.com", "channel": "xxx@gmail.com", "data": "hello world"
If you are using the embedded presentation template in SDK, for the Notification Bar of Android, you need to use format data in POST method, refer to the JSON string as following:
{ "type":"notification", //notification bar type "style":"1", //notification bar style number "config":{ "icondata":"XXXXXXX", //icon file data with BASE64 encoding "vibrate":"1", //whether to vibrate when receive the message: 1 vibrating, 0 no vibrating "sound":"1", //whether to play sound: 1 sound, 0 no sound "title":"XXXXXX", //notification bar title "ticker":"XXXXXXX", //the rolling information "body":"XXXXXXX", //notification content "clickconfig":{ //define the behavior after user clicks the notification bar, please refer to the examples below "operation":"launchActivity", "package":"com.wbkit.icclient", "targetActivity":"com.wbkit.icclient.MainActivity" } } }
clickconfig Example 1: open APP (Activity)
{ “operation”:“l(fā)aunchActivity”, //operation type: open Activity “package” : “com.example.demo” //APK package name “targetActivity”: “com.example.demo.MainActivity” //Activity }
clickconfig Example 2: download APK and install
{ “operation”:“download”, //operation type: download APK “appname”: “fishing” //APP name “dlurl”: “http://xxxxxx.apk” //APK url //PS: popup installation guide of Android automatically after downloading }
clickconfig Example 3: open a web page
{ “operation”:“l(fā)oadWebpage”, //operation type: open a web page //PS: if both url and page are provided, the SDK will use url “url”: “http://www.baidu.com”, //url “page”: “.....” //content of page }
Payload message template embedded
Format data as following:
{ “type”:“transparent”, //payload type “config”:“{ “content”:“XXXXXXX”, //payload notification content } ” }
Format of returns from Web Interface:
{ "status": "200", "pushedCount": 100, "offCount": 1, "elapsed": 0.52, "mid": "489c4464de66000" }
* status: 200 indicates success, 400 indicates the request packet format error. * pushedCount: count of message sent. This number does not represent the number of users(devices) who received the message, it only means the server has sent data to 100 links. Only when SDK submit the receipt, the PNS server will get to know how many users(devices) received message. * offCount: the current offline count in submitted user channel. * elapsed: the consume time on the server push, in milliseconds, is a float type number. * mid: the unique ID of push task for the pushing. It can be used to query task information asynchronous, such as received count, click count, message content, and so on.