0

When I tab the outgoing call made by my app in native phone recents But I only can get the id (EX: 12345678), can't get the description (EX: David)

native phone recents

info of the outgoing call

Here is my code in AppDelegate.m

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler NS_AVAILABLE_IOS(8_0)
{
     INInteraction *interaction = userActivity.interaction;  
     INStartAudioCallIntent *startAudioCallIntent = (INStartAudioCallIntent *)interaction.intent;  
     INPerson *contact = startAudioCallIntent.contacts[0];  
     INPersonHandle *personHandle = contact.personHandle;  
     NSString *phoneNumber = personHandle.value;  
} 

I can't found any info about the description (EX: David) in INPerson object.

Is there any other way to get the phone description?

Sailendra
  • 1,318
  • 14
  • 29
Zenki Wu
  • 63
  • 1
  • 9

1 Answers1

1

I don't think you can do that.

When you configure your CXProvider object, you specify the supported handle types (CXHandle.HandleType), for example:

providerConfiguration.supportedHandleTypes = [.phoneNumber]

According to the CXHandle documentation:

When the telephony provider receives an incoming call or the user starts an outgoing call, the other caller is identified by a CXHandle object. For a caller identified by a phone number, the handle type is CXHandleTypePhoneNumber and the value is a sequence of digits. For a caller identified by an email address, the handle type is CXHandleTypeEmailAddress and the value is an email address. For a caller identified in any other way, the handle type is CXHandleTypeGeneric and the value typically follows some domain-specific format, such as a username, numeric ID, or URL.

You can add a generic CXHandle for an outbound call:

 - (instancetype)initWithType:(CXHandleType)type 
                        value:(NSString *)value;

but it's not sure whether this info is passed into the userActivity that is passed into your app.

EDIT: As user102008 noted, you can take a look at Apple's Speakerbox example.

To resolve contacts, you can add this call to your intent handler

func resolveContacts(forStartAudioCall intent: INStartAudioCallIntent, with completion: @escaping ([INPersonResolutionResult]) -> Void) {
    // Your code here
}

EDIT 2: I have a lot more to learn :( Here's a link with more information: CallKit find number used to start app from native phone app

Community
  • 1
  • 1
Ri_
  • 662
  • 8
  • 13
  • "but it's not sure whether this info is passed into the userActivity that is passed into your app" It is. See the Speakerbox sample code. – user102008 Nov 21 '16 at 20:08
  • You can also attempt to set the name for the call yourself using the `localizedCallerName` property on `CXCallUpdate` – AdamPro13 May 03 '18 at 19:18