Login behaviours

You must Login before you can answer or comment on any questions.

I have a client which is asking different behaviours on a user logging in for first time or it is logging in for second time.. If the user login for the first time the view should be a login view where users put its username and password and second time it should not ask for username and password. I stored the username and password in app properties but then it is never showing the login view even after a clean build. Any help on how can i acheive this..Sorry if it is a trivial thing..Thanks in advance.

3 Answers

can you provide some sample code, because the approach you have outlined seems like it should be working?

in app.js

var userName = Ti.App.Properties.getString('username');
    alert(userName);// **shows the user name even after clean build**
    //construct UI
    if(userName ==''){
    Ti.include('ui/common/LoginView.js');
    } else {
    Ti.include('ui/common/View2.js');
    }
in LoginView
Ti.App.Properties.setString('username', loginField.value);
    Ti.App.Properties.setString('password', passwordField.value)

— answered 10 months ago by Shashank Dass
answer permalink
5 Comments
  • looking at the code above, I might suggest a slight edit

    // set default to empty string
    var userName = Ti.App.Properties.getString('username', '');
    change if statement use === not ==
    if(userName ===''){
        Ti.include('ui/common/LoginView.js');
        } else {
        Ti.include('ui/common/View2.js');
        }

    — commented 10 months ago by Aaron Saunders

  • tried it ..no luck :(

    — commented 10 months ago by Shashank Dass

  • what Stephan suggested below should wipe the app and the property should be gone if you are deleting the application. I am assuming this is IOS? You really should specify in the question.

    — commented 10 months ago by Aaron Saunders

  • Show 2 more comments

I stored the username and password in app properties but then it is never showing the login view even after a clean build.

App properties are not removed after a clean build. Only after an app uninstall.

— answered 10 months ago by Stephen Feather
answer permalink
3 Comments
  • Oh i see..so how to test this feature than.. how can you simulate the uninstall in the simulator.

    — commented 10 months ago by Shashank Dass

  • long press the icon in the springboard, delete, just like you would on device

    — commented 10 months ago by Stephen Feather

  • Thanks Stephen...i tried this..it is still giving the alert with the previous user name..

    — commented 10 months ago by Shashank Dass

Your Answer

Think you can help? Login to answer this question!