Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CallKit :- Callkit is working but the callee doesn't get the call

I want to develop an SOS application. When I am trying to use URL schema openURL(), it will display an alert but my requirement is to connect the call without any alert or popup while trying to call. So I found a solution using CallKit. When I implemented CallKit in my application it does not ask for any permission, the outgoing call is placed but the callee doesn't get any call. Is there any solution for this?

I have tried the following code for connecting the call.

@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)
    }
}
like image 289
Adarsh KC Avatar asked Feb 06 '20 11:02

Adarsh KC


2 Answers

You just can't make standard native calls through CallKit. The CallKit framework, as clearly stated in the documentation, is meant to be used to develop custom VoIP applications and integrate them with the native phone interface.

like image 121
Marco Avatar answered Oct 31 '22 11:10

Marco


Any iOS application can't make native call without user action.

An alert will be shown with phone number and two buttons will be available "Call" and "Cancel" which is presented from the OS level.

Just like we are showing popup to delete photos from Photos app.

Solution

If you want to implement SOS Application (Yes its possible using VoIP service), But you can place calls when app is active (Can be done without user action given internet connection is there.)

Note: The receiving side also should support VoIP.

How to Implement VoIP

We need permission of Voice over IP services to make calls in between iPhone devices.

VoIP app must have background mode enabled in the Xcode Project > Capabilities pane. Select the checkbox for Voice over IP

Also CallKit is indented only for VoIP Apps, If you really want to implement the VoIP follow CallKit Tutorial

like image 1
Saranjith Avatar answered Oct 31 '22 11:10

Saranjith