iOS Live Activities API
Apple 文档:
startLiveActivity
Anchor link to使用此方法创建 iOS Live Activities。
POST https://api.pushwoosh.com/json/1.3/startLiveActivity
允许创建 iOS Live Activities。
| 参数 | 类型 | 必填/可选 | 描述 |
|---|---|---|---|
| application | String | 必填 | Pushwoosh Application code |
| auth | String | 必填 | 来自 Pushwoosh 控制面板的 API Access token。 |
| notifications | Array | 必填 | 消息参数的 JSON 数组。查看下方 Notifications 表格中的详细信息。 |
Notifications
Anchor link tonotifications 数组中使用的参数:
| 参数 | 类型 | 必填/可选 | 描述 |
|---|---|---|---|
| content | String | 必填 | 运行 iOS 版本低于 16.1 且不支持 Live Activity 的设备的回退内容。在 iOS 16.1+(支持 Live Activity)上,内容来源于 live_activity 字段。 |
| title | String | 可选 | 通知消息的标题。 |
| live_activity | Object | 必填 | 用于在 iOS 中创建 Live Activity 的 Live Activity 数据。 |
| content-state | Object | 必填 | Live Activity 通知的内容。 |
| attributes-type | String | 必填 | Live Activity 中使用的属性类型。 |
| attributes | Object | 必填 | Live Activity 的属性。 |
| live_activity_id | String | 必填 | Live Activity 的唯一 ID,由用户创建。 |
| filter_code | String | 可选 | Filter (Segment) code 用于定位特定的受众细分。 |
| devices | Array of strings | 可选 | Tokens 或 HWIDs 用于发送定向推送通知,最多 1000 个。如果设置,消息将仅发送给列表中的设备。注意: 不允许为设备列表使用 Application Group,且 iOS push tokens 必须为小写。 |
| users | Array of strings | 可选 | 如果设置,消息将仅发送给指定的 User ID(通过 /registerUser 调用分配)。数组中最多包含 1000 个 User ID。注意: 如果与 devices 参数一起使用,users 参数将优先。不允许为用户列表使用 Application Group。 |
200
{ "status_code": 200, "status_message": "OK", "response": { "Messages": [ "C3F8-C3863ED4-334AD4F1" ] }}请求示例
Anchor link to{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "live_activity": { // required. Live Activity data to create Live Activity in iOS "content-state": { "emoji": ":wink:" }, "attributes-type": "LiveActivityAttributes", "attributes": { "name": "Apple" } }, "live_activity_id": "unique UUID", // optional. Unique identifier of the Live Activity. "filter_code": "FILTER_NAME", // optional. Specify filter. "devices": [ // optional. Specify tokens or hwids to send targeted push "hwid_XXXX" // notifications. Not more than 1000 tokens/hwids in ], // an array. If set, the message will only be sent to // the devices on the list. Application Group for // devices list is not allowed. // iOS push tokens can only be lower case. "users": [ // optional. If set, message will only be delivered to the specified "user_XXXX" // user ID's (set via /registerUser call). If specified ] // together with devices parameter, the latter will be // ignored. Not more than 1000 user ID's in an array. // Application Group for users list is not allowed. }] }}注意:
阅读 这篇文章 以了解有关使用 Pushwoosh iOS SDK 处理 Live Activities 的更多信息。
updateLiveActivity
Anchor link to使用此方法管理 iOS Live Activities。
POST https://api.pushwoosh.com/json/1.3/updateLiveActivity
允许创建和管理 iOS Live Activities。
| 参数 | 类型 | 必填/可选 | 描述 |
|---|---|---|---|
| auth | String | 必填 | 来自 Pushwoosh 控制面板的 API Access token。 |
| application | String | 必填 | Pushwoosh Application code |
| notifications | Array | 必填 | 消息参数的 JSON 数组。查看下方 Notifications 表格中的详细信息。 |
Notifications
Anchor link tonotifications 数组中使用的参数:
| 参数 | 类型 | 必填/可选 | 描述 |
|---|---|---|---|
| live_activity | Object | 必填 | 用于在 iOS 中更新 Live Activity 的 Live Activity 数据。 |
| event | String | 必填 | 指定事件类型。使用 "update" 更新 Live Activity 或使用 "end" 关闭它。 |
| content-state | Object | 必填 | 包含键值对的对象,用于将数据传递给 Live Activity 以更新其内容。 |
| dismissal-date | Integer | 可选 | Live Activity 应结束的时间(以秒为单位)。 |
| live_activity_id | String | 必填 | 正在更新的 Live Activity 的唯一标识符。 |
| stale-date | Integer | 可选 | 表示 Live Activity 变为过时(stale)或过期的时间(以秒为单位)。 |
{ "status_code": 200, "status_message": "OK", "response": { "Messages": [ "C3F8-C3863ED4-334AD4F1" ] }}请求示例
Anchor link to{ "request": { "application": "XXXXX-XXXXX", // required. Pushwoosh application code "auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel "notifications": [{ "live_activity": { // required. Live Activity data to update Live Activity in iOS "event": "update", // required. Use "update" to update Live Activity or // "end" to close Live Activity "content-state": { // required. Object with key-value pairs used to pass data "courierName": "NUMBER: 15", // to Live Activity for updating its content "deliveryStatus": "Done" }, "dismissal-date": 12345678, // optional. Time of ending Live Activity in seconds "stale-date": 23456789 // optional. Time (in seconds) when Live Activity becomes stale }, "live_activity_id": "unique UUID" // optional. Unique identifier of the Live Activity. }] }}阅读这篇文章 以了解有关使用 Pushwoosh iOS SDK 处理 Live Activities 的更多信息。