我正在进行Auth0 Lock集成,但出现错误使用未解决的标识符“连接”;您是说“连接”吗?。
.withConnections {_ in
connections.database(name: "Username-Password-Authentication", requiresUsername: true)
}
我将代码更改为
Connections.database(name: "Username-Password-Authentication", requiresUsername: true)
现在我收到错误消息实例成员'database'不能用于'Connections'类型
当我将代码更改为
Connections().database(name: "Username-Password-Authentication", requiresUsername: true)
遇到错误无法建立“连接”,因为它没有可访问的初始化程序
我将代码更改为
$0.database(name: "Username-Password-Authentication", requiresUsername: true)
获取匿名闭包参数不能在具有显式参数的闭包内使用
https://github.com/auth0/Lock.swift
https://auth0.com/docs/libraries/lock-ios/v2#configuration-options
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Lock
.classic()
// withConnections, withOptions, withStyle, and so on
.withOptions {
$0.oidcConformant = true
$0.scope = "openid profile"
}
.onAuth { credentials in
// Let's save our credentials.accessToken value
}
.withConnections {_ in
connections.database(name: "Username-Password-Authentication", requiresUsername: true)
}
.withStyle {
$0.title = "Company LLC"
$0.logo = LazyImage(name: "123.png")
$0.primaryColor = UIColor(red: 0.6784, green: 0.5412, blue: 0.7333, alpha: 1.0)
}
.present(from: self)
答案 0 :(得分:2)
似乎Auth0文档在这里是错误的。如果查看Lock.swift source file,则会看到ConnectionBuildable
作为参数传递。您需要使用它来建立连接。
尝试一下:
.withConnections { connections in
connections.database(name: "Username-Password-Authentication", requiresUsername: true)
}
或使用匿名闭包参数的相同操作:
.withConnections {
$0.database(name: "Username-Password-Authentication", requiresUsername: true)
}
答案 1 :(得分:2)
错误位于.withConnections的闭包中 您不是通过使用 _
来命名参数的没有参数
.withConnections { _ in }
带有参数
.withConnections { connections in {
connections.database(name: "Username-Password-Authentication", requiresUsername: true)
}
答案 2 :(得分:1)
您得到使用未解决的标识符“连接”;您是说“连接”吗?,因为connections
没有声明为闭包参数。
尝试:
.withConnections { connections in
connections.database(name: "Username-Password-Authentication", requiresUsername: true)
}
或者如果您想使用匿名参数,请不要声明任何参数:
.withConnections {
$0.database(name: "Username-Password-Authentication", requiresUsername: true)
}