你也可以后端不集成个推SDK,使用个推推荐的RestAPI v2接口来发起推送消息,给你一个postman
demo,里面包含鉴权和单推接口的示例,下载附件后 先在vscode中打开然后替换掉所有的 {!!此处替换为appid}
伪代码即可发起推送
{
"info": {
"_postman_id": "eb87c469-68f9-410d-8b8a-db176cf8c52c",
"name": "UniPush 应用在线/离线RestAPI V2 接口调用测试",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "单推",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"const timestamp = +new Date;",
"pm.variables.set('timestamp', timestamp)",
"pm.variables.set('appid', '{!!此处替换为appid}')"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "token",
"value": "{!!此处替换为鉴权接口返回的token}",
"type": "text"
},
{
"key": "content-type",
"value": "application/json;charset=utf-8",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": " { \n \"request_id\":\"apsmobile_{{timestamp}}\", \n \"audience\": { \n \"cid\": [\n \"cid\" \n ] \n }, \n \"settings\":{ \n \"ttl\":3600000, \n \"strategy\":{ \n \"default\":1 \n } \n }, \n \"push_message\":{ \n \"transmission\":\"{title: \\\"${title}\\\", content: \\\"${content}\\\", payload: \\\"${payload}\\\"}\" \n }, \n \"push_channel\":{ \n \"android\":{ \n \"ups\":{ \n \"notification\":{ \n \"title\":\"代办离线消息\", \n \"body\":\"您有一条李现代办消息\", \n \"click_type\":\"intent\", \n \"intent\":\"intent:#Intent;action=android.intent.action.oppopush;launchFlags=0x14000000;component={!!!!!!!包名}/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title=代办;S.content=您有一条代办消息;S.payload={path: '/ddd'};end\" \n } \n } \n }, \n \"ios\":{ \n \"type\":\"notify\", \n \"payload\":\"{'title':'1','content':'2','payload':'3'}\", \n \"aps\":{ \n \"alert\":{ \n \"title\":\"代办消息2\", \n \"body\":\"您有一条待办消息2\" \n }, \n \"content-available\":0 \n }, \n \"auto_badge\":\"+1\" \n } \n}}"
},
"url": {
"raw": "https://restapi.getui.com/v2/{{appid}}/push/single/cid",
"protocol": "https",
"host": [
"restapi",
"getui",
"com"
],
"path": [
"v2",
"{{appid}}",
"push",
"single",
"cid"
]
}
},
"response": []
},
{
"name": "鉴权",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"const timestamp = new Date().getTime();",
"const appkey = '{!!此处替换为appkey}';",
"const mastersecret = '{!!此处替换为mastersecret}';",
"",
"const signStr = appkey + timestamp + mastersecret;",
"",
"const sign = CryptoJS.SHA256(signStr).toString()",
"",
"pm.variables.set('appkey', appkey)",
"pm.variables.set(\"sign\", sign + '')",
"pm.variables.set('timestamp', timestamp)",
"console.log(sign)"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "content-type",
"value": "application/json;charset=utf-8",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"sign\": \"{{sign}}\",\n \"timestamp\": \"{{timestamp}}\",\n \"appkey\": \"{{appkey}}\"\n}"
},
"url": {
"raw": "{{BaseUrl}}/auth",
"host": [
"{{BaseUrl}}"
],
"path": [
"auth"
]
}
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "BaseUrl",
"value": "https://restapi.getui.com/v2/{!!此处替换为appid}"
}
]
}
2 个回复
BoredApe - 有问题就会有答案。
那个厂商收不到消息。intent是否书写正确。
可以联系个推客服询问消息推送状态
BoredApe - 有问题就会有答案。
你也可以后端不集成个推SDK,使用个推推荐的RestAPI v2接口来发起推送消息,给你一个
postman
demo,里面包含鉴权和单推接口的示例,下载附件后 先在vscode中打开然后替换掉所有的{!!此处替换为appid}
伪代码即可发起推送