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!
Iām interest in this functionnality.
i post principally for follow the post and have an update if the functionnaly sort
@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ā¦)
thankā¦
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(window.localStorage[āauthStuffā]){
$urlRouterProvider.otherwise(ā/homeā);
}else{
$urlRouterProvider.otherwise(ā/loginā);
}
If anyone have questions about my code, please let me know.
if(window.localStorage[āauthStuffā]){
$urlRouterProvider.otherwise(ā/homeā);
}else{
$urlRouterProvider.otherwise(ā/loginā);
}
This solutions works on android but not iphoneā¦any clue why?
Thanks
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
});