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,
More From Oodles
Mahipal Singh | 13-Dec-2024
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Varun Wadhwa
Varun is a mobile developer with experience in various technologies like Titanium , Cordova and native iOS development.