写点什么

MobPush 创建推送

  • 2023-07-26
    上海
  • 本文字数:3541 字

    阅读完需:约 12 分钟

MobPush 创建推送

功能说明

  • MobPush 提供遵循 REST 规范的 HTTP 接口,适用各开发语言环境调用。

频率控制

此接口频次限制 30 次/秒,如频次不满足,可点击右侧"技术咨询”图标了解详情。

IP 绑定

工作台可以绑定服务器 IP 地址,未绑定之前所有 IP 均可进行 REST API 的调用,绑定后仅绑定的 IP 才有调用权限。


调用地址

请求头

推送对象

  • 以 JSON 格式表达,表示一条推送相关的所有信息。

pushTarget:推送目标

pushAreas:复杂地理位置

countries:国家列表

provinces:省份列表

pushNotify:推送展示细节配置

androidNotify:Android 通知消息对象

customStyle:安卓通知自定义样式

notifyRepeat:消息重弹配置项

iosNotify:iOS 通知消息对象

pushOperator:运营保障相关配置

pushForward:Link 相关打开配置

pushCallback:推送回调配置

pushFactoryExtra:厂商特殊配置

huaweiExtra:华为厂商特殊配置

xiaomiExtra:小米厂商特殊配置

oppoExtra:OPPO 厂商特殊配置

vivoExtra:VIVO 厂商特殊配置

userExtra:用户补充信息

加密示例

  • 参数

{"source":"webapi","appkey":"2f2d7a68f8a40","pushTarget":{"target":1},"pushNotify":{"plats":[1],"content":"推送的内容","type":1}}9abee316611dd24f607feb9f2c496338
复制代码
  • 计算结果

sign -> eb276f35cf6480169b2d3e2e509db680
复制代码

请求示例

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,        "customNotify": {            "customType": "text 文本消息",            "customTitle": "自定义类型标题"        }    }}
复制代码

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"    }}
复制代码

批量推送

MobPush 还额外提供了批量推送接口,可以设置推送不同的 regid 和别名对应不同的推送内容,详情点击查看

返回码


发布于: 刚刚阅读数: 4
用户头像

还未添加个人签名 2019-05-08 加入

还未添加个人简介

评论

发布
暂无评论
MobPush 创建推送_前端_MobTech袤博科技_InfoQ写作社区