Skip to content

ライブアクティビティを更新

post

/messages/live_activity/update

このエンドポイントを使用して、iOS アプリに表示されるライブアクティビティを更新および終了します。このエンドポイントには追加の設定が必要です。

ライブアクティビティを登録したら、JSON ペイロードを渡して Apple プッシュ通知サービス (APN) を更新できます。詳細については、プッシュ通知ペイロードによるライブアクティビティの更新に関するAppleのドキュメントを参照してください

前提条件

このエンドポイントを使用するには、以下を完了する必要があります。

レート制限

We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in API rate limits.

リクエスト本文

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."
 }

リクエストパラメーター

パラメーター 必須 データ型 説明
app_id 必須 文字列 API [キーページから取得したアプリ API](/docs/ja/user_guide/administrative/app_settings/api_settings_tab/) 識別子
activity_id 必須 文字列 を使用してライブアクティビティを登録する場合launchActivitypushTokenTagパラメータを使用してアクティビティのプッシュトークンにカスタム文字列という名前を付けます。

activity_idこのカスタム文字列に設定して、更新するライブアクティビティを定義します。
content_state 必須 オブジェクト ContentState ライブアクティビティを作成するときにパラメーターを定義します。ContentStateこのオブジェクトを使用する際に、更新された値を渡してください。

このリクエストの形式は、最初に定義した形状と一致する必要があります。
end_activity オプション Boolean true もし、このリクエストはライブアクティビティを終了します。
dismissal_date オプション 日時
(ISO-8601文字列)
このパラメータは、ライブアクティビティをユーザーのUIから削除する時間を定義します。end_activityこの時間が過去のものであればtrue、ライブアクティビティはすぐに削除されます。

falseまたは省略した場合、end_activityこのパラメーターはライブアクティビティのみを更新します。
stale_date オプション 日時
ISO-8601文字列
このパラメータは、ライブアクティビティのコンテンツがユーザーのUIで古くなっているとマークされたときにシステムに通知します。
notification オプション オブジェクト apple_pushプッシュ通知を定義するオブジェクトを含めます。このプッシュ通知のこの動作は、ユーザーがアクティブか、ユーザーがプロキシデバイスを使用しているかによって異なります。
  • 通知が含まれていて、アップデートが配信されたときにユーザーが iPhone でアクティブになっている場合、更新された Live Activity UI が下にスライドしてプッシュ通知のように表示されます。
  • 通知が含まれていてユーザーがiPhoneでアクティブでない場合、画面が点灯し、ロック画面に更新されたLive Activity UIが表示されます。
  • 通知アラートは標準のプッシュ通知としては表示されません。さらに、ユーザーがApple Watchなどのプロキシデバイスを持っている場合は、そこにアラートが表示されます

リクエスト例

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との 2 つのステータスコード応答があります4XX

成功レスポンスの例

リクエストが正しくフォーマットされ、リクエストを受け取った場合は、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' "
}
「このページはどの程度役に立ちましたか?」
New Stuff!