How to map social profile with CallKit API

女生的网名这么多〃 提交于 2020-01-17 12:15:10

问题


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

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.

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 ?

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!!!

Thanks in advance.


回答1:


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

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
    }

For Incoming Calls set localizedCallerName of your CXCallUpdate

In your call history it will show something like



来源:https://stackoverflow.com/questions/39957242/how-to-map-social-profile-with-callkit-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!