它的回复晚了,但它可能会帮助未来的观众。您可以在 ProviderDelegate 中进行欺骗。只需使用您的句柄开始呼叫,无论您有Generic OR PhoneNumber。并通过开始呼叫操作向您发送被呼叫者姓名,例如
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的StartCallAction中更新您的呼叫
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的本地化呼叫者名称
在您的通话记录中,它会显示类似
