swift3でGoogleアカウント連携を開発してます。
GoogleアカウントでFirebaseサインインまではできているのですが、サインイン後の処理をAppDelegateで以下のように記載しています。
Firebaseサインイン直後に、サインイン画面のloginViewControllerで戻って処理したいのですがやり方がわかりませんので、ご教授ください。
func sign(_ signIn: GIDSignIn!, dismiss viewController: UIViewController!)
で処理するのかと思いました、以下のFirebaseサイン処理する前に処理され正常に動作しません。
AppDelegateで以下の処理をしています。
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) { 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) Auth.auth().signIn(with: credential) { (user, error) in if let error = error { print(error.localizedDescription) return } print("User is signed in") let storyboard = UIStoryboard(name: "Main", bundle: nil) let mainVC = storyboard.instantiateViewController(withIdentifier: "main") as! mainViewController self.window?.rootViewController?.present(mainVC, animated: true, completion: { print("change") }) } }
loginViewControllerで以下の処理を記載するも、上記の前に処理されログイン状態で処理されません。
func sign(_ signIn: GIDSignIn!, dismiss viewController: UIViewController!) { // サインウインドウが閉じたあとの処理 print("DEBUG:GIDSignIn dismiss!!!") if let user = Auth.auth().currentUser { hogehogeJob() } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。