请求示例

请求示例

通知消息

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 0' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
    "payload": {
        "notification": {
            "category": "MARKETING", // category替换为实际通知消息类型
            "title": "普通标题",
            "body": "普通内容",
            "clickAction": {
                "actionType": 0
            }
        }
    },
    "target": {
        "token": [
            "o39qtoP7Nd6s*******2d4d5636",
        ]
    }
}'

语音播报消息

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 2' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
    "payload": {
        "notification": {
            "category": "PLAY_VOICE",
            "title": "普通标题",
            "body": "普通内容",
            "clickAction": {
                "actionType": 0
            }
        },
        "extraData": "传递给应用的数据"
    },
    "target": {
        "token": [
            "o39qtoP7Nd6s*******2d4d5636",
        ]
    }
}'

后台消息

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 6' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
    "payload": {
        "extraData": "传递给应用的数据"
    },
    "target": {
        "token": [
            "o39qtoP7Nd6s*******2d4d5636",
        ]
    }
}'

创建实况窗消息

航班场景(event为FLIGHT)

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

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 7' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
  "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": [
      "o39qtoP7Nd6s*******2d4d5636"
    ]
  }
}'

出行打车场景(event为TAXI)

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

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 7' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
  "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": [
      "o39qtoP7Nd6s*******2d4d5636"
    ]
  }
}'

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

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

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 7' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
  "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": [
      "o39qtoP7Nd6s*******2d4d5636"
    ]
  }
}'

更新实况窗消息

航班场景(event为FLIGHT)

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

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 7' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
  "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": [
      "o39qtoP7Nd6s*******2d4d5636"
    ]
  }
}'

出行打车场景(event为TAXI)

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

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 7' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
  "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": [
      "o39qtoP7Nd6s*******2d4d5636"
    ]
  }
}'

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

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 7' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
  "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": [
      "o39qtoP7Nd6s*******2d4d5636"
    ]
  }
}'

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

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

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 7' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
  "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": [
      "o39qtoP7Nd6s*******2d4d5636"
    ]
  }
}'

赛事比分场景(event为SCORE)

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

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 7' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
  "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": ["o39qtoP7Nd6s*******2d4d5636"]
  }
}'

应用内通话消息

curl --location 'https://oh-push-api.getui.com/v3/NdMch6e******mcsXsxM4A/messages:send' \
--header 'Content-Type: application/json' \
--header 'push-type: 10' \
--header 'Authorization: Bearer eyJ0eX******IUzI1NiJ9.eyJpc******YzNTZ9.j6y1NGM******NncAeLE' \
--data '{
    "payload": {
        "extraData": "传递给应用的数据"
    },
    "target": {
        "token": [
            "o39qtoP7Nd6s*******2d4d5636",
        ]
    }
}'
开发者中心 SDK 下载

文档中心搜索

技术
咨询

微信扫一扫

随时联系技术支持

在线
咨询