iOS 监测电话呼入
1.首先引入CoreTelephony框架,代码里:
@import CoreTelephony;
项目设置里:
2.定义属性,建立强引用:
@property (nonatomic, strong) CTCallCenter * callCenter;
3.初始化这个属性,并设置回调:
self.callCenter = [[CTCallCenter alloc] init]; __weak typeof(self) weakedSelf = self; self.callCenter.callEventHandler = ^(CTCall * call) { dispatch_async(dispatch_get_main_queue(), ^{ // 检测到来电后的处理 [weakedSelf pausePublish]; }); };
Stay hungry,stay foolish.