当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Always logged in my android and ios app for mobile

问题描述:

I am developing ios and android application using java script. How to set my app always logged in state. For example,when i login in my app and then i just shutdown my device and then restart, then i click my app again,but it asks for log in. How to make my application always logged in as in Facebook app.Help me

网友答案:

Use Shared Preference for that. When user logged into your application store login status into sharedPreference and clear sharedPreference when user click on logged Out.

Check every time when user enter into application if user status from shared Preference is true then no need to login otherwise move to login page.

First create class in that class write all the functions set and get shared preference information or in javascript use localStorage to set and get values probably first time login to set userinfo using:

localStorage.setItem("name","vale");

after switch off you try to open your app, at the time use localStorage.getItem("name") based on that you can load your values.

分享给朋友:
您可能感兴趣的文章:
随机阅读: