Skip to content

실시간 활동 업데이트

post

/messages/live_activity/update

이 엔드포인트를 사용하여 iOS 앱에 표시되는 실시간 활동을 업데이트하고 종료할 수 있습니다. 이 엔드포인트에는 추가 설정이 필요합니다.

실시간 활동을 등록한 후 JSON 페이로드를 전달하여 Apple 푸시 알림 서비스(APNs)를 업데이트할 수 있습니다. 자세한 내용은 푸시 알림 페이로드로 실시간 활동 업데이트하기에 대한 Apple 설명서를 참조하세요.

content-available이 설정되지 않은 경우 기본 Apple 푸시 알림 서비스(APNs) 우선순위는 10입니다. content-available이 설정된 경우 이 우선순위는 5입니다. 자세한 내용은 Apple 푸시 오브젝트를 참조하세요.

필수 조건

이 엔드포인트를 사용하려면 다음을 완료해야 합니다:

  • messages.live_activity.update 권한으로 API 키를 생성합니다.
  • Braze Swift SDK를 사용하여 실시간 활동을 원격 또는 로컬로 등록합니다.

사용량 제한

이 엔드포인트에는 API 사용량 제한 설명서에 명시된 대로 기본 Braze 사용량 제한인 시간당 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.
  • If a notification is included and the user is active on their iPhone when the update is delivered, the updated Live Activity UI will slide down and display like a push notification.
  • If a notification is included and the user is not active on their iPhone, their screen will light up to display the updated Live Activity UI on their lock screen.
  • The notification alert will not display as a standard push notification. Additionally, if a user has a proxy device, like an Apple Watch, the alert will be displayed there.

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

응답

이 엔드포인트에 대한 상태 코드 응답은 2014XX 두 가지입니다.

성공 응답 예시

요청 형식이 올바르게 지정되어 요청을 수신한 경우 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!