作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我用这段代码开始 callkit 调用:
private func startCallKitCall(call: Call, completion: @escaping (Bool) -> ()){
let handle = CXHandle(type: .phoneNumber, value: call.handle)
let startCallAction = CXStartCallAction(call: call.uuid, handle: handle)
startCallAction.isVideo = call.hasVideo
startCallAction.contactIdentifier = call.uuid.uuidString
let transaction = CXTransaction(action: startCallAction)
requestCallKitTransaction(transaction, completionHandler: { success in
completion(success)
})
}
在 contactIdentifier 中,我设置了用户 UUID,然后在提供者中,更新调用者远程名称:
public func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
let update = CXCallUpdate()
update.remoteHandle = action.handle
update.hasVideo = action.isVideo
update.localizedCallerName = "TestCallName"
self.provider!.reportCall(with: action.callUUID, updated: update)
action.fulfill()
}
我使用“TestCallName”作为 localizedCallerName,现在在我手机的最近通话中,我看到一个名为“TestCallName”的行,如果我单击它,我将在 appdelegate 上调用此方法:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
if (userActivity.activityType == "INStartAudioCallIntent"){
guard let interaction = userActivity.interaction else {
return false
}
var personHandle: INPersonHandle?
if let startVideoCallIntent = interaction.intent as? INStartVideoCallIntent {
personHandle = startVideoCallIntent.contacts?[0].personHandle
} else if let startAudioCallIntent = interaction.intent as? INStartAudioCallIntent {
personHandle = startAudioCallIntent.contacts?[0].personHandle
print(startAudioCallIntent.contacts?[0])
}
print(personHandle!.value)
} else if (userActivity.activityType == "INStartVideoCallIntent"){
} else {
print("called userActivity: \(userActivity.activityType), but not yet supported.")
}
return true
}
但我得到的输出是:
Optional(<INPerson: 0x1742a5280> {
contactIdentifier = "<null>";
customIdentifier = "<null>";
displayName = "<null>";
image = "<null>";
nameComponents = "<null>";
personHandle = "<INPersonHandle: 0x17402f0c0> {\n label = \"<null>\";\n type = PhoneNumber;\n value = \"TestCallName\";\n}";
relationship = "<null>";
siriMatches = "<null>";
})
Optional("TestCallName")
我只看到名称“TestCallName”,但联系人标识符为“null”,我该如何解决这个问题?我看到还有一个字段名称“customIdentifier”,我可以使用它吗?
谢谢!
最佳答案
contactIdentifier
是联系人应用程序中联系人的 ID。您在 startCallAction.contactIdentifier
中设置的那个没有任何意义。要调用用户,您需要使用电话或电子邮件,或者至少使用姓名。
关于ios - 如何从 callKit 访问联系人标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47430527/
我是一名优秀的程序员,十分优秀!