ライブアクティビティを更新
/messages/live_activity/update
このエンドポイントを使用して、iOSアプリが表示するライブアクティビティを更新および終了します。このエンドポイントには追加のセットアップが必要です。
ライブアクティビティを登録した後、Apple Push Notification service(APNs)を更新するためにJSONペイロードを渡すことができます。詳しくは、プッシュ通知ペイロードを使ったライブアクティビティの更新に関するAppleのドキュメントを参照してください。
content-availableが設定されていない場合、Apple Push Notification service(APNs)のデフォルトの優先度は10です。content-availableが設定されている場合、この優先度は5になります。詳細はAppleプッシュオブジェクトを参照してください。
前提条件
このエンドポイントを使用するには、以下を完了する必要があります。
最終的にレンダリングされたペイロードが、対応するサービスの最大許容サイズより大きい場合、送信は成功しない。
レート制限
APIレート制限に記載されているように、このエンドポイントにはデフォルトのBrazeレート制限(1時間あたり250,000リクエスト)が適用されます。
リクエスト本文
1
2
3
4
5
6
7
8
9
{
"app_id": "(required, string) App API identifier retrieved from the Developer Console.",
"activity_id": "(required, string) When you register your Live Activity using launchActivity, you use the pushTokenTag parameter to name the Activity’s push token to a custom string. Set activity_id to this custom string to define which Live Activity you want to update.",
"content_state": "(required, object) You define the ContentState parameters when you create your Live Activity. Pass the updated values for your ContentState using this object. The format of this request must match the shape you initially defined.",
"end_activity": "(optional, boolean) If true, this request ends the Live Activity.",
"dismissal_date": "(optional, datetime in ISO-8601 format) The time to remove the Live Activity from the user’s UI. If this time is in the past, the Live Activity will be removed immediately.",
"stale_date": "(optional, datetime in ISO-8601 format) The time the Live Activity content is marked as outdated in the user’s UI.",
"notification": "(optional, object ) Include an `apple_push` object to define a push notification that creates an alert for the user."
}
Request parameters
| Parameter | Required | Data Type | Description |
|---|---|---|---|
app_id |
Required | String | App API identifier retrieved from the API Keys page. |
activity_id |
Required | String | When you register your Live Activity using launchActivity, you use the pushTokenTag parameter to name the Activity’s push token to a custom string.Set activity_id to this custom string to define which Live Activity you want to update. |
content_state |
Required | Object | You define the ContentState parameters when you create your Live Activity. Pass the updated values for your ContentState using this object.The format of this request must match the shape you initially defined. |
end_activity |
Optional | Boolean | If true, this request ends the Live Activity. |
dismissal_date |
Optional | Datetime (ISO-8601 string) |
This parameter defines the time to remove the Live Activity from the user’s UI. If this time is in the past and end_activity is true, the Live Activity will be removed immediately.If end_activity is false or omitted, this parameter only updates the Live Activity. |
stale_date |
Optional | Datetime (ISO-8601 string) |
This parameter tells the system when the Live Activity content is marked as outdated in the user’s UI. |
notification |
Optional | Object | Include an apple_push object to define a push notification. The behavior of this push notification depends on if the user is active or if the user is using a proxy device.
|
Example request
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
curl --location --request POST 'https://rest.iad-01.braze.com/messages/live_activity/update' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {YOUR-REST-API-KEY}' \
--data-raw '{
"app_id": "{YOUR-APP-API-IDENTIFIER}",
"activity_id": "live-activity-1",
"content_state": {
"teamOneScore": 2,
"teamTwoScore": 4
},
"end_activity": false,
"dismissal_date": "2023-02-28T00:00:00+0000",
"stale_date": "2023-02-27T16:55:49+0000",
"notification": {
"alert": {
"body": "It's halftime! Let's look at the scores",
"title": "Halftime"
}
}
}'
応答
このエンドポイントには201と4XXの2つのステータスコード応答があります。
成功応答の例
リクエストが正しくフォーマットされ、受信された場合、201ステータスコードが返されます。ステータスコード201は、次の応答本文を返す可能性があります。
1
2
3
{
"message": "success"
}
エラー応答の例
4XXクラスのステータスコードはクライアントエラーを示します。発生する可能性のあるエラーの詳細については、APIエラーと応答の記事を参照してください。
ステータスコード400は、次の応答本文を返す可能性があります。
1
2
3
{
"error": "\nProblem:\n message body does not match declared format\nResolution:\n when specifying application/json as content-type, you must pass valid application/json in the request's 'body' "
}