我是这个iOS/phonegap技术的新手.我正在使用phonegap处理iPhone/iOS应用程序.它有一个登录页面,其中包含两个文本字段"用户名"和"密码".
<input type="text" class="form-control input-lg user_name" id="txtUserName" placeholder="Username" />
<input type="password" class="form-control input-lg pass_word" id="txtPassword" placeholder="Password" />
<button id="btnLogin" class="large color blue button login_top btn-block" type="submit" value="Login">Login</button>
Run Code Online (Sandbox Code Playgroud)
在$(document).ready(function()登录处理执行.
现在我想保存用户的电子邮件地址.即当我退出时它应该记住电子邮件地址,因此不必再次输入.
我正在使用phonegap进行开发.我经历了很多链接,发现可以使用1. NSUserDefaults 2. KeyChain完成
我正在考虑使用NSUserDefaults,但我不了解如何实现这个东西.即由于这是本机c代码,我们必须在appDelegate.m文件中编写.我对吗?然后如何将此代码链接到我的登录页面?
任何人都可以给我发送完整的代码来实现这个功能.我的意思是我需要在appdelegate中添加并将该代码链接到我的登录页面的代码.
如果您或其他人需要它,有一个cordova插件:https: //github.com/apla/me.apla.cordova.app-preferences/
cordova plugin add me.apla.cordova.app-preferences
Run Code Online (Sandbox Code Playgroud)
来自它的网站的示例:
var prefs = plugins.appPreferences;
// store key => value pair
prefs.store (ok, fail, 'key', 'value');
// store key => value pair in dict (see notes)
prefs.store (ok, fail, 'dict', 'key', 'value');
// fetch value by key (value will be delivered through "ok" callback)
prefs.fetch (ok, fail, 'key');
// fetch value by key from dict (see notes)
prefs.fetch (ok, fail, 'dict', 'key');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2241 次 |
| 最近记录: |