콘텐츠로 건너뛰기

iOS 대화형 푸시 생성

iOS 8에서는 사용자가 알림 배너에서 직접 작업을 수행할 수 있는 대화형 알림을 도입했습니다. 이제 Pushwoosh는 iOS 카테고리를 제공하여 Pushwoosh 제어판 내에서 사용자 지정 버튼을 만들 수 있습니다. 자세히 알아보기

애플리케이션이 registerDevice를 호출하면 Pushwoosh API는 사용 가능한 카테고리 목록과 각 버튼의 ID 및 세부 정보가 포함된 응답을 다음과 같이 반환합니다:

{
"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 요청에서 ios_category 매개변수를 해당 카테고리 ID 값과 함께 사용해야 합니다:

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

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

Pushwoosh iOS SDK의 버튼 및 작업

Anchor link to

앱을 열 때 다양한 작업을 수행하려면 사용자 지정 UNUserNotificationCenterDelegate 구현을 만들고 didReceiveNotificationResponse 메서드를 재정의해야 합니다:

CustomDelegate

Anchor link to
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

Anchor link to
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Pushwoosh.sharedInstance().registerForPushNotifications()
let customDelegate = CustomDelegate()
Pushwoosh.sharedInstance().notificationCenterDelegateProxy?.add(customDelegate)
return true
}
알림 배너에 표시된 사용자 지정 작업 버튼이 있는 iOS 대화형 푸시 알림