How to get user incoming call phone number in iOS device

拥有回忆 提交于 2019-11-28 01:58:45

问题


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

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?


回答1:


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.



来源:https://stackoverflow.com/questions/13681449/how-to-get-user-incoming-call-phone-number-in-ios-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!