Skip to content

Instantly share code, notes, and snippets.

@xiezefan
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiezefan/1727fe71dbf88bebbe74 to your computer and use it in GitHub Desktop.
Save xiezefan/1727fe71dbf88bebbe74 to your computer and use it in GitHub Desktop.

POST /service/{serviceId}/{clientServiceId}/push

对指定的ClientService进行推送

KEY DESCRIPTION REQUIRE
platform 目标平台,支持all,ios,android false
audience 目标用户,支持all,与基于push_token点对点推送 true
type 推送的类型 true
text 文本对象 false
article 图文对象 false

platform

指定推送给特定平台, 支持 android, ios

推送到所有平台(如未指定platform,默认推送到所有平台)

{ "platform" : "all" }

指定推送特定平台

{ "platform" : ["android", "ios"] }

audience

指定推送给特定用户

推送给所有的用户

{"audience" : "all"}

根据push_token推送给特定用户

{
    "audience" : {
        "push_token":["4df99d44-23d0-454a-b7c6-d734da0aa8e7", "4df99d44-23d0-454a-b7c6-d734da0aa8e7"]
    }
}

type

推送的类型,目前支持  

  • DING 纯提醒
  • TEXT 纯文本
  • IMAGE 图文消息

text

纯文本消息,当type="TEXT"时,该参数为必填

Params:
  • content 推送的正文,长度不超过140字节
Example
{
    "text":{
         "content":"每天深圳有大到暴雨转狂暴雨,风太大,带伞也没有,所以无须带雨伞。"
    }
}

article

图文消息,当type="IMAGE"时,该参数为必填

Params:

  • title 图文标题,必填
  • summary 图文概述,只在Notification Bar显示,非必填
  • cover_pic 图文封面,非必填
  • link 图文外链,必填
{
    "article":{
        "title":"深圳明天下雨",
        "summary":"每天深圳有大到暴雨转狂暴雨,风太大,带伞也没有,所以无须带雨伞。",
        "cover_pic":"http://a.36krcnd.com/photo/2014/4c096554b77e6d8a2b9f7c754322edc3.jpg"
        "link":"http://www.36kr.com/p/215315.html"
    }
}

Notify API

Notify API 是当Service, ClientService发生创建,关注,取消关注等事件时, 服务端会主动通知Factory的设计.

Service创建事件

{
  "s_data": "{\"date\":\"1\",\"status\":\"下雨\"}",
  "action": "ACTION_SERVICE_CREATE",
  "title": "明天下雨提醒",
  "api_secret": "09ltfmd29f0our68q5bjij2x",
  "sid": "5857",
  "c_data": [
    {
      "data": "{\"location\":\"珠海\"}",
      "cid": "6f782524-22d4-48fc-b0f6-ab79d49bf178"
    },
    {
      "data": "{\"location\":\"深圳\"}",
      "cid": "c388eb26-c9f2-41ae-93c5-fdcc0ff8d26a"
    }
  ]
}

Service更新事件

{
  "s_data": "{\"date\":\"1\",\"status\":\"下雨\"}",
  "action": "ACTION_SERVICE_UPDATE",
  "title": "明天下雨提醒",
  "api_secret": "09ltfmd29f0our68q5bjij2x",
  "sid": "5857",
  "c_data": [
    {
      "data": "{\"location\":\"珠海\"}",
      "cid": "6f782524-22d4-48fc-b0f6-ab79d49bf178"
    },
    {
      "data": "{\"location\":\"深圳\"}",
      "cid": "c388eb26-c9f2-41ae-93c5-fdcc0ff8d26a"
    }
  ]
}

ClientService创建事件

{
  "data": "{\"date\":\"1\",\"status\":\"下雨\"}",
  "action": "ACTION_CLIENT_SERVICE_CREATE",
  "sid": "0556",
  "cid": "bc6e20b4-a0f0-494f-8564-dc2490432e4e"
}

ClientService关注数变更事件

{
  "action": "ACTION_SERVICE_FOLLOWED_CHANGE",
  "followed": 25,
  "sid": "0556",
  "cid": "05e504ec-7500-4ab0-b63b-21cc2b91438e"
}

用户互动事件

{
  "action": "ACTION_SERVICE_DING",
  "location": {
    "lng": "120.748588",
    "lat": "31.282878"
  },
  "push_token": "e17adc4a-439b-4589-ae01-e0508fc8cbbf",
  "sid": "8994",
  "cid": "c07b5bd7-155e-40eb-8f23-b57dbd50ecfd"
}

Factory Response Code

Server主动添加Factory的时候, 返回的Response规范: Success:

{ "code": 3000, "message":"success" }

Fail:

{ "code": 1000, "message":"Bad Server" }
Code Description
1000 Bad Server
1001 Tip Message(将会在客户端展示)
1002 Invalid Parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment