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

查看:21
本文介绍了如何在 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 对象中获取来电电话号码吗?或者还有其他方法.
我不想使用 Private API.Apple 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.

您将永远无法获得当前通话的电话号码,因为这是私人数据,Apple 不允许您访问这些数据.

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天全站免登陆