(我是本土的iPhone开发者 - Phonegap / Cordova的新手)
对于某些设置或首选项,我们在本机iOS中使用NSUserDefaults。使用webviews和phonegap时是否有相应的内容? 在此先感谢。
答案 0 :(得分:1)
有Application preferences Cordova plugin。
function ok (value) {}
function fail (error) {}
var prefs = plugins.appPreferences;
// cordova interface
// 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');
// remove value by key
prefs.remove (ok, fail, 'key');
// show application preferences
prefs.show (ok, fail);
// instead of cordova interface you can use promise interface
// you'll receive promise when you won't pass function reference
// as first and second parameter
// fetch the value for a key using promise
prefs.fetch ('key').then (ok, fail);
// support for iOS suites (untested)
var suitePrefs = prefs.iosSuite ("suiteName");
suitePrefs.fetch (...);
suitePrefs.store (...);