IOS Coretelephony realizes listening to the call status _ios

Source: Internet
Author: User

In the program if you need to monitor the status of the phone, you can introduce the Coretelephony framework, this framework contains the telephone-related APIs, can monitor incoming calls, look at operator information and other functions. The following is the specific implementation of the code to monitor incoming calls. Be sure to write Center as a separate attribute, and a strong reference (strong), otherwise if center is destroyed after the Center,viewdidload method is created in the Viewdidload method, then the call cannot be detected.

The initial state of a call is the incoming (ctcallstateincoming) and exhaled (ctcallstatedialing), when the state is switched on (ctcallstateconnected), And when the call is terminated, the state turns to hang up (ctcallstatedisconnected)

Ctcallcenter *center = [[Ctcallcenter alloc]init];
Center_ = center;
Center.calleventhandler = ^ (Ctcall *call) {
NSLog (@ "call:%@", call.description);
if ([Call.callstate isequaltostring:@ "ctcallstatedialing"]) {
//is calling status
}
if ([call.callstate isequaltostring:@ "ctcallstatedisconnected"]) {
//disconnect status
}
};

The above is a small set to introduce the iOS coretelephony to monitor the status of all the narration, hope to help everyone, if you want to know more content, please pay attention to cloud Habitat community website!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.