目录

请求示例

通知消息

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:0
 
{ 
  "payload": { 
    "notification": { 
      "category": "MARKETING", 
      "title": "普通标题", 
      "body": "普通内容", 
      "clickAction": { 
        "actionType": 0
      }, 
      "style": 0, 
      "image":"https://lf*******246.png" 
    } 
  }, 
  "target": { 
    "token": ["MAAALgE4G98BAAAAst*******jg"] 
  } 
}

授权订阅消息

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:0
 
{ 
  "payload": { 
    "subscription": { 
      "entityId": "TM*****FA9",
      "data": {
        "keyword1": "接单了",
        "keyword2": "苏A12345",
        "keyword3": "司机路径"
      },
      "clickAction": {
        "actionType": 0                
      }
    } 
  }, 
  "target": { 
    "token": ["MAAALgE4G98BAAAAst*******jg"] 
  } 
}

卡片刷新消息

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:1
 
{ 
  "payload": { 
    "formData": { 
      "123": 96, 
      "class": "123" 
    }, 
    "version": 922337203, 
    "images": [ 
      { 
        "keyName": "hello", 
        "url": "https://xxx.png", 
        "require": 1 
      } 
    ], 
    "formId": 0, 
    "moduleName": "testName", 
    "formName": "testFormName", 
    "abilityName": "testAbilityName"      
  }, 
  "pushOptions": { 
    "biTag": "this is bi", 
    "ttl": 666 
  }, 
  "target": { 
    "token": [ 
      "MAAALgE4G98BAAAAst************ttQd4Tw" 
    ]   
  } 
}

通知扩展消息

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:2
 
{ 
  "payload": { 
    "extraData": "Extension extra data", 
    "notification": { 
      "category": "EXPRESS", 
      "title": "普通标题", 
      "body": "普通内容", 
      "clickAction": { 
        "actionType": 0
      }, 
      "style": 0, 
      "image":"https://lf*******246.png" 
    } 
  }, 
  "target": { 
    "token": ["MAAALgE4G98BAAAAst*******jg"] 
  } 
}

后台消息

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:6
 
{ 
  "payload": { 
    "extraData": "携带的数据" 
  }, 
  "target": { 
    "token": ["MAAALgE4G98BAAAAst************jq"] 
  } 
}

创建实况窗消息

[h2]航班场景(event为FLIGHT)

计划出发,使用左右文本模板。

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send 
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---**** 
push-type:7 

{
  "pushOptions": {
    "ttl": 1000,
    "biTag": "biTag"
  },
  "payload": {
    "activityId": 1,
    "operation": 0,
    "event": "FLIGHT",
    "status": "DEPART", // 计划出发
    "activityData": {
      "notificationData": {
        "keywords": {
          "flightNo": "MU1471"
        },
        "type": 5,
        "contentTitle": "航班{{status}}", // 航班计划出发
        "contentText": [
          {
            "text": "航班号:"
          },
          {
            "text": "{{flightNo}}", // MU1471
            "foregroundColor": "#FF317AF7"
          }
        ],
        "clickAction": {
          "actionType": 0
        },
        "firstTextBlock": {
          "firstLine": "12:00",
          "secondLine": "上海虹桥"
        },
        "lastTextBlock": {
          "firstLine": "14:20",
          "secondLine": "成都天府"
        },
        "displayHorizontalLine": true,
        "spaceIcon": "space.png", // 取值为“/resources/rawfile”路径下的文件名
        "extend": {
          "type": 3,
          "pic": "flight.png", // 取值为“/resources/rawfile”路径下的文件名
          "clickAction": {
            "actionType": 1,
            "action": "xxxxxxx"
          }
        }
      },
      "capsuleData": {
        "type": 1,
        "status": 1,
        "icon": "icon.svg", // 取值为“/resources/rawfile”路径下的文件名
        "bgColor": "#FF317AF7",
        "remind": "EXPAND",
        "title": "即将出发",
        "content": "请尽快前往机场"
      }
    }
  },
  "target": {
    "token": [
      "MAAALgE4G98BAAAAst************jq"
    ]
  }
}

[h2]出行打车场景(event为TAXI)

司机正在赶来,使用进度可视化模板。

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:7

