Abo*_*ths 27 authentication viewcontroller ios firebase swift
因此,我的应用可以选择使用Google登录.单击Google提供的按钮后,将打开Web视图并让用户输入其凭据.在允许应用访问他们的信息后,应用程序然后签署用户并将SignInViewController更改为TabBarController(他们现在可以相应地进行交互).
当用户按下"注销"按钮时,他们会按照预期被定向到登录屏幕.但奇怪的是,如果用户再次按下谷歌按钮,他们会自动登录,根本没有进一步的身份验证,也没有选择删除他们的帐户.他们是否有办法清除谷歌帐户凭据以保护用户免遭意外盗窃?
登录功能:
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
if let error = error {
print(error.localizedDescription)
return
}
let authentication = user.authentication
let credential = FIRGoogleAuthProvider.credentialWithIDToken(authentication.idToken, accessToken: authentication.accessToken)
FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
// ...
SignInViewController().signedIn(user)
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
退出功能:
func signOutOverride() {
do {
try! FIRAuth.auth()!.signOut()
CredentialState.sharedInstance.signedIn = false
// Set the view to the login screen after signing out
let storyboard = UIStoryboard(name: "SignIn", bundle: nil)
let loginVC = storyboard.instantiateViewControllerWithIdentifier("SignInVC") as! SignInViewController
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window?.rootViewController = loginVC
} catch let signOutError as NSError {
print ("Error signing out: \(signOutError)")
}
}
Run Code Online (Sandbox Code Playgroud)
Rah*_*tel 50
迅速
尝试 GIDSignIn.sharedInstance().signOut()
目标 - c
[[GIDSignIn sharedInstance] signOut];
Run Code Online (Sandbox Code Playgroud)
小智 12
是的,就像@Rahul所说,下面的代码将是正确的方式.
GIDSignIn.sharedInstance().signOut()
Run Code Online (Sandbox Code Playgroud)
https://developers.google.com/identity/sign-in/ios/sign-in?ver=swift#sign_out_the_user
| 归档时间: |
|
| 查看次数: |
13606 次 |
| 最近记录: |