我正在用google和facebook授权重建宠物IOS项目。Google flow曾经是这样的:
GIDSignIn.sharedInstance.signIn(with: config, presenting: presentingViewController) {
user, error in ///bla bla bla }但是当重新下载GoogleSignIn包时,xcode开始显示一个错误。而google授权流更改为
GIDSignIn.sharedInstance.signIn(withPresenting: presentingViewController) {
user, error in ///bla bla bla }问题是,当我用这种“新”方式运行时,我的应用程序就会崩溃。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'No active configuration. Make sure GIDClientID is set in Info.plist.'此外,google文档和github代表中也没有任何信息。请帮帮我!
发布于 2022-10-12 19:58:28
函数已更新,with: config参数已删除。谷歌服务信息中的Client_ID值应该作为GIDClientID键添加到info.plist中。你的职责应该是
func googleSign(){
guard let presentingVC = (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.windows.first?.rootViewController else {return}
// Start the sign in flow!
GIDSignIn.sharedInstance.signIn(withPresenting: presentingVC) { user, error in
if let error = error {
print(error.localizedDescription)
return
}
guard let authentication = user?.authentication, let idToken = authentication.idToken
else {
return
}
let credential = GoogleAuthProvider.credential(withIDToken: idToken,
accessToken: authentication.accessToken)
self.showCustomAlertLoading = true
Auth.auth().signIn(with: credential) { authResult, error in
guard let user = authResult?.user, error == nil else {
self.signUpResultText = error?.localizedDescription ?? "Error Occured"
DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
self.showCustomAlertLoading = false
})
return}
self.signUpResultText = "\(user.email!)\nSigning Succesfully"
self.isSignUpSucces = true
DispatchQueue.main.asyncAfter(deadline: .now() + 3, execute: {
self.showCustomAlertLoading = false
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
self.navigateHome = true
})
})
print("\(user.email!) signed****")
}
}
}发布于 2022-11-29 21:25:20
确保您正在下载6.0.2版本,以便获得GIDSignIn.sharedInstance.signIn(with: presenting: callback)
https://stackoverflow.com/questions/74042206
复制相似问题