如何在iOS设备用户来电的电话号码 [英] How to get user incoming call phone number in iOS device

查看:143
本文介绍了如何在iOS设备用户来电的电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的iOS SDK 4.0中引入CoreTelephony框架知道来电&安培;其下降的状态。

I used CoreTelephony framework introduced in iOS SDK 4.0 to know about Incoming call & its dropped state.

CTTelephonyNetworkInfo *tni = [[CTTelephonyNetworkInfo alloc] init];
    callCenter = [[CTCallCenter alloc] init];
    crtCarrierName = tni.subscriberCellularProvider.carrierName;

    [callCenter setCallEventHandler:^(CTCall *call) {
      if ([[call callState] isEqual:CTCallStateConnected]) {
        //this call has just connected
      } else if ([[call callState] isEqual:CTCallStateDisconnected]) {
        //this call has just ended (dropped/hung up/etc)
      }
    }];

我可以使用此事件处理程序,以跟踪呼叫状态时,我的应用程序是在后台?
我还可以获取来自CTCall对象来电的电话号码?或有任何其他方式。结果
我不想用私人API.Is有办法可以从苹果iOS SDK?

Can i use this event handler to track call state when my app is in background? Can i also fetch incoming call phone number from CTCall object? or there is any other way around.
I dont want to use Private API.Is there way available from Apple iOS SDK?

推荐答案

没有就没有办法在官方SDK做到这一点,你不能在后台使用它,因为它不属于上运行的类别,除非背景你的应用程序做别的东西在后台然后只需监控呼叫。

No there is no way to do this in the official SDK, you can not use it in the background since it does not fall on of the background running categories unless you app does something else in the background then just monitoring the call.

您将永远无法获得,因为这当前呼叫的电话号码是私人数据苹果不会让你存取权限的数据。

You will never be able to get the phone number of the current call since this is private data Apple will not allow you to acces the data.

这篇关于如何在iOS设备用户来电的电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