将GoogleSignIn的Pod版本从以前的版本更改为v5时出现问题。0.0.
gupuwyp21#
您必须将GIDSignInUIDelegate更改为GIDSignInDelegate,如GoogleSignIn文档中的示例:https://developers.google.com/identity/sign-in/ios/sign-in?ver=swift
GIDSignInUIDelegate
GIDSignInDelegate
yks3o0rb2#
GIDSignInUIDelegate协议过去需要在启动GIDSignIn.sharedInstance().signIn()的UIViewController中实现。UIViewController必须使用GIDSignIn.sharedInstance().uiDelegate = self注册自己。GoogleSignIn 5.0.0已经改变了启动GIDSignIn.sharedInstance().signIn()的UIViewController应该使用GIDSignIn.sharedInstance()?.presentingViewController = self注册自己,显然不再需要实现不再存在的GIDSignInUIDelegate。GIDSignInDelegate仍然打算在AppDelegate中实现,AppDelegate应该使用GIDSignIn.sharedInstance().delegate = self注册自己。另请参阅:https://developers.google.com/identity/sign-in/ios/quick-migration-guide
GIDSignIn.sharedInstance().signIn()
GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance()?.presentingViewController = self
GIDSignIn.sharedInstance().delegate = self
jbose2ul3#
不需要使用GIDSignInUIDelegate,请查看此链接以获取迁移指南: www.example.com只需使用GIDSignInDelegate并将GIDSignIn.sharedInstance().uiDelegate = self替换为GIDSignIn.sharedInstance()?.presentingViewController = self和
GIDSignIn.sharedInstance().handle(url, sourceApplication: sourceApplication, annotation: annotation)
关于GIDSignIn.sharedInstance().handle(url)这就是我的应用被拒绝UIWebView
GIDSignIn.sharedInstance().handle(url)
UIWebView
70gysomp4#
不要使用GIDSignIn。sharedInstance().uiDelegate = self和GIDSignInUIDelegate协议。仅使用GIDSignInDelegate协议并导入GoogleUtilities。实现sigin方法。
import UIKit import Firebase import GoogleSignIn import FirebaseAuth import GoogleUtilities class LoginViewController: UIViewController, GIDSignInDelegate { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. GIDSignIn.sharedInstance().delegate = self GIDSignIn.sharedInstance()?.presentingViewController = self } @IBAction func googleSignIn(sender: AnyObject) { GIDSignIn.sharedInstance().signIn() } func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { print("Google Sing In didSignInForUser") if let error = error { print(error.localizedDescription) return } guard let authentication = user.authentication else { return } let credential = GoogleAuthProvider.credential(withIDToken: (authentication.idToken)!, accessToken: (authentication.accessToken)!)// When user is signed in Auth.auth().signIn(with: credential, completion: { (user, error) in if let error = error { print("Login error: \(error.localizedDescription)") return } }) } }
baubqpgj5#
如果你使用的是最新的谷歌唱歌sdk使用这个代码按钮操作
let signInConfig = GIDConfiguration.init(clientID: KGoogle.clientID) GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in guard error == nil else { return } guard let user = user else { return } if let profiledata = user.profile { let userId : String = user.userID ?? "" let givenName : String = profiledata.givenName ?? "" let familyName : String = profiledata.familyName ?? "" let email : String = profiledata.email if let imgurl = user.profile?.imageURL(withDimension: 100) { let absoluteurl : String = imgurl.absoluteString //HERE CALL YOUR SERVER API } } }
5条答案
按热度按时间gupuwyp21#
您必须将
GIDSignInUIDelegate
更改为GIDSignInDelegate
,如GoogleSignIn文档中的示例:https://developers.google.com/identity/sign-in/ios/sign-in?ver=swift
yks3o0rb2#
GIDSignInUIDelegate
协议过去需要在启动GIDSignIn.sharedInstance().signIn()
的UIViewController中实现。UIViewController必须使用GIDSignIn.sharedInstance().uiDelegate = self
注册自己。GoogleSignIn 5.0.0已经改变了启动
GIDSignIn.sharedInstance().signIn()
的UIViewController应该使用GIDSignIn.sharedInstance()?.presentingViewController = self
注册自己,显然不再需要实现不再存在的GIDSignInUIDelegate
。GIDSignInDelegate
仍然打算在AppDelegate中实现,AppDelegate应该使用GIDSignIn.sharedInstance().delegate = self
注册自己。另请参阅:https://developers.google.com/identity/sign-in/ios/quick-migration-guide
jbose2ul3#
不需要使用
GIDSignInUIDelegate
,请查看此链接以获取迁移指南: www.example.com只需使用
GIDSignInDelegate
并将GIDSignIn.sharedInstance().uiDelegate = self
替换为GIDSignIn.sharedInstance()?.presentingViewController = self
和关于
GIDSignIn.sharedInstance().handle(url)
这就是我的应用被拒绝
UIWebView
70gysomp4#
不要使用GIDSignIn。sharedInstance().uiDelegate = self和GIDSignInUIDelegate协议。仅使用GIDSignInDelegate协议并导入GoogleUtilities。实现sigin方法。
baubqpgj5#
如果你使用的是最新的谷歌唱歌sdk使用这个代码按钮操作