问题描述
这是我第一次使用PushKit
和CallKit
组合来构建VoIP功能。我注意到,从iOS 13开始,必须报告 PushKit VoIP推送,否则该应用将崩溃。
由于这项规定,我继续在reportNewIncomingCall
内实现didReceiveIncomingPushWith
方法,并确保成功完成了它的完成,因为我放置在完成块中的断点已被激活。
但是,此后不久,该应用程序崩溃并显示“杀死应用程序,因为它在收到PushKit VoIP回调后从未向系统发布来话呼叫”,这很奇怪,因为之前已调用完成模块。
有人知道为什么会这样吗?
这是我实现的reportNewIncomingCall
的代码:
let callUpdate = CXCallUpdate()
callUpdate.remoteHandle = CXHandle(type: .phoneNumber,value: session)
callUpdate.localizedCallerName = username
callUpdate.hasVideo = true
callUpdate.supportsDTMF = false
let uuid = {{some uuid}}
provider.reportNewIncomingCall(with: uuid,update: callUpdate,completion: { error in
if let error = error {
print("reportNewIncomingCall error: \(error.localizedDescription)")
}
DispatchQueue.main.async {
completion()
}
})
编辑
这是pushRegistry(_,didReceiveIncomingPushWith...)
代码:
func pushRegistry(_ registry: PKPushRegistry,didReceiveIncomingPushWith payload: PKPushPayload,for type: PKPushType,completion: @escaping () -> Void) {
if type == .voIP {
guard let payloadData = payload.dictionaryPayload as? [String: Any],let data = payloadData["data"] as? [String: Any],let typeCall = data["type"] as? String else { completion();return }
if typeCall == "OPEN_ACTIVITY_CALL" {
guard let userName = data["userName"] as? String else { completion();return }
self.appleCallKit?.showIncomingCall(username: userName)
}
completion()
}
}
self.appleCallKit?.showIncomingCall(username: userName)
方法在上一个代码块中执行reportNewIncomingCall
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)