向某单个设备或者某设备列表推送一条通知、消息。推送的内容只能是 JSON 表示的一个推送对象。
调用验证
详情参见 REST API 概述的 鉴权方式 说明。
频率控制
详情参见推送限制策略的 接口限制 说明。
调用地址
POST http://api.push.mob.com/v3/push/createPush
推送对象
以 JSON 格式表达,表示一条推送相关的所有信息
请求示例
curl --location --request POST 'http://api.push.mob.com/v3/push/createPush' \
--header 'Content-Type: application/json' \
--header 'key: 2f2d7a68f8a40' \
--header 'sign: eb276f35cf6480169b2d3e2e509db680' \
--data-raw '{"source":"webapi","appkey":"2f2d7a68f8a40","pushTarget":{"target":1},"pushNotify":{"plats":[1],"content":"推送的内容","type":1}}'
响应示例
请求成功
{
"status": 200,
"res": {
"batchId": "4bp4tw9ttc06xgch6o",
"fetched": null,
"uninstalls": null,
"closes": null,
"notFounds": null
},
"error": null
}
请求失败
{
"status": 5801,
"res": null,
"error": "数据校验失败"
}
响应参数
调用示例
推送广播
{
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 1
},
"pushNotify": {
"plats": [
1
],
"content": "推送的内容",
"type": 1
}
}
推送广播并附加参数
{
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 1
},
"pushNotify": {
"plats": [
1,
2
],
"content": "推送的内容",
"type": 1,
"iosProduction": 0,
"extrasMapList": [
{
"key": "ContentTypeasd",
"value": "personal_chat"
}
]
}
}
推送标签
{
"source": "webapi",
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 3,
"tags": [
"男",
"上海",
"老师"
]
},
"pushNotify": {
"plats": [
1
],
"content": "推送的内容",
"type": 1
}
}
推送别名
{
"source": "webapi",
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 2,
"alias": [
"alias_1",
"alias_2"
]
},
"pushNotify": {
"plats": [
1
],
"content": "推送的内容",
"type": 1
}
}
推送 RegisterID
{
"source": "webapi",
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 4,
"rids": [
"c262bac10d05ec1c9b04126d"
]
},
"pushNotify": {
"plats": [
1
],
"content": "推送的内容",
"type": 1
}
}
自定义消息(透传消息)
{
"source": "webapi",
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 1
},
"pushNotify": {
"plats": [
1
],
"content": "推送内容",
"type": 2,
}
}
Android 通知大图模式
{
"source": "webapi",
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 1
},
"pushNotify": {
"plats": [
1
],
"content": "推送内容",
"type": 1,
"androidNotify": {
"content": [
"Android推送内容1",
"Android推送内容2"
],
"style": 2
}
}
}
Android 通知横幅模式
{
"source": "webapi",
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 1
},
"pushNotify": {
"plats": [
1
],
"content": "推送内容",
"type": 1,
"androidNotify": {
"content": [
"Android推送内容1",
"Android推送内容2"
],
"style": 3
}
}
}
Android 通知自定义声音
音频文件放到项目 res/raw 目录下,只需传音频文件的文件名
{
"source": "webapi",
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 1
},
"pushNotify": {
"plats": [
1
],
"content": "推送内容",
"type": 1,
"androidNotify": {
"content": [
"Android推送内容1",
"Android推送内容2"
],
"style": 2,
"warn": "1",
"sound": "warn",
"androidChannelId": "channelId"
}
}
}
跳转首页并传递附加参数
{
"source": "webapi",
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 1
},
"pushNotify": {
"plats": [
1
],
"content": "推送内容",
"type": 1,
"androidNotify": {
"content": [
"Android推送内容1",
"Android推送内容2"
],
"style": 2,
"warn": "1",
"sound": "warn"
},
"extrasMapList": [
{
"key": "extrakey",
"value": "extravalue"
}
]
},
"pushForward": {
"nextType": 0
}
}
跳转到指定界面并且传递携带 scheme 数据
{
"source": "webapi",
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 1
},
"pushNotify": {
"plats": [
1
],
"content": "推送内容",
"type": 1,
"androidNotify": {
"content": [
"Android推送内容1",
"Android推送内容2"
],
"style": 2,
"warn": "1",
"sound": "warn"
}
},
"pushForward": {
"nextType": 2,
"scheme": "mlink://com.mob.mobpush.linkone",
"schemeDataList": [
{
"key": "schemekey",
"value": "schemevalue"
}
]
}
}
打开网页
{
"source": "webapi",
"appkey": "moba6b6c6d6",
"pushTarget": {
"target": 1
},
"pushNotify": {
"plats": [
1
],
"content": "推送内容",
"type": 1,
"androidNotify": {
"content": [
"Android推送内容1",
"Android推送内容2"
],
"style": 2,
"warn": "1",
"sound": "warn"
}
},
"pushForward": {
"nextType": 1,
"url": "http://www.mob.com"
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。