设备 API
registerDevice
Anchor link toPOST https://api.pushwoosh.com/json/1.3/registerDevice
由 SDK 内部调用。为应用程序注册设备。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问设备 API 的 API 设备令牌。请将 XXXX 替换为您的实际设备 API 令牌。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application* | string | Pushwoosh 应用代码 |
| push_token | string | 设备的 推送令牌。 |
| language | string | 设备的语言区域设置。必须是符合 ISO-639-1 标准的小写双字母代码。 |
| hwid* | string | 用于识别设备的唯一字符串(iOS 上为 IDFV,Android 上为随机生成的值)。了解更多 |
| timezone | integer | 设备的秒级时区偏移量。 |
| device_type* | integer | 设备类型。请参阅下方的可能值。 |
| string | 要注册的电子邮件地址(用于电子邮件用户,而非 HWID 和推送令牌)。 | |
| tags | object | 分配给已注册设备的标签值。 |
{ "status_code": 200, "status_message": "OK", "response": null}{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "push_token": "dec301908b9ba8XXXXX57a58e40f96f5XXXXX2068674f5XXXXa25cdc250a2a41", // optional. "hwid": "1CA6XXXXX-8DAC-XXXXX-XXXXX-B756288B6D3C", // required. Hardware device ID "idfa": "AEBE52E7-0XXXXX-455A-XXXXX-E57283966239", // optional. "timezone": 3600, // optional. Offset in seconds "device_type": 1, // required. See the possible values below. For emails, // use the "emails" params as described below. "email": "email_address@domain.com", // use instead of "hwid" and "push_token" to register // the email address for your email project "language": "en", // optional. ISO 639-1|639-2 language code "userId": "Alex", // optional. "tags": { // optional. Tag values to set for the device registered "StringTag": "string value", "IntegerTag": 42, "ListTag": ["string1", "string2"], // sets the list of values for Tags of List type "DateTag": "2024-10-02 22:11", // note the time should be in UTC "BooleanTag": true // valid values are: true, false },
// system tags, optionals "app_version": "1.2.3", "device_model": "Samsung SM-G355H", "os_version": "2.3",
// optional encryption keys for chrome/firefox "public_key": "BNmDO4BTKEMJqaqprTf7t/HBXXXXX/orcXXXXX/scS5CFP6XXXXXHI1/GgRQD8c4kTxTEEF0quvIUiLQqoBY0/Qo=", "auth_token": "RlRmCXXXXX/s7XXXXXjKFzoQ==",
// optional FCM keys for Chrome (for XMPP) "fcm_token": "BNmDO4BTKEMJXXXXXprTf7t/XXXXXBQ/orXXXXXc/scS5CFP6zhQGIHI1/GgRQD8c4kTxTEEF0quvIUiLQqoBY0/Qo=", "fcm_push_set": "RlXXXXXGM/s7XXXXXjKFzoQ==" }}可能的设备类型:
- 1 – iOS
- 3 – Android
- 7 – Mac OS X
- 8 – Windows
- 9 – Amazon
- 10 – Safari
- 11 – Chrome
- 12 – Firefox
- 13 – Internet Explorer
- 14 – Email
- 17 – Huawei
- 18 – SMS
- 20 – Web
- 21 – WhatsApp
- 22 – Line
- 23 – Kakao Talk
- 24 – Telegram
- 25 – Apple Wallet
- 26 – Google Wallet
- 27 – Viber
注册电子邮件设备
Anchor link to要为您的应用注册电子邮件订阅者,请在您的 /registerDevice 或 /registerEmail 请求中按如下方式发送 "email": "email_address@domain.com" 参数:
请求示例
Anchor link to{ "request":{ "application": "XXXXX-XXXXX", // required. Pushwoosh application code "email": "email_address@domain.com", // required. Email address to register for your email project "language": "en", // optional. ISO 639-1|639-2 language code "userId": "Alex", // optional. "tags": { // optional. Tag values to set for the device registered "StringTag": "string value", "IntegerTag": 42, "ListTag": ["string1", "string2"], // sets the list of values for Tags of List type "DateTag": "2024-10-02 22:11", // note the time should be in UTC "BooleanTag": true // valid values are: true, false } }}注册 WhatsApp 设备
Anchor link to要为您的应用注册 WhatsApp 设备,请遵循以下指南:
-
hwid:确保此字段包含
whatsapp:前缀,后跟 E.164 格式的电话号码(例如,whatsapp:+0000000000)。该电话号码必须有效,Pushwoosh 将对此进行验证。 -
Push token:不需要推送令牌,因为
hwid将自动作为推送令牌。 -
device_type:将此字段设置为
21以指定 WhatsApp 为平台。
请求示例
Anchor link to{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "whatsapp:+0000000000", // required. WhatsApp prefix and valid phone number "timezone": 3600, // optional. Time offset in seconds "device_type": 21, // required. WhatsApp device type is 21 "language": "en", // optional. ISO 639-1|639-2 language code "userId": "Alex", // optional. User identifier "tags": { // optional. Tag values for custom segmentation "StringTag": "string value", "IntegerTag": 42, "ListTag": ["string1", "string2"], "DateTag": "2024-10-02 22:11", // UTC format "BooleanTag": true }, "app_version": "1.2.3", // optional. Application version "device_model": "Samsung SM-G355H", // optional. Device model "os_version": "2.3" // optional. Operating system version }}注册 SMS 设备
Anchor link to要为您的应用注册 SMS 设备,请遵循以下指南:
-
hwid:确保此字段包含 E.164 格式的电话号码(例如,
+0000000000)。该电话号码必须有效,Pushwoosh 将对此进行验证。 -
Push token:不需要推送令牌,因为
hwid将自动作为推送令牌。 -
device_type:将此必填字段设置为
18以指定 SMS 为平台。
请求示例
Anchor link to{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "+0000000000", // required. Valid phone number in E.164 format "timezone": 3600, // optional. Time offset in seconds "device_type": 18, // required. SMS device type is 18 "language": "en", // optional. ISO 639-1|639-2 language code "userId": "Alex", // optional. User identifier "tags": { // optional. Tag values for custom segmentation "StringTag": "string value", "IntegerTag": 42, "ListTag": ["string1", "string2"], "DateTag": "2024-10-02 22:11", // UTC format "BooleanTag": true }, "app_version": "1.2.3", // optional. Application version "device_model": "Samsung SM-G355H", // optional. Device model "os_version": "2.3" // optional. Operating system version }}状态码:
| HTTP 状态码 | status_code | 描述 |
|---|---|---|
| 200 | 200 | 设备注册成功 |
| 200 | 210 | 参数错误。请参阅 status_message 了解更多信息。 |
| 400 | N/A | 格式错误的请求字符串 |
| 500 | 500 | 内部错误 |
unregisterDevice
Anchor link toPOST https://api.pushwoosh.com/json/1.3/unregisterDevice
移除设备的推送令牌。未注册的设备仍计入总设备数,并可通过应用内消息触达。由 SDK 内部调用。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问设备 API 的 API 设备令牌。请将 XXXX 替换为您的实际设备 API 令牌。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application* | string | Pushwoosh 应用代码 |
| hwid* | string | 在 /registerDevice 请求中使用的 硬件设备 ID。 |
{ "status_code": 200, "status_message": "OK", "response": null}{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "8f65b16XXXXXe7a6beceXXXXX530fb2" // required. Hardware device ID used in /registerDevice API }}状态码:
| HTTP 状态码 | status_code | 描述 |
|---|---|---|
| 200 | 200 | 设备成功取消订阅 |
| 200 | 210 | 参数错误。请参阅 status_message 了解更多信息。 |
| 400 | N/A | 格式错误的请求字符串 |
| 500 | 500 | 内部错误 |
deleteDevice
Anchor link toPOST https://api.pushwoosh.com/api/v2/device-api/deleteDevice
删除应用程序内由指定 HWID 标识的设备及其所有关联数据。与仅移除推送令牌并保留设备记录的 /unregisterDevice 不同,/deleteDevice 会完全移除设备。该请求是异步处理的,一旦删除请求被接受处理,端点就会返回 200 OK。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问设备 API 的 API 设备令牌。请将 XXXX 替换为您的实际设备 API 令牌。 |
| Content-Type | 是 | application/json |
| 名称 | 必需 | 类型 | 描述 |
|---|---|---|---|
| application | 是 | string | Pushwoosh 应用代码 |
| hwid | 是 | string | 要删除的设备的 硬件设备 ID。 |
请求示例
Anchor link to{ "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "8f65b16df378e7a6bece9614e1530fb2" // required. Hardware device ID of the device to delete}响应示例
Anchor link to{ "status_code": 200, "status_message": "OK", "response": null}| HTTP 状态码 | status_code | 描述 |
|---|---|---|
| 200 | 200 | 删除请求已接受 |
| 200 | 210 | 参数错误。请参阅 status_message 了解更多信息。 |
| 400 | N/A | 格式错误的请求字符串 |
| 401 | N/A | 缺少或无效的 Authorization 令牌 |
| 500 | 500 | 内部错误 |
setTags
Anchor link toPOST https://api.pushwoosh.com/json/1.3/setTags
为设备设置标签值。由 SDK 调用。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问设备 API 的 API 设备令牌。请将 XXXX 替换为您的实际设备 API 令牌。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application* | string | Pushwoosh 应用代码 |
| hwid* | string | 在 /registerDevice 请求中使用的 硬件设备 ID。 |
| tags* | object | 要设置的标签的 JSON 对象,发送 “null” 以移除值。 |
{ "status_code": 200, "status_message": "OK", "response": null}{ "request":{ "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "8f65b16XXXXXe7a6becXXXXXe1530fb2", // required. Hardware device ID used in /registerDevice API "tags": { // required. "StringTag": "string value", "IntegerTag": 42, "ListTag": ["string1", "string2"], // sets the list of values for Tags of List type "DateTag": "2024-10-02 22:11", // note the time is in UTC "BooleanTag": true // valid values are - true, false } }}递增整数标签值
Anchor link to要递增整数标签的值,请按如下方式使用带有 “increment” 值的 operation 参数:
{ "request":{ "application": "12345-67890", // required. Pushwoosh application code "hwid": "21AB7628-XXXX-XXXX-CCC0-PO287CS24CA4", // required. hardware device ID used in /registerDevice API "tags": { // required. "Level": { // Tag name "operation": "increment", // overwrites the integer tag in increments of the following value "value": 1 // increment for the tag value } } }}递减整数标签值
Anchor link to要递减,请使用负数作为 “increment” 操作的值(-1, -2, -3,-n):
{ "request":{ "application": "12345-67890", // required. Pushwoosh application code "hwid": "21AB7628-XXXX-XXXX-CCC0-PO287CS24CA4", // required. Hardware device ID used in /registerDevice API "tags": { // required "Level": { // Tag name "operation": "increment", // overwrites the integer tag in decrement of the following value "value": -1 // decrement for the tag value } } }}附加列表标签值
Anchor link to要使用新值扩展列表标签,请按如下方式使用带有 “append” 值的 operation 参数:
{ "request": { "hwid": "3d124a79XXXXf189XXXX7dfd9XXXXafd", // required. Hardware device ID used in /registerDevice API "application": "6XXXX-XXXX3", // required. Pushwoosh application code "tags": { // required. "ListTag": { // Tag name "operation": "append", // appends following values to the Tag's list of values "value": [ // values to append "tag2", "tag3" ] } } }}移除列表标签值
Anchor link to要从列表标签中移除某些值,请按如下方式使用 “remove” 操作:
{ "request":{ "application": "12345-67890", // required. Pushwoosh application code "hwid": "21AB7628-XXXX-XXXX-CCC0-PO287CS24CA4", // required. Hardware device ID used in /registerDevice API "tags": { // required. "In-App Product": { // Tag name "operation": "remove", // removes the following values from the list tag "value": "outwear_02" // value or values to remove } } }}按 UserID 设置标签
Anchor link to要为与特定 User ID 关联的所有设备设置标签,请使用 “userId” 参数而不是 “hwid”。
{ "request":{ "application": "AAAAA-BBBBB", // Pushwoosh app code "userId": "some_user", // user ID you'd like to set tags for "tags": { // tags and values to set "Language": "es" } }}状态码:
| HTTP 状态码 | status_code | 描述 |
|---|---|---|
| 200 | 200 | 标签已成功设置 |
| 200 | 210 | 参数错误。请参阅 status_message 了解更多信息。 |
| 400 | N/A | 格式错误的请求字符串 |
| 500 | 500 | 内部错误 |
getTags
Anchor link toPOST https://api.pushwoosh.com/json/1.3/getTags
检索特定设备的标签列表及其对应值。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问设备 API 的 API 设备令牌。请将 XXXX 替换为您的实际设备 API 令牌。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application* | string | Pushwoosh 应用代码 |
| userId | string | 要使用的 User ID,而非 “hwid”。如果与 “hwid” 一起使用,则 “hwid” 优先。 |
| hwid | string | 在 /registerDevice 请求中使用的 硬件设备 ID。 |
{ "status_code": 200, "status_message": "OK", "response": { "result": { "Language": "fr" } }}{ "request":{ "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "HWID", // optional. Hardware device ID used in /registerDevice API "userId": "USER_ID" // optional. Can be used instead of "hwid" to retrieve tags for a specific user }}setBadge
Anchor link toPOST https://api.pushwoosh.com/json/1.3/setBadge
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问设备 API 的 API 设备令牌。请将 XXXX 替换为您的实际设备 API 令牌。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application* | string | Pushwoosh 应用代码 |
| hwid* | string | 在 /registerDevice 请求中使用的 硬件设备 ID。 |
| badge* | integer | 应用程序上的当前角标。 |
{ "status_code": 200, "status_message": "OK"}{ "request":{ "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "8f65b16dXXXXe7a6XXXX9614XXXX0fb2", // required. Hardware device ID used in /registerDevice API "badge": 4 // required. Current badge on the application }}此方法不用于更新设备上的角标值。请改用带有 "ios_badges" 参数的 /createMessage 请求。
applicationOpen
Anchor link toPOST https://api.pushwoosh.com/json/1.3/applicationOpen
注册应用打开事件。由 SDK 内部调用。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问设备 API 的 API 设备令牌。请将 XXXX 替换为您的实际设备 API 令牌。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application* | string | Pushwoosh 应用代码 |
| hwid* | string | 在 /registerDevice 请求中使用的 硬件设备 ID。 |
{ "status_code": 200, "status_message": "OK"}{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "8f65b16dXXXXe7a6XXXX9614eXXXXfb2" // required. Hardware device ID used in /registerDevice API }}pushStat
Anchor link toPOST https://api.pushwoosh.com/json/1.3/pushStat
注册推送打开事件。由 SDK 内部调用。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问设备 API 的 API 设备令牌。请将 XXXX 替换为您的实际设备 API 令牌。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application* | string | Pushwoosh 应用代码 |
| hwid* | string | 在 /registerDevice 请求中使用的 硬件设备 ID。 |
| userId | string | 要与推送打开事件关联的 User ID。 |
| hash | string | 在推送通知中收到的哈希标签(推送有效负载的 “p” 参数)。 |
{ "status_code": 200, "status_message": "OK", "response": null}{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "8f65b16dfXXXX7a6beXXXX14e1530fb2", // required. Hardware device ID used in /registerDevice API "userId": "USER012345", // optional. The user id to associate with the push open event "hash": "HASH_TAG" // optional. Hash tag received in push notification // ("p" parameter in the push payload) }}messageDeliveryEvent
Anchor link toPOST https://api.pushwoosh.com/json/1.3/messageDeliveryEvent
为设备注册推送送达事件。由 SDK 内部调用。
| 名称 | 必需 | 值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Token XXXX | 用于访问设备 API 的 API 设备令牌。请将 XXXX 替换为您的实际设备 API 令牌。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| application* | string | Pushwoosh 应用代码 |
| hwid* | string | 在 /registerDevice 请求中使用的 硬件设备 ID。 |
| hash | string | 在推送通知中收到的哈希标签(推送有效负载的 “p” 参数)。 |
{ "status_code": 200, "status_message": "OK", "response": null} { "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "hwid": "8f65b16dfXXXX7a6bece9XXXX1530fb2", // required. Hardware device ID used in /registerDevice API "hash": "HASH_TAG" // optional. Hash tag received in push notification // ("p" parameter in the push payload) }}