【发布时间】:2021-05-12 22:36:16
【问题描述】:
我正在尝试实现 AutoFill Credential Provider Extension,但是在 the video of the WWDC 提出此功能时遇到了一些问题。
是否有人已经做过可以帮助我?
现在,我添加了 AutoFill Credential Provider 功能以及 AutoFill Credential Provider 扩展,现在看起来像这样:
import AuthenticationServices
class CredentialProviderViewController: ASCredentialProviderViewController {
override func prepareCredentialList(for serviceIdentifiers: [ASCredentialServiceIdentifier]) {
}
override func provideCredentialWithoutUserInteraction(for credentialIdentity: ASPasswordCredentialIdentity) {
let databaseIsUnlocked = true
if (databaseIsUnlocked) {
let passwordCredential = ASPasswordCredential(user: "j_appleseed", password: "apple1234")
self.extensionContext.completeRequest(withSelectedCredential: passwordCredential, completionHandler: nil)
} else {
self.extensionContext.cancelRequest(withError: NSError(domain: ASExtensionErrorDomain, code:ASExtensionError.userInteractionRequired.rawValue))
}
}
override func prepareInterfaceToProvideCredential(for credentialIdentity: ASPasswordCredentialIdentity) {
}
@IBAction func cancel(_ sender: AnyObject?) {
self.extensionContext.cancelRequest(withError: NSError(domain: ASExtensionErrorDomain, code: ASExtensionError.userCanceled.rawValue))
}
@IBAction func passwordSelected(_ sender: AnyObject?) {
let passwordCredential = ASPasswordCredential(user: "j_appleseed", password: "apple1234")
self.extensionContext.completeRequest(withSelectedCredential: passwordCredential, completionHandler: nil)
}
}
所有这些都是预先写好的,但在行
} 否则 {
self.extensionContext.cancelRequest(withError: NSError(domain: ASExtensionErrorDomain, code:ASExtensionError.userInteractionRequired.rawValue))
}
我收到黄色警告“永远不会被执行”。有人可以帮我理解这个扩展是如何工作的吗?或者有我可以遵循的指南吗?我在这个网站和互联网上的其他地方都找不到任何东西。
【问题讨论】:
-
当您为每个视频添加此提供程序时,您是否在设备上获得了选择您的扩展程序作为自动填充提供程序的选项?我无法连接那个点。
标签: swift swiftui passwords autofill ios14