-
반응형
이번에 개발하는 서비스에 CallKit, PushKit을 적용해 보면서 정리해본 내용
VoIP Push 등록
참고: https://developer.apple.com/documentation/pushkit/supporting_pushkit_notifications_in_your_app
Apple Developer Documentation
developer.apple.com
일단 CallKit과 PushKit은 세트라서 항상 함께 사용한다.
Voip Push 는 일반 notification과는 조금 다르게 취급되며 APNS 에서도 최고 prioirity로 취급한다. 대신 Voip Push를 받았는데 CallKit 함수를 호출하지 않는 경우 패널티가 생길수 있으니, 다른 용도로는 사용하면 안된다.
PushKit을 사용하기 위해서는 XCode 프로젝트의 Capability > Background Modes > Voice over IP 를 활성화 시켜주어야 한다. 그리고 AppDelegate 에서 VoIP Push를 등록한다.
func setupVoIPPush() { voipRegistry = PKPushRegistry(queue: nil) voipRegistry.delegate = self voipRegistry.desiredPushTypes = [PKPushType.voIP] }그리고 나서 받은 PushToken을 서비스 서버에 등록하고, Push가 등록했을때는 CallKit의 report incoming call 함수를 호출해준다.
extension AppDelegate: PKPushRegistryDelegate { func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) { // TODO: upload push credential to server } func pushRegistry( _ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void ) { let handle = payload["handle"] let hasVideo = payload["hasVideo"] CallManager.shared.reportIncomingCall(uuid: UUID(), handle: handle, hasVideo: hasVideo) { error in // handle error } } }CallKit 적용하기
콜킷 적용은 아래 tutorial을 참고했다.
https://www.raywenderlich.com/1276414-callkit-tutorial-for-ios
CallKit Tutorial for iOS
Learn how your app can use CallKit for system-level phone integration and how to build a directory extension for call blocking and identification.
www.raywenderlich.com
참고 :
https://developer.apple.com/documentation/pushkit/responding_to_voip_notifications_from_pushkit
Apple Developer Documentation
developer.apple.com
그 외 정보
서버 없이 Device Token 만으로 기기에 푸시를 보낼 수 있는 방법을 정리한 글
[iOS] Callkit과 PushKit을 이용해서 전화 푸쉬하기
안녕하세요 Foma 입니다! 오늘은 Callkit을 이용해서 전화오는 화면을 띄워보도록 하겠습니다! 바로 시작할게요~ Xcode 프로젝트를 만들어주신 뒤 Signing & Capabitities 로 이동하셔서 Background modes를 추
fomaios.tistory.com
Push notification관련 좋은 글
https://mininny.dev/everything-about-ios-push/
Everything about iOS push📲
Put an end to Apple's weird push systems
www.mininny.dev
반응형'개발' 카테고리의 다른 글
[iOS/Swift] UIView 캡쳐하고 흑백 처리하기 code snippet (0) 2022.01.20 [Swift] RetainCycle과 weak self (0) 2022.01.02 [XCode] Archive 할때 image resource가 사라지는 이슈 해결 - 범인은 Development Assets! (0) 2021.09.22 [iOS] Testflight 업로드에서 JSON 파일이 유실되는 현상 해결 (0) 2021.09.15 iOS 프로젝트명 변경하기 (0) 2021.09.08 댓글