写点什么

创建推送

  • 2024-07-17
    上海
  • 本文字数:3047 字

    阅读完需:约 10 分钟

创建推送

向某单个设备或者某设备列表推送一条通知、消息。推送的内容只能是 JSON 表示的一个推送对象。

调用验证

详情参见 REST API 概述的 鉴权方式 说明。

频率控制

详情参见推送限制策略的 接口限制 说明。

调用地址

推送对象

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


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

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

还未添加个人简介

评论

发布
暂无评论
创建推送_Java_MobTech袤博科技_InfoQ写作社区