I first use GoogleSignIn SDK for login phrase. Then, I use the following code for redirecting to the homepage of my apps.
self.present(tabController, animated: true, completion: nil)
Here is the structure of my app (I use storyboard):
TabBarController
- NavigationBarController (Homepage): View Controllers
- NavigationBarController (Function 1): View Controllers
- NavigationBarController (Function 2): View Controllers
- NavigationBarController (Profile): View Controllers
Now that I have logged in, I would like to pass the data from google to my profile root view controller. Yet, I am not sure how to do that.
Here is my current code, that I have put in func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!):
let tabController: UITabBarController = self.storyboard?.instantiateViewController(withIdentifier: "homepageVC") as! UITabBarController
let navController: UINavigationController = self.storyboard?.instantiateViewController(withIdentifier: "homepageVC2") as! UINavigationController
let vc = navController.viewControllers[0] as! ViewController
tabController.modalPresentationStyle = .fullScreen
vc.name = fullName
self.present(tabController, animated: true, completion: nil)
** where fullName is the global variable in my LoginViewController, which contains user.fullName (from google).
But of coz, it does not work. I hope someone can help me out with this. Many thanks.