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];
    });
};

 

 

 

 

 

 

 


转载请注明出处:http://www.cnblogs.com/ficow/p/7283850.html 

posted @ 2017-08-04 10:56  Ficow  阅读(433)  评论(0编辑  收藏  举报