如何使用 CallKit API 映射社交资料 [英] How to map social profile with CallKit API

查看:35
本文介绍了如何使用 CallKit API 映射社交资料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我正在尝试将 CallKit 集成到现有的 VoIP 应用程序中.

Now i am trying to integrate CallKit into the existing VoIP app.

根据 API,通过 CallKit 报告的每个调用都有一个与之关联的句柄.我们的应用程序的用户可以进行音频和视频通话,这是在帐户之间建立的,并且他们没有任何关联的电话号码",因此我们将呼叫句柄类型设置为通用"并使用一些特殊的帐户标识符作为这些句柄的值.这些用户帐户对用户不友好,不应显示在 UI 中.

According to the API, every call reported via CallKit has a handle associated with it. Users of our app can make audio and video calls, which are established between accounts and they don't have any associated "phone numbers", so we set call handle type to "generic" and use some special account identifiers as values for these handles. These user accounts are not user friendly and are not supposed to be shown in UI.

所以很自然地希望在通话记录中显示真实的用户名.这是我们遇到障碍的地方.

So there's a natural wish to show real user names in call history logs. This is where we hit the roadblock.

根据 WWDC 会议,社交资料将是集成 CallKit 的 VoIP 应用程序之间的一种链接,所以我的问题是如何创建社交资料并将其与 Callkit API 链接?

According to the WWDC session, social profiles will be a sort of link between VoIP apps integrating CallKit, so my question is how to create the social profile and link it with the Callkit API ?

在检查了几个 VoIP 应用程序后,我认为这不是使用这些信息创建新联系人的正确方法,因为我在联系人中找不到它们.

After check with several VoIP app, i don't think it's the right way to create a new contact with these info, for i can't find them in the Contacts.

任何评论/建议/帮助将不胜感激!!!

Any comments/suggestions/help would be highly appreciated!!!

提前致谢.

推荐答案

回复较晚,但可能对未来的观众有所帮助.你可以在 ProviderDelegate 中欺骗它.无论您有通用电话号码,只需使用您的手柄开始呼叫即可.并通过开始呼叫操作向您发送被叫方名称,例如

Its late reply but it may help future viewers. You can trick this in ProviderDelegate. Just start call with your handle whatever you have Generic OR PhoneNumber. And send you callee name with start call action like

public func startCall(handle: String,contactIdentifier:String/*Your Callee Name*/, video: Bool = false) {
        let handle = CXHandle(type: .Generic, value: handle)
        let startCallAction = CXStartCallAction(callUUID: NSUUID(), handle: handle)

        startCallAction.video = video
        startCallAction.contactIdentifier = contactIdentifier //Callee name goes with action so we can get in Delegate
        let transaction = CXTransaction()
        transaction.addAction(startCallAction)

        requestTransaction(transaction)
    }

之后的主要技巧是在 ProviderDelegate Like

And after that main trick is to update your call in your StartCallAction in ProviderDelegate Like

public func provider(provider: CXProvider, performStartCallAction action: CXStartCallAction) {

        let update = CXCallUpdate()
        update.remoteHandle = action.handle
        update.hasVideo = action.isVideo
        update.localizedCallerName = action.contactIdentifier     //Here contactIdentifier is assigned callee name on start call

        self.provider.reportCall(with: action.callUUID, updated: update)


      // Rest of your code
    }

对于来电,设置 CXCallUpdate 的 localizedCallerName

For Incoming Calls set localizedCallerName of your CXCallUpdate

在您的通话记录中,它会显示类似

In your call history it will show something like

这篇关于如何使用 CallKit API 映射社交资料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