[swift] CallKit과 통화 알림(notification) 카테고리

이번에는 CallKit을 사용하여 iOS 앱에서 통화 알림(notification)을 추가하는 방법을 알아보겠습니다. CallKit은 통화와 관련된 기능을 iOS 앱에 추가하고 시스템 통화 환경과 통합할 수 있도록 해주는 프레임워크입니다.

1. CallKit Framework 가져오기

먼저 Xcode 프로젝트에 CallKit 프레임워크를 추가해야 합니다. Xcode 프로젝트를 열고 Build Phases에서 + 버튼을 클릭하여 CallKit.framework를 추가합니다.

2. 통화 알림(notification) 카테고리 설정

애플리케이션의 Info.plist 파일에 다음 항목을 추가하여 통화 알림(notification) 카테고리를 설정합니다.

<key>UIUserNotificationSettings</key>
<dict>
    <key>categories</key>
    <array>
        <dict>
            <key>category</key>
            <string>INCOMING_CALL</string>
            <key>actions</key>
            <array>
                <dict>
                    <key>identifier</key>
                    <string>ACCEPT_ACTION</string>
                    <key>title</key>
                    <string>Accept</string>
                    <key>activationMode</key>
                    <string>foreground</string>
                    <key>authenticationRequired</key>
                    <false/>
                </dict>
                <dict>
                    <key>identifier</key>
                    <string>DECLINE_ACTION</string>
                    <key>title</key>
                    <string>Decline</string>
                    <key>activationMode</key>
                    <string>foreground</string>
                    <key>authenticationRequired</key>
                    <false/>
                    <key>destructive</key>
                    <true/>
                </dict>
            </array>
        </dict>
    </array>
</dict>

위의 코드에서 category, identifier, title, activationMode, authenticationRequired, destructive 등의 필드를 적절히 설정하여 통화 알림(notification) 카테고리를 정의합니다.

결론

위의 단계를 따라하면 CallKit을 사용하여 iOS 앱에서 통화 알림(notification)을 설정할 수 있습니다. CallKit은 iOS 앱에서 통화 관련 기능을 구현하기 위한 강력한 도구입니다.

더 자세한 내용은 CallKit Framework 문서를 참고하시기 바랍니다.