【问题标题】:How to get voip phone name description from native phone recents?如何从本地电话最近获取 voip 电话名称描述?
【发布时间】:2016-11-17 06:30:33
【问题描述】:

当我在本机手机最近使用的应用程序中选择拨出电话时 但我只能得到 id (EX: 12345678),无法得到描述 (EX: David)

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

我在 INPerson 对象中找不到有关描述(例如:David)的任何信息。

有没有其他方法可以得到电话描述?

【问题讨论】:

    标签: ios objective-c ios10 callkit


    【解决方案1】:

    我认为你做不到。

    在配置 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

    【讨论】:

    • "但不确定此信息是否传递到传递到您的应用程序的 userActivity" 是。请参阅 Speakerbox 示例代码。
    • 您也可以尝试使用CXCallUpdate 上的localizedCallerName 属性自行设置呼叫名称
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-14
    相关资源
    最近更新 更多