2016-11-17 71 views
0

当我按标签我的应用程序在本地电话最近用过 但我只能得到ID(EX:12345678)的拨叫,不能获得描述(EX:大卫)如何从本地电话最近获取voip电话名称描述?

native phone recents

info of the outgoing call

这是我在代码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; 
} 

我无法找到有关DESCR任何信息iption(EX:David)在INPerson对象中。

是否有任何其他方式获取电话说明?

回答

0

我不认为你可以这样做。

当您配置CXProvider对象,指定支持的句柄类型(CXHandle.HandleType),例如:

providerConfiguration.supportedHandleTypes = [.phoneNumber] 

按照CXHandle documentation

当电话提供商接收来电或用户 开始拨出电话,另一个呼叫者由CXHandle 对象标识。对于由电话号码标识的呼叫者,句柄类型为 CXHandleTypePhoneNumber,值为数字序列。对于由电子邮件地址标识的 调用方,句柄类型为 CXHandleTypeEmailAddress,值为电子邮件地址。对于以任何其他方式标识的 调用方,句柄类型为 CXHandleTypeGeneric,该值通常遵循某些 域特定的格式,例如用户名,数字ID或URL。

您可以添加一个通用CXHandle用于出站呼叫:

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

,但它不知道这个信息是否被传递到传递到您的应用程序的userActivity

编辑: 正如user102008指出的,你可以看看Apple's Speakerbox example

要解决的联系人,你可以这样调用添加到您的意图处理

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

编辑2: 我还有很多东西要学:(这里有更多信息的链接: CallKit find number used to start app from native phone app

+0

“但不确定这些信息是否传递到传递到应用程序的userActivity中“是的,请参阅扬声器示例代码。 – user102008