# iOS 인터랙티브 푸시 생성

iOS 8에서는 사용자가 알림 배너에서 직접 작업을 수행할 수 있는 인터랙티브 알림을 도입했습니다. Pushwoosh는 이제 **iOS 카테고리**를 제공하여 Pushwoosh 제어판 내에서 사용자 지정 버튼을 생성할 수 있습니다. [자세히 알아보기](/ko/product/messaging-channels/push-notifications/advanced-push-features/ios-interactive-push)

## API

애플리케이션이 [`registerDevice`](/ko/developer/api-reference/device-api/#registerdevice)를 호출하면 Pushwoosh API는 사용 가능한 카테고리 목록과 각 버튼에 대한 세부 정보가 포함된 응답을 다음과 같이 반환합니다:

```json
{
  "status_code": 200,
  "status_message": "OK",
  "response": {
    "iosCategories": [
      {
        "categoryId": 65,
        "buttons": [
          {
            "id": 0,
            "label": "Rate",
            "type": "1",
            "startApplication": 1
          },
          {
            "id": 1,
            "label": "Later",
            "type": "0",
            "startApplication": 0
          }
        ]
      }
    ]
  }
}
```

이러한 카테고리는 이제 기기에서 사용할 수 있으므로 메시지가 도착하고 애플리케이션이 포그라운드에서 실행되고 있지 않을 때 올바르게 표시될 수 있습니다.

Pushwoosh Journey에서 카테고리와 함께 푸시를 보내려면 메시지를 작성하는 동안 iOS 플랫폼 설정에서 해당 카테고리를 선택하기만 하면 됩니다. Pushwoosh API를 통해 원격으로 푸시를 보내는 경우, [`createMessage`](/ko/developer/api-reference/messages-api/#createmessage) 요청에서 `ios_category` 파라미터에 해당하는 카테고리 ID를 값으로 사용해야 합니다:

```json
{
  "categoryId": 65  // 선택 사항. 문자열 값. Pushwoosh의 iOS8 카테고리 ID
}
```

카테고리 ID가 포함된 푸시 메시지가 도착하면 Pushwoosh SDK는 이 카테고리에 포함된 버튼 세트와 함께 알림을 표시합니다.

## Pushwoosh iOS SDK의 버튼 및 액션

앱을 열 때 다양한 액션을 수행하려면 사용자 지정 `UNUserNotificationCenterDelegate` 구현을 생성하고 `didReceiveNotificationResponse` 메서드를 재정의해야 합니다:

#### CustomDelegate


```swift
class CustomDelegate: NSObject, UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let identifier = response.actionIdentifier
        let category = response.notification.request.content.categoryIdentifier

        if category == "10212" {
            if identifier == "1" {
                // 작업 수행
            } else {
                // 다른 작업 수행
            }
        }

        completionHandler()
    }
}
```

여기서 `identifier`는 버튼 ID이고 `category`는 알림 페이로드에서 파생됩니다.

그런 다음 이 클래스의 인스턴스를 생성하고 프록시 메서드를 사용하여 Pushwoosh SDK에 전달합니다:

#### AppDelegate

```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    Pushwoosh.configure.registerForPushNotifications()

    let customDelegate = CustomDelegate()
    Pushwoosh.configure.addNotificationCenterDelegate(customDelegate)

    return true
}
```

<img src="/messaging-channels-ios-interactive-push-1.png" alt="알림 배너에 표시된 사용자 지정 액션 버튼이 있는 iOS 인터랙티브 푸시 알림"/>