首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >配置参数从GIDSignIn方法到哪里?

配置参数从GIDSignIn方法到哪里?
EN

Stack Overflow用户
提问于 2022-10-12 12:56:28
回答 2查看 95关注 0票数 1

我正在用google和facebook授权重建宠物IOS项目。Google flow曾经是这样的:

代码语言:javascript
复制
GIDSignIn.sharedInstance.signIn(with: config, presenting: presentingViewController) {

        user, error in ///bla bla bla }

但是当重新下载GoogleSignIn包时,xcode开始显示一个错误。而google授权流更改为

代码语言:javascript
复制
GIDSignIn.sharedInstance.signIn(withPresenting: presentingViewController) {

            user, error in ///bla bla bla }

问题是,当我用这种“新”方式运行时,我的应用程序就会崩溃。

代码语言:javascript
复制
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'No active configuration.  Make sure GIDClientID is set in Info.plist.'

此外,google文档和github代表中也没有任何信息。请帮帮我!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-10-12 19:58:28

函数已更新,with: config参数已删除。谷歌服务信息中的Client_ID值应该作为GIDClientID键添加到info.plist中。你的职责应该是

代码语言:javascript
复制
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****")
            
        }
    }
}
票数 0
EN

Stack Overflow用户

发布于 2022-11-29 21:25:20

确保您正在下载6.0.2版本,以便获得GIDSignIn.sharedInstance.signIn(with: presenting: callback)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74042206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档