Vla*_*lad 5 firebase swift firebase-authentication
FirebaseAuth我在 macOS 上使用。下面的代码按预期工作。它会uid在每次应用程序启动时打印到控制台。
func applicationDidFinishLaunching(_ aNotification: Notification) {
FirebaseApp.configure()
Auth.auth().signInAnonymously { [weak self] result, error in
if let error = error {
debugPrint(error)
}
if let result = result {
debugPrint(result.user.uid)
}
}
}
Run Code Online (Sandbox Code Playgroud)
uid但是,当从currentUser类的属性使用时,Auth系统会弹出对话框,其中显示消息“应用程序想要使用存储在 firebase_auth_1:blah:ios:blah 中的机密信息”。
func applicationDidFinishLaunching(_ aNotification: Notification) {
FirebaseApp.configure()
if let id = Auth.auth().currentUser?.uid {
debugPrint(id) // run `killall -9 SecurityAgent` to kill dialog
} else {
Auth.auth().signInAnonymously { [weak self] result, error in
if let error = error {
debugPrint(error)
}
if let result = result {
debugPrint(result.user.uid)
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
currentUser使用类的属性时如何避免系统弹出此窗口 Auth?
更新 1当不是从 Xcode 而是从 Finder 启动应用程序时,上面显示的两个版本的启动代码似乎都可以在不弹出系统对话框的情况下工作。看起来只有在从 Xcode 运行应用程序时才会显示弹出窗口。
更新 2该问题未在Auth.auth().currentUser使用中。每次重新编译应用程序时,系统都会显示弹出窗口。似乎这取决于代码签名,编译更改后可能会有所不同。

更新 3似乎问题是由于 Xcode 设置“签名证书:签名以本地运行”所致。显式设置“配置文件”和“签名证书”可以解决问题。

| 归档时间: |
|
| 查看次数: |
335 次 |
| 最近记录: |