How to map social profile with CallKit API

2019-09-04 11:56发布

问题:

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



标签: ios voip callkit