Ionic start page depending on a condition


Hi, I am relatively new to ionic and building an app where I want to route the user to a input screen when he logs in for the first time and then to the standard login screen when he launches the app for the second time.
Links / Ideas anyone?
Thanks, EL


You would start with something like this

And then set up a login service like this


Thanks! I’ll have a look into that! :smile:


I’m interest in this functionnality.
i post principally for follow the post and have an update if the functionnaly sort :wink:

@elduderino15 : do you think is possible to have an easy facebook connect for ionic ?
(in my last test, phonegap plugin is not functionnaly and angular fb is not also… i don’t search so much…)


mhartington, I simply didnt undertand how that helps=\

I just want to understand how you define the ion-nav-view what state to load first.
I want it to check if the user have a auth token saved locally and based on that choose to load the “welcome” page or the “profile” page.

the closest i got was working with events. it worked but im still see a glimps of my welcome page before routing to the profile page.

Isnt there a simple way to tell the router what state to inject the ion-nav-view?
im stuck on that for hours and its shuold be the most simple thing.


So you need to break it down which is what the login page does. You could if you wanted to make it difficult and do it in the angular run function or tie a bunch of events together. But the best way is to have a type of landing controller. So you’d first navigate to like a /landing state that you make, and that controller will run the logic of testing the authentication and then depending on how that goes you just direct them to the next states whether it’s login or home.

In my app, I actually have my login page as my landing page, and it checks the authentication there and if it passes, it automatically logs them in and moves them along with $state.go(‘home’);

Also to make it cleaner for the user I programmatically hide the splash screen after I check the auth that way it doesn’t show the app moving between states.


I dont know if it is a beautiful solution, but just works for me. I store auth info in local storage, so in my app.config I put a condition like this:


If anyone have questions about my code, please let me know.



This solutions works on android but not iphone…any clue why?



in which function did u include like this?


if you are using $stateProvider, you have something like this

app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider .state(’’, {…

// authStuff code here