{
  "pushOptions": {
    "ttl": 1000,
    "biTag": "biTag"
  },
  "payload": {
    "activityId": 2,
    "operation": 0,
    "event": "TAXI",
    "status": "DRIVER_ON_THE_WAY", // 司机正在赶来
    "activityData": {
      "notificationData": {
        "type": 3,       
        "contentTitle": "{{status}}", // 司机正在赶来
        "contentText": [
          {
            "text": "距您"
          },
          {
            "text": "1.2公里",
            "foregroundColor": "#FF317AF7"
          },
          {
            "text": " | "
          },
          {
            "text": "5分钟",
            "foregroundColor": "#FF317AF7"
          }
        ],
        "clickAction": {
          "actionType": 1, // 打开应用自定义页面
          "action": "xxxxxx" // 应用内置页面ability对应的action
        },
        "richProgress": {
          "type": 0,
          "nodeIcons": ["icon1.png", "icon2.png", "icon3.png"], // 取值为“/resources/rawfile”路径下的文件名
          "indicatorIcon": "taxi.png", // 取值为“/resources/rawfile”路径下的文件名
          "progress": 40,
          "indicatorType": 1,
          "color": "#FF317AF7",
          "bgColor": "#19000000"
        },
        "extend": {
          "type": 3,
          "pic": "phone.png", // 取值为“/resources/rawfile”路径下的文件名
          "clickAction": {
            "actionType": 5, // 打开拨号界面
            "data": {
              "tel": "138xxxxxxxx" // 通过tel字段携带电话号码
            }
          }
        }
      },
      "capsuleData": {
        "type": 1,
        "status": 1,
        "icon": "icon.svg", // 取值为“/resources/rawfile”路径下的文件名
        "bgColor": "#FF317AF7",
        "remind": "EXPAND",
        "title": "接驾中",
        "content": "预计5分钟"
      }
    }
  },
  "target": {
    "token": [
      "MAAALgE4G98BAAAAst************jq"
    ]
  }
}

[h2]高铁/火车场景(event为TRAIN)

计划出发,使用左右文本模板。

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:7

{
  "pushOptions": {
    "ttl": 1000,
    "biTag": "biTag"
  },
  "payload": {
    "activityId": 3,
    "operation": 0,
    "event": "TRAIN",
    "status": "DEPART", // 计划出发
    "title": "列车即将出发",
    "content": "请尽快去高铁站",
    "activityData": {
      "notificationData": {
        "keywords": {
          "trainNo": "G1406"
        },
        "type": 5,        
        "contentTitle": "列车{{status}}", // 列车计划出发
        "contentText": [
          {
            "text": "车次:"
          },
          {
            "text": "{{trainNo}}", // G1406
            "foregroundColor": "#FF317AF7"
          }
        ],
        "clickAction": {
          "actionType": 0
        },
        "firstTextBlock": {
          "firstLine": "13:00",
          "secondLine": "上海虹桥"
        },
        "lastTextBlock": {
          "firstLine": "14:20",
          "secondLine": "南京南"
        },
        "displayHorizontalLine": true,
        "spaceIcon": "space.png", // 取值为“/resources/rawfile”路径下的文件名
        "extend": {
          "type": 3,
          "pic": "train.png", // 取值为“/resources/rawfile”路径下的文件名
          "clickAction": {
            "actionType": 1,
            "action": "xxxxxxx"
          }
        }
      },
      "capsuleData": {
        "type": 1,
        "status": 1,
        "icon": "icon.svg", // 取值为“/resources/rawfile”路径下的文件名
        "bgColor": "#FF317AF7",
        "remind": "EXPAND",
        "title": "即将出发",
        "content": "请尽快去高铁站"
      }
    }
  },
  "target": {
    "token": [
      "MAAALgE4G98BAAAAst************jq"
    ]
  }
}

更新实况窗消息

[h2]航班场景(event为FLIGHT)

已值机,使用左右文本模板。

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send 
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---**** 
push-type:7 

