首页 > 代码库 > iOS监听电话事件
iOS监听电话事件
项目上有个需求,要求打完电话后加积分.
首先导入这两个头文件:
#import <CoreTelephony/CTCallCenter.h>#import <CoreTelephony/CTCall.h>
添加属性:
@property (nonatomic, strong) CTCallCenter *callCenter;
获取状态如下:
self.callCenter = [[CTCallCenter alloc] init]; self.callCenter.callEventHandler=^(CTCall* call) { if (call.callState == CTCallStateDisconnected) { NSLog(@"挂断电话Call has been disconnected"); } else if (call.callState == CTCallStateConnected) { NSLog(@"电话通了Call has just been connected"); } else if(call.callState == CTCallStateIncoming) { NSLog(@"来电话了Call is incoming"); } else if (call.callState ==CTCallStateDialing) { NSLog(@"正在播电话call is dialing"); } else { NSLog(@"Nothing is done"); } };
iOS监听电话事件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。