iOS 푸시 알림 원클릭 수신거부 구현 가이드 (category이용)
안녕하세요, 핑거푸시 기술지원팀입니다. 광고성 정보가 포함된 푸시 메시지 발송 시, 사용자 편의성을 높이고 규정을 준수하기 위해 알림 창에서 즉시 수신거부를 할 수 있는 '원클릭 수신거부' 기능 구현 방법을 안내해 드립니다.
1. 개요
2. 주요 설정 내용
3. 단계별 구현 방법 예제
//Swift
import UserNotifications
func registerNotificationCategories() {
// 1. 수신거부 버튼(액션) 정의
let unsubscribeAction = UNNotificationAction(
identifier: "UNSUBSCRIBE_ACTION",
title: "원클릭 수신거부",
options: [.authenticationRequired, .destructive] // 인증 필요 및 붉은색 표시(선택)
)
// 2. "fp1" 카테고리에 액션 등록
let adCategory = UNNotificationCategory(
identifier: "fp1",
actions: [unsubscribeAction],
intentIdentifiers: [],
options: .customDismissAction
)
// 3. 시스템에 카테고리 등록
UNUserNotificationCenter.current().setNotificationCategories([adCategory])
}
4. APNs 페이로드 예시
5. 주의사항
Last updated