Search code examples
iosiphoneswiftfbsdkgidsignin

App workflow of iOS app


I am making an app with 2 navigation controllers in storyboard. 1st one is LoginRootController and 2nd is RootController.

LoginRootController is set as the initial view controller. I have google and facebook login integrated to the app. Their delegates are in AppDelegate. When I login, I set RootController as rootViewController which has the home page. I'm setting this from loginButton() of FBSDK and "signIn(signIn: didSignInForUser user: withError error:)" google delegate function. There is signInSilently() and fb sign in in applicationDidBecomeActive.

The problem is that whenever signIn is called, my home page is loaded. I want to load home page only once when I login manually. What is the optimal way to do this?


Solution

  • I understand that you want to avoid reloading the RootController after a silent sign in triggered by the application becoming active.

    The easy option is to check the current rootViewController. If it's already the RootController, no need to change it. Otherwise, change it.

    Note that you probably want to save the user ID that was used to load the RootController. If that changes, you probably need to force reloading it even if it's already there.

    If that's not what you want, you'll need to be more explicit and provide the relevant parts of your code.