I've successfully integrated Google Sign-In into my iOS app in my AppDelegate.swift file, and can successfully detect a successful sign-in (by printing "success" out onto the console). The issue is that after a successful sign-in, I'm back at the Google Sign-In page when I want to be in the next screen of the app.
The AppDelegate.swift file did not recognize the performSegue function, as it is a function of the UIViewController class (please correct me if I'm wrong). To get around this, I created a global variable in the ViewController file such that the segue would be performed whenever this value would be changed:
AppDelegate.swift:
var userSignedInGlobal = "n/a"
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
// A bunch of code that implements the Google Sign in ...
print("Successfully logged into Google.", user)
userSignedInGlobal = "success"
}
And then my InitialViewController.swift file:
class InitialViewController: UIViewController, GIDSignInUIDelegate {
var userSignedIn = userSignedInGlobal {
didSet {
performSegue(withIdentifier: "segueOne", sender: self)
}
}
// A bunch of irrelevant code.
}
This did not work, and the reason I think this didn't work is that userSignedInGlobal in the InitialViewController.swift file is being passed by reference - so even when its value changes, the value of userSignedIn does not change (again, please do correct me if I'm wrong).
To get around this, I changed my InitialViewController.swift file as follows:
var userSignedIn = userSignedInGlobal {
didSet {
doSegue()
}
}
class InitialViewController: UIViewController, GIDSignInUIDelegate {
func doSegue() {
performSegue(withIdentifier: "segueOne", sender: self)
}
// A bunch of irrelevant code.
}
This gave me an error in the third line: "Use of unresolved identifier 'doSegue()' "
I do not know how to go about performing the segue when the sign in is successful. Any help will be greatly appreciated, thanks in advance.