Giter Club home page Giter Club logo

me.apla.cordova.app-preferences's Introduction

Application preferences Cordova plugin.

Store and fetch application preferences using platform facilities. Compatible with Cordova 3.x

Installing

From plugin registry:

$ cordova plugin add me.apla.cordova.app-preferences

From the repo:

$ cordova plugin add https://github.com/apla/me.apla.cordova.app-preferences

From a local clone:

$ cordova plugin add /path/to/me.apla.cordova.app-preferences/folder

More information: Command-line Interface Guide.

Using Plugman to Manage Plugins.

Synopsis

function ok (value) {}
function fail (error) {}


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');

Platforms

  1. Native execution on iOS using NSUserDefaults
  2. Native execution on Android using android.content.SharedPreferences
  3. Native execution on Windows Phone using IsolatedStorageSettings.ApplicationSettings
  4. Native execution on Windows 8 using IsolatedStorageSettings.ApplicationSettings
  5. (untested) fallback using localStorage

Notes

  1. iOS, Android and Windows Phone basic values (string, number, boolean) are stored using typed fields.
  2. Complex values, such as arrays and objects, are always stored using JSON notation.
  3. Dictionaries are supported on iOS and Windows 8 only, so on other platforms instead of using the real dictionary a composite key will be written like <dict>.<key>

Tests

Tests are available in src/test.js. After installing plugin you can add test code from this file and then launch testPlugin() function.

iOS, Android and Windows Phone 8 tests pass ok at the moment.

Preferences interface generator

You can find preliminary version of Settings.bundle generator in bin/build-app-settings.js.

Usage:

  1. Copy example settings JSON to your project folder: cp plugins/me.apla.cordova.app-preferences/app-settings.json .

  2. Edit JSON to include the controls you need...

  3. Generate settings resources with this command: node plugins/me.apla.cordova.app-preferences/bin/build-app-settings.js

  4. Add generated Settings.bundle to your iOS project.

Supported controls for iOS:

  • group
  • combo
  • switch
  • textfield

Supported controls for Android:

  • group
  • combo

Credits

Originally ported from: https://github.com/phonegap/phonegap-plugins/tree/master/iOS/ApplicationPreferences

Another android implementation for cordova 2.x: https://github.com/macdonst/AppPreferences

me.apla.cordova.app-preferences's People

Contributors

apla avatar kalyansky avatar

Watchers

joe beuckman avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.