2016-11-17 55 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

相關問題