0
我需要使用Google-SignIn SDK对其进行身份验证, 当我在类UIViewcontroller类中使用它时,它工作成功。 但我需要在一个单独的类中实现signIn方法我应该怎么做才能成功工作? 我的GoogleLogin类看起来像谷歌登录不在非UIViewController中起作用
import Foundation
import GoogleSignIn
class GoogleLogin:NSObject, LoginAuthProtocol, GIDSignInDelegate, GIDSignInUIDelegate{
weak var googleView: UIViewController!
init(view: UIViewController) {
super.init()
googleView = view
GIDSignIn.sharedInstance().clientID = "1017499022947-4d73nf64.apps.googleusercontent.com"
GIDSignIn.sharedInstance().uiDelegate = self
GIDSignIn.sharedInstance().delegate = self
}
func login() {
GIDSignIn.sharedInstance().signIn()
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if error != nil{
print("*****error \(error.localizedDescription) ******")
return
}
print(user.profile.email)
}
func sign(inWillDispatch signIn: GIDSignIn!, error: Error!) {
}
func sign(_ signIn: GIDSignIn!, present viewController: UIViewController!) {
googleView.present(viewController, animated: true, completion: nil)
}
func sign(_ signIn: GIDSignIn!, dismiss viewController: UIViewController!) {
googleView.dismiss(animated: true, completion: nil)
}
}
当我要开始登录我叫login()方法从我的根的viewController和路径自身作为参数
GoogleLogin(view: self).login()
但电话后没有发生!