我想开发一个SOS应用程序。当我尝试使用URL schema openURL()时,它会显示警报,但我的要求是在拨打电话时不显示任何警报或弹出窗口。因此,我找到了一种使用CallKit的解决方案。在我的应用程序中实现CallKit时,它不需要任何权限,可以拨出呼叫,但被叫方没有收到任何电话。有没有解决这个问题的方法?
我尝试了以下代码以连接电话。
我尝试了以下代码以连接电话。
@IBAction func buttonCallTapped(_ sender: Any) {
let provider = CXProvider(configuration: CXProviderConfiguration(localizedName: "My App"))
provider.setDelegate(self, queue: nil)
let controller = CXCallController()
let transaction = CXTransaction(action: CXStartCallAction(call: UUID(), handle: CXHandle(type: .phoneNumber, value: "\(number)")))
controller.request(transaction, completion: { error in })
DispatchQueue.main.asyncAfter(wallDeadline: DispatchWallTime.now() + 5) {
provider.reportOutgoingCall(with: controller.callObserver.calls[0].uuid, connectedAt: nil)
}
}