9

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!!

Community
  • 1
  • 1
  • 3
    Have you find a solution for this? I'm also wondering if it's possible to get a callback when a "normal" call starts or ends. – Jan Jun 26 '17 at 13:09

1 Answers1

16

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")
        }
    }
}
Marwen Doukh
  • 1,946
  • 17
  • 26
Krishna Kumar Thakur
  • 1,456
  • 12
  • 27
  • @Krishna It's observing each call either it's native call or in app call. Is it possible to track only native call ? https://stackoverflow.com/questions/49257417/where-can-i-track-native-call-when-user-wants-to-call-through-app-on-another-dev?noredirect=1#comment85519416_49257417 – Hiren Mar 14 '18 at 06:39
  • @Hiren you can use uuid to determine your app calls something like this hope it works for you. if call.uuid == "your uuid" – Krishna Kumar Thakur Mar 14 '18 at 07:21
  • Not Possible. we are generating call session using var callUUID : UUID = UUID() so can not predict between native call and app call. – Hiren Mar 14 '18 at 07:31