# iOS Live Activities API

> Apple 문서:
> 
> * [Live Activities에 대하여](https://developer.apple.com/design/human-interface-guidelines/live-activities)
> * [ActivityKit 푸시 알림으로 Live Activities 업데이트 및 종료하기](https://developer.apple.com/documentation/activitykit/updating-and-ending-your-live-activity-with-activitykit-push-notifications)



## startLiveActivity



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

iOS Live Activities를 생성할 수 있습니다.

### 요청 본문

| 매개변수      | 타입   | 필수/선택 | 설명                                                                        |
|---------------|--------|-----------|-----------------------------------------------------------------------------|
| application   | String | 필수      | [Pushwoosh 애플리케이션 코드](/ko/developer/api-reference/api-identifiers/#application-code)                                             |
| auth          | String | 필수      | Pushwoosh Control Panel의 [API 액세스 토큰](/ko/developer/api-reference/api-identifiers/#api-access-token)입니다.                          |
| notifications | Array  | 필수      | 메시지 매개변수의 JSON 배열입니다. 자세한 내용은 아래 Notifications 표를 참조하세요. |

#### Notifications
`notifications` 배열에 사용되는 매개변수:

| 매개변수         | 타입             | 필수/선택 | 설명                                                                                                                                                             |
|------------------|------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| content          | String           | 필수      | Live Activity를 지원하지 않는 iOS 16.1 미만 버전의 기기를 위한 대체 콘텐츠입니다. iOS 16.1 이상(Live Activity 지원)에서는 `live_activity` 필드에서 콘텐츠를 가져옵니다. |
| title            | String           | 선택      | 알림 메시지의 제목입니다.                                                                                                                                        |
| live_activity    | Object           | 필수      | iOS에서 Live Activity를 생성하기 위한 Live Activity 데이터입니다.                                                                                                |
| live_activity.content-state    | Object           | 필수      | Live Activity 알림의 콘텐츠입니다.                                                                                                                 |
| live_activity.attributes-type  | String           | 필수      | Live Activity에 사용되는 속성의 유형입니다.                                                                                                        |
| live_activity.attributes       | Object           | 필수      | Live Activity의 속성입니다.                                                                                                                        |
| live_activity_id | String           | 필수      | Live Activity의 고유 식별자입니다. `updateLiveActivity`를 호출할 때 이 활동을 대상으로 지정하는 데 사용됩니다. 활동 세션당 고유해야 합니다.                          |
| filter           | String           | 선택      | Pushwoosh 필터(세그먼트)의 이름입니다. [세그먼트 / 필터 이름](/ko/developer/api-reference/api-identifiers/#segment--filter-name)을 참조하세요. 이 필터와 일치하는 모든 기기에서 Live Activity가 시작됩니다. |
| devices          | Array of Strings | 선택      | [기기 토큰](/ko/developer/api-reference/api-identifiers/#push-token) 목록입니다. 지정된 기기에서만 Live Activity가 시작됩니다.                                         |



### 요청 예시

<Tabs>
<TabItem label="필터 사용">
```json
{
  "request": {
    "application": "XXXXX-XXXXX",
    "auth": "SECRET_API_TOKEN",
    "notifications": [
      {
        "content": "Your order is being prepared",
        "title": "Food Delivery",
        "live_activity": {
          "event": "start",
          "title": "Order status",
          "content-state": {
            "status": "Third",
            "estimatedTime": "37 min",
            "emoji": "👨‍🍳"
          },
          "attributes-type": "FoodDeliveryAttributes",
          "attributes": {}
        },
        "live_activity_id": "FIRST_LIVE_ACTIVITY",
        "filter": "FILTER_NAME_1"
      }
    ]
  }
}
```
</TabItem>
<TabItem label="기기 사용">
```json
{
  "request": {
    "application": "XXXXX-XXXXX",
    "auth": "SECRET_API_TOKEN",
    "notifications": [
      {
        "content": "Your order is being prepared",
        "title": "Food Delivery",
        "live_activity": {
          "event": "start",
          "title": "Order status",
          "content-state": {
            "status": "Third",
            "estimatedTime": "37 min",
            "emoji": "👨‍🍳"
          },
          "attributes-type": "FoodDeliveryAttributes",
          "attributes": {}
        },
        "live_activity_id": "SECOND_LIVE_ACTIVITY",
        "devices": ["first_third", "second_device"]
      }
    ]
  }
}
```
</TabItem>
</Tabs>

### 응답 예시

```json
{
  "status_code": 200,
  "status_message": "OK",
  "response": {
    "Messages": [
      "XXXXX-XXXXXXXX-XXXXXXXX"
    ]
  }
}
```
> **참고:**
> 
> Pushwoosh iOS SDK를 사용하여 Live Activities로 작업하는 방법에 대해 자세히 알아보려면 [이 문서](/ko/developer/pushwoosh-sdk/ios-sdk/ios-live-activities)를 읽어보세요.


## updateLiveActivity


`POST` `https://api.pushwoosh.com/json/1.3/updateLiveActivity`

iOS Live Activities를 업데이트하고 종료할 수 있습니다.

### 요청 본문

| 매개변수       | 타입   | 필수/선택 | 설명                                                                        |
|----------------|--------|-----------|-----------------------------------------------------------------------------|
| auth           | String | 필수      | Pushwoosh Control Panel의 [API 액세스 토큰](/ko/developer/api-reference/api-identifiers/#api-access-token)입니다.                      |
| application    | String | 필수      | [Pushwoosh 애플리케이션 코드](/ko/developer/api-reference/api-identifiers/#application-code)                                       |
| notifications  | Array  | 필수      | 메시지 매개변수의 JSON 배열입니다. 자세한 내용은 아래 Notifications 표를 참조하세요. |

#### Notifications

`notifications` 배열에 사용되는 매개변수:

| 매개변수         | 타입    | 필수/선택 | 설명                                                                                                                                                             |
|------------------|---------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| live_activity    | Object  | 필수      | iOS에서 Live Activity를 업데이트하기 위한 Live Activity 데이터입니다.                                                                                            |
| live_activity.event            | String  | 필수      | 이벤트 유형을 지정합니다. Live Activity를 업데이트하려면 `"update"`를 사용하고, 종료하려면 `"end"`를 사용하세요.                                       |
| live_activity.content-state    | Object  | 필수      | 콘텐츠를 업데이트하기 위해 Live Activity에 데이터를 전달하는 데 사용되는 키-값 쌍을 가진 객체입니다.                                                  |
| live_activity.dismissal-date   | Integer | 선택      | Live Activity가 종료되어야 하는 시간(초)입니다.                                                                                                    |
| live_activity_id | String  | 필수      | 업데이트할 Live Activity의 고유 식별자입니다. **startLiveActivity**에서 사용된 `live_activity_id`와 일치해야 합니다. 업데이트는 이 활동이 시작된 모든 기기에 전달됩니다. |
| live_activity.relevance-score  | Integer | 선택      | 어떤 Live Activity가 다른 것보다 높은 우선순위를 갖는지 iOS 시스템에 알립니다. 1부터 무한대까지의 값을 허용합니다(100까지의 값을 권장합니다).             |
| live_activity.stale-date       | Integer | 선택      | Live Activity가 오래되거나 만료되는 날짜를 나타내는 시간(초)입니다.                                                                                |


### 요청 예시

```json

{
  "request": {
    "application": "XXXXX-XXXXX",
    "auth": "SECRET_API_TOKEN",
    "notifications": [
      {
        "live_activity": {
          "event": "update",
          "title": "Live Activity Update",
          "content-state": {
            "status": "second 66",
            "estimatedTime": "66 min",
            "emoji": "👨‍"
          },
          "relevance-score": 60
        },
        "live_activity_id": "FIRST_LIVE_ACTIVITY"
      }
    ]
  }
}
```

### 응답 예시

```json
{
  "status_code": 200,
  "status_message": "OK",
  "response": {
    "Messages": [
      "XXXXX-XXXXXXXX-XXXXXXXX"
    ]
  }
}
```

> Pushwoosh iOS SDK를 사용하여 Live Activities로 작업하는 방법에 대해 자세히 알아보려면 [이 문서](/ko/developer/pushwoosh-sdk/ios-sdk/ios-live-activities/)를 읽어보세요.


## 기기당 여러 활동

`startLiveActivity`를 다른 `live_activity_id` 값으로 여러 번 호출하여 동일한 기기에서 여러 Live Activities를 시작할 수 있습니다.

예를 들어, `filter: FILTER_NAME_1`을 사용하는 `FIRST_LIVE_ACTIVITY`와 `filter: FILTER_NAME_2`를 사용하는 `SECOND_LIVE_ACTIVITY` 두 활동을 시작하면, 두 필터에 모두 일치하는 기기에서는 두 활동이 동시에 실행됩니다.

그중 하나를 업데이트하려면 해당 `live_activity_id`를 `updateLiveActivity`에 전달합니다. 업데이트는 해당 활동이 생성된 모든 기기에 전달됩니다. 다른 활동은 영향을 받지 않습니다.

`relevance-score` 매개변수는 동일한 기기에서 여러 Live Activities가 활성화되어 있을 때 표시 우선순위를 제어합니다. 화면 공간이 제한적이거나 활동이 그룹화된 경우, 더 높은 값을 가진 활동이 더 높은 우선순위로 표시됩니다.