some.ios.developer
some.ios.developer

Reputation: 91

Can Callkit be used with non-voip call to get the call states in ios?

I have read the question about making a-non-voip-call and it seems, that the open url is the only way to do it. Since CoreTelephony is deprecated, is it possible to use Callkit to get the call states when making a call with open url? If not is there any way to get the call states programmatically? I am developing an in-house-app.

How can CallKit be used to make a non-voip call?

Thanks in advance!!

Upvotes: 9

Views: 3370

Answers (1)

Krishna Kumar Thakur
Krishna Kumar Thakur

Reputation: 1476

To get call states in CallKit, you can use CXCallObserver in your app.

import CallKit

final class ProviderDelegate: NSObject, CXCallObserverDelegate { 
var callObserver: CXCallObserver!

func setupCallObserver(){
callObserver = CXCallObserver()
callObserver.setDelegate(self, queue: nil)
}

func callObserver(_ callObserver: CXCallObserver, callChanged call: CXCall) {
        if call.hasEnded == true {
            print("CXCallState :Disconnected")
        }
        if call.isOutgoing == true && call.hasConnected == false {
            print("CXCallState :Dialing")
        }
        if call.isOutgoing == false && call.hasConnected == false && call.hasEnded == false {
            print("CXCallState :Incoming")
        }

        if call.hasConnected == true && call.hasEnded == false {
            print("CXCallState : Connected")
        }
    }
}

Upvotes: 16

Related Questions