{
  "pushOptions": {
    "ttl": 1000,
    "biTag": "biTag"
  },
  "payload": {
    "activityId": 1,
    "operation": 1,
    "event": "FLIGHT",
    "status": "CHECKED_IN", // 已值机
    "version": 1,
    "activityData": {
      "notificationData": {
        "keywords": {
          "flightNo": "MU1471"
        },
        "type": 5,
        "contentTitle": "登机口88",
        "contentText": [
          {
            "text": "{{status}} | " // 已值机
          },
          {
            "text": "{{flightNo}}", // MU1471
            "foregroundColor": "#FF317AF7"
          }
        ],
        "clickAction": {
          "actionType": 0
        },
        "firstTextBlock": {
          "firstLine": "12:00",
          "secondLine": "上海虹桥"
        },
        "lastTextBlock": {
          "firstLine": "14:20",
          "secondLine": "成都天府"
        },
        "displayHorizontalLine": true,
        "spaceIcon": "space.png", // 取值为“/resources/rawfile”路径下的文件名
        "extend": {
          "type": 3,
          "pic": "flight.png", // 取值为“/resources/rawfile”路径下的文件名
          "clickAction": {
            "actionType": 1,
            "action": "xxxxxxx"
          }
        }
      },
      "capsuleData": {
        "type": 1,
        "status": 1,
        "icon": "icon.svg", // 取值为“/resources/rawfile”路径下的文件名
        "bgColor": "#FF317AF7",
        "remind": "EXPAND",
        "title": "登机口88",
        "content": "请尽快完成安检"
      }
    }
  },
  "target": {
    "token": [
      "MAAALgE4G98BAAAAst************jq"
    ]
  }
}

[h2]出行打车场景(event为TAXI)

正在去往目的地,使用进度可视化模板。

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:7

{
  "pushOptions": {
    "ttl": 1000,
    "biTag": "biTag"
  },
  "payload": {
    "activityId": 2,
    "operation": 1,
    "event": "TAXI",
    "status": "HEADING_TO_DESTINATION", // 正在去往目的地
    "version": 1,
    "activityData": {
      "notificationData": {
        "type": 3,
        "contentTitle": "{{status}}", // 正在去往目的地
        "contentText": [
          {
            "text": "距目的地"
          },
          {
            "text": "7.2公里",
            "foregroundColor": "#FF317AF7"
          },
          {
            "text": " | 预计"
          },
          {
            "text": "27分钟",
            "foregroundColor": "#FF317AF7"
          }
        ],
        "clickAction": {
          "actionType": 1,
          "action": "xxxxxx"
        },
        "richProgress": {
          "type": 0,
          "nodeIcons": ["icon1.png", "icon2.png", "icon3.png"], // 取值为“/resources/rawfile”路径下的文件名
          "indicatorIcon": "taxi.png", // 取值为“/resources/rawfile”路径下的文件名
          "progress": 60,
          "indicatorType": 1,
          "color": "#FF317AF7",
          "bgColor": "#19000000"
        },
        "extend": {
          "type": 0
        }
      },
      "capsuleData": {
        "type": 1,
        "status": 1,
        "icon": "icon.svg", // 取值为“/resources/rawfile”路径下的文件名
        "bgColor": "#FF317AF7",
        "title": "27分钟",
        "content": "距目的地7.2公里"
      }
    }
  },
  "target": {
    "token": [
      "MAAALgE4G98BAAAAst************jq"
    ]
  }
}

行程结束,使用强调文本模板。

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:7

{
  "pushOptions": {
    "ttl": 1000,
    "biTag": "biTag"
  },
  "payload": {
    "activityId": 2,
    "operation": 1,
    "event": "TAXI",
    "status": "COMPLETED", // 行程结束
    "version": 2,
    "activityData": {
      "notificationData": {
        "type": 4,       
        "contentTitle": "{{status}},请支付", // 行程结束,请支付
        "contentText": [
          {
            "text": "全程"
          },
          {
            "text": "10公里",
            "foregroundColor": "#FF317AF7"
          },
          {
            "text": " | 耗时"
          },
          {
            "text": "30分钟",
            "foregroundColor": "#FF317AF7"
          }
        ],
        "clickAction": {
          "actionType": 1,
          "action": "xxxxxx"
        },
        "singleTextBlock": { 
          "firstLine": "全程费用", 
          "secondLine": "35.2元", 
          "underlineColor": "#FF317AF7" 
        }, 
        "descPic": "payment.png", // 取值为“/resources/rawfile”路径下的文件名
        "extend": {
          "type": 0
        }
      },
      "capsuleData": {
        "type": 1,
        "status": 1,
        "icon": "icon.svg", // 取值为“/resources/rawfile”路径下的文件名
        "bgColor": "#FF317AF7",
        "title": "待支付",
        "content": "费用35.2元"
      }
    }
  },
  "target": {
    "token": [
      "MAAALgE4G98BAAAAst************jq"
    ]
  }
}

[h2]高铁/火车场景(event为TRAIN)

列车运行中,使用左右文本模板。

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:7

{
  "pushOptions": {
    "ttl": 1000,
    "biTag": "biTag"
  },
  "payload": {
    "activityId": 3,
    "operation": 1,
    "event": "TRAIN",
    "status": "HEADING_TO_DESTINATION", // 列车运行中
    "version": 1,
    "activityData": {
      "notificationData": {
        "keywords": {
          "trainNo": "G1406"
        },
        "type": 5,        
        "contentTitle": "{{status}}", // 列车运行中
        "contentText": [
          {
            "text": "车次:"
          },
          {
            "text": "{{trainNo}}", // G1406
            "foregroundColor": "#FF317AF7"
          }
        ],
        "clickAction": {
          "actionType": 0
        },
        "firstTextBlock": {
          "firstLine": "13:00",
          "secondLine": "上海虹桥"
        },
        "lastTextBlock": {
          "firstLine": "14:20",
          "secondLine": "南京南"
        },
        "displayHorizontalLine": true,
        "spaceIcon": "space.png", // 取值为“/resources/rawfile”路径下的文件名
        "extend": {
          "type": 3,
          "pic": "train.png", // 取值为“/resources/rawfile”路径下的文件名
          "clickAction": {
            "actionType": 1,
            "action": "xxxxxxx"
          }
        }
      },
      "capsuleData": {
        "type": 1,
        "status": 1,
        "icon": "icon.svg", // 取值为“/resources/rawfile”路径下的文件名
        "bgColor": "#FF317AF7",
        "title": "运行中",
        "content": "预计14:20到达"
      }
    }
  },
  "target": {
    "token": [
      "MAAALgE4G98BAAAAst************jq"
    ]
  }
}

[h2]赛事比分场景(event为SCORE)

推送赛事最新比分,使用赛事比分模板。

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:7 
 
{ 
  "pushOptions": { 
    "ttl": 1000, 
    "biTag": "biTag" 
  }, 
  "payload": { 
    "activityId": 4, 
    "operation": 1, 
    "event": "SCORE", 
    "activityData": { 
      "notificationData": { 
        "type": 7,         
        "contentTitle": "第四节比赛中", 
        "contentText": [ 
          { 
            "text": "XX",
            "foregroundColor": "#FF317AF7"
          },
          {
            "text": " VS " 
          },
          {
            "text": "XX",
            "foregroundColor": "#FF317AF7"
          },
          {
            "text": " | 小组赛第五场" 
          }
        ], 
         "game": { 
            "host": { 
              "icon":"host.png", // 取值为“/resources/rawfile”路径下的文件名
              "name": "队名A", 
              "score": "110" 
            }, 
            "guest": { 
              "icon":"guest.png", // 取值为“/resources/rawfile”路径下的文件名
              "name": "队名B", 
              "score": "102" 
            }, 
            "competition": { 
              "desc": "Q4", 
              "time":"02:16" 
            } 
          },
        "displayHorizontalLine": true,
        "clickAction": {
          "actionType": 1,
          "action": "xxxxxxx"
        }
      }, 
      "capsuleData": { 
        "type": 1, 
        "status": 1, 
        "icon": "icon.svg", // 取值为“/resources/rawfile”路径下的文件名
        "bgColor": "#FF317AF7",
        "title": "110:102", 
        "content": "第四节比赛中" 
      } 
    } 
  }, 
  "target": { 
    "token": ["MAAALgE4G98BAAAAst************jq"] 
  } 
}

应用内通话消息

POST https://push-api.cloud.huawei.com/v3/3158882***52863/messages:send
Authorization: Bearer eyJr*****OiIx---****.eyJh*****iJodHR--***.QRod*****4Gp---****
push-type:10
 
{ 
  "pushOptions": { 
    "biTag": "biTag" 
  }, 
  "payload": { 
    "extraData": "携带的透传数据"
  }, 
  "target": { 
    "token": [ 
      "MAAALgE4G98BAAAAst************jq" 
    ] 
  } 
}