1
我正在Google中登录我的项目。我使用CocoaPods安装了SDK。我有以前用Objective-C编写的这个相同的应用程序。所以我从我的旧项目中拖动了相同的Google配置文件(GoogleService-Info.plist)。Google didSignInForUser不会迅速启动3
而且我跟着this with CocoaPods installed method。但是当我按下登录按钮时,我正在指向Google网页,输入用户名密码后,它会返回到我的应用程序。但是这个代表没有触发。
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
if error == nil {
// Perform any operations on signed in user here.
let userId = user.userID // For client-side use only!
let idToken = user.authentication.idToken // Safe to send to the server
let fullName = user.profile.name
let givenName = user.profile.givenName
let familyName = user.profile.familyName
let email = user.profile.email
let dm = Datamanager.sharedInstance
dm.gplusEmail = email
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "RETURNED_GOOGLE"), object: nil)
// ...
} else {
print("\(error.localizedDescription)")
}
}
我在按钮的标志是一个UIButton
,在我的ViewController我这样已经实现:
@IBAction func googleClick(_ sender: UIButton) {
strLoggedWay="google"
GIDSignIn.sharedInstance().signIn()
}
请帮助我。我的代码过程出了什么问题?