How to get user incoming call phone number in iOS

2019-01-25 23:44发布

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条回答
趁早两清
2楼-- · 2019-01-26 00:17

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.

查看更多
登录 后发表回答