跳到内容

iOS Live Activities API

Apple 文档:

startLiveActivity

Anchor link to

使用此方法创建 iOS Live Activities。

POST https://api.pushwoosh.com/json/1.3/startLiveActivity

允许创建 iOS Live Activities。

参数类型必填/可选描述
applicationString必填Pushwoosh Application code
authString必填来自 Pushwoosh 控制面板的 API Access token
notificationsArray必填消息参数的 JSON 数组。查看下方 Notifications 表格中的详细信息。

Notifications

Anchor link to

notifications 数组中使用的参数:

参数类型必填/可选描述
contentString必填运行 iOS 版本低于 16.1 且不支持 Live Activity 的设备的回退内容。在 iOS 16.1+(支持 Live Activity)上,内容来源于 live_activity 字段。
titleString可选通知消息的标题。
live_activityObject必填用于在 iOS 中创建 Live Activity 的 Live Activity 数据。
content-stateObject必填Live Activity 通知的内容。
attributes-typeString必填Live Activity 中使用的属性类型。
attributesObject必填Live Activity 的属性。
live_activity_idString必填Live Activity 的唯一 ID,由用户创建。
filter_codeString可选Filter (Segment) code 用于定位特定的受众细分。
devicesArray of strings可选TokensHWIDs 用于发送定向推送通知,最多 1000 个。如果设置,消息将仅发送给列表中的设备。注意: 不允许为设备列表使用 Application Group,且 iOS push tokens 必须为小写。
usersArray 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。

参数类型必填/可选描述
authString必填来自 Pushwoosh 控制面板的 API Access token
applicationString必填Pushwoosh Application code
notificationsArray必填消息参数的 JSON 数组。查看下方 Notifications 表格中的详细信息。

Notifications

Anchor link to

notifications 数组中使用的参数:

参数类型必填/可选描述
live_activityObject必填用于在 iOS 中更新 Live Activity 的 Live Activity 数据。
eventString必填指定事件类型。使用 "update" 更新 Live Activity 或使用 "end" 关闭它。
content-stateObject必填包含键值对的对象,用于将数据传递给 Live Activity 以更新其内容。
dismissal-dateInteger可选Live Activity 应结束的时间(以秒为单位)。
live_activity_idString必填正在更新的 Live Activity 的唯一标识符。
stale-dateInteger可选表示 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 的更多信息。