How to detect Phone call status in iOS

Posted By : Varun Wadhwa | 19-Jun-2016

How To Detect Phone Call Status In iOS

This blog explain how to detect phone call events in an iOS app.

First of all we need to import CoreTelephony framework. 

 

import CoreTelephony
 

 

Core Telephony framework is  use to obtain details about a user’s cellular service provider and provides us some useful classes like CTCall,

from CTCall instance we can get information about ongoing phone calls, current call status (incoming,dialing,connected and disconnected states).

 

var callCenter = CTCallCenter()

callCenter.callEventHandler = {[weak self] (call: CTCall) -> () in                             
                                print(call.callState)
                             }


First of all create an instance of CTCallCenter , which is used to obtain ongoing call and responds accordingly on state change. and the method callState of CTCall returns the state of ongoing call.

call.callState return

CTCallStateIncoming  on Incoming call

CTCallStateConnected when phone call is connected,

CTCallStateDisconnected after call  gets disconnected

and CTCallStateDialling when dialing a phone call.

 

THANKS,

 

About Author

Author Image
Varun Wadhwa

Varun is a mobile developer with experience in various technologies like Titanium , Cordova and native iOS development.

Request for Proposal

Name is required

Comment is required

Sending message..