swift4
xcode9.2
Firebase
LogInViewControllerにあるFBログインボタンをタップして、
ポップアップの(Continue)を選択し、
(次へ)で進んだ後に、
異なるビューへ(NavigationController → RAMAnimatedTabBarController)
コードで遷移したいのですが上手く行きません。
不足箇所をご指摘して頂きたいです。
よろしくお願いします。
(AppDelegateです) import UIKit import Firebase import FirebaseAuth import GoogleSignIn import FBSDKCoreKit import RAMAnimatedTabBarController @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { print("アプリ起動時の処理だよ") FirebaseApp.configure() FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID GIDSignIn.sharedInstance().delegate = self return true } func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { var handled:Bool = false if url.scheme == "fb1014972461988152" { handled = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options) } else if url.scheme == "179603253813-oahjjd5qqh47ca5c7nvsoripcbn7kcvm" { handled = GIDSignIn.sharedInstance().handle(url, sourceApplication:options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String!, annotation: options[UIApplicationOpenURLOptionsKey.annotation]) } return handled } func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) { if let error = error { print(error.localizedDescription) return } print("Googleログインが成功したよ") guard let authentication = user.authentication else { return } let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken, accessToken: authentication.accessToken) Auth.auth().signIn(with: credential, completion: { (user, error) in if let error = error{ print(error.localizedDescription) return } print("Firebaseに正常にログインしたよ") })} func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) { } func applicationWillResignActive(_ application: UIApplication) { print("アプリ閉じそう") } func applicationDidEnterBackground(_ application: UIApplication) { print("アプリ閉じた") } func applicationWillEnterForeground(_ application: UIApplication) { print("アプリ開きそう") } func applicationDidBecomeActive(_ application: UIApplication) { print("アプリ開いた") FBSDKAppEvents.activateApp() //Facebookでも独自のカスタムイベントを定義して記録することができるようです。これいらないか } func applicationWillTerminate(_ application: UIApplication) { print("フリックしてアプリ終了") } }
(LogInViewControllerです) import UIKit import Firebase import FirebaseAuth import GoogleSignIn import FBSDKCoreKit import FBSDKLoginKit import RAMAnimatedTabBarController class LogInViewController: UIViewController, GIDSignInUIDelegate { @IBOutlet weak var GIDSignInButton: GIDSignInButton! @IBOutlet weak var FBSDKLoginButton:FBSDKLoginButton! override func viewDidLoad() { self.navigationItem.hidesBackButton = true super.viewDidLoad() GIDSignIn.sharedInstance().uiDelegate = self GIDSignIn.sharedInstance().signIn() } func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) { if let error = error { print(error.localizedDescription) return } // ... let credential = FacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString) Auth.auth().signIn(with: credential) { (user, error) in print("User Signed Into Firebase") } let storyboard: UIStoryboard = UIStoryboard(name: "RAMAnimatedTabBar", bundle: nil) let nextView = storyboard.instantiateInitialViewController() self.present(nextView!, animated: true, completion: nil) } func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,withError error: Error?) { if let error = error { print(error.localizedDescription) return } print("User signed into google") let authentication = user.authentication let credential = GoogleAuthProvider.credential(withIDToken: (authentication?.idToken)!, accessToken: (authentication?.accessToken)!) Auth.auth().signIn(with: credential) { (user, error) in print("User Signed Into Firebase") } let storyboard: UIStoryboard = UIStoryboard(name: "RAMAnimatedTabBar", bundle: nil) let nextView = storyboard.instantiateInitialViewController() self.present(nextView!, animated: true, completion: nil) } /* StoryboadでMailSignUpToFirstViewを引くため(戻るため)に必要 ボタン 戻る際の処理が特に必要ないのでメソッドは空です*/ func BackLogInView(segue: UIStoryboardSegue) { } }
回答1件
あなたの回答
tips
プレビュー