Giter Site home page Giter Site logo

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

Application preferences plugin for Cordova 3+

Why you should use this plugin?

  • Cordova + Promise interface out of the box
  • Supports many platforms (Android, iOS/macOS, Windows and local storage fallback)
  • Have tests (iOS: iOS and browser status, Android: Android status, Windows: Windows status, Browser: iOS and browser status)
  • Supports simple and complex data structures
  • Supports removal of the keys
  • Have preference pane generator for application (for Android and iOS) and can show native preferences
  • (Untested) reference change notification #37
  • (Untested) named preferences files for android and iOS suites #97
  • (Untested) synchronized preferences via iCloud or windows roaming #75

Installing

From plugin registry:

$ cordova plugin add cordova-plugin-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

#97

More information: Command-line Interface Guide.

Using Plugman to Manage Plugins.

Synopsis

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

Suites

// support for iOS suites or android named preference files (untested)
var suitePrefs = prefs.suite ("suiteName");
suitePrefs.fetch (...);
suitePrefs.store (...);

// store preferences in synchronized cloud storage for iOS and windows
var cloudSyncedPrefs = prefs.cloudSync ();
cloudSyncedPrefs.fetch (...);
cloudSyncedPrefs.store (...);

Platforms

  1. Native execution on iOS/macOS using NSUserDefaults — docs for iOS / macOS
  2. Native execution on Android using android.content.SharedPreferencesdocs
  3. Native execution on Windows Universal Platform using Windows.Storage.ApplicationDatadocs
  4. Native execution on Windows Phone 7 using IsolatedStorageSettings.ApplicationSettingsdocs
  5. Execution on BlackBerry10 fallback using localStorage

Notes

  1. iOS, macOS, 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>
  4. On iOS/macOS dictionaries just a key, so appPrefs.store ('dict', 'key', value) and appPrefs.store ('dict', {'key': value}) have same meaning (but different result).

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 pass locally, Travis: iOS and browser status
  • Android pass locally, CircleCI: Android status
  • BlackBerry 10 pass locally
  • Windows Phone 8 tests pass locally, Appveyor: Windows status
  • Browser pass locally, Travis: iOS and browser status

Module update for cordova < 5.x

Please note that plugin id is changed for npm publishing, so if you used this plugin before [email protected], you'll have to reinstall it:

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

Show Preference pane

If you have generated preferences, you can programmatically show preference pane (Android and iOS at this time). On Android your application show native interface for preferences, on iOS you'll be switched to the Settings.app with application preferences opened for you. Either way, you must listen for Cordova resume event to perform preferences synchronization.

Preferences interface generator

Preferences generator installed along with plugin and run every time when you prepare you cordova app.

After plugin installation you can find file app-settings.json within your app folder.

If you want to disable this functionality, please remove app-settings.json.

iOS note: if you have Settings.bundle from external source or previous version of generator cordova prepare will fail. Current version of preference generator trying not to rewrite existing Settings.bundle if it is not generated by plugin. It is save to remove Settings.bundle if it came from previous version of plugin.

Supported controls for iOS:

  • group
  • combo
  • switch
  • textfield

Supported controls for Android:

  • group
  • combo
  • switch - not tested
  • textfield - not tested

TODO: Preferences UI for Windows Phone (guide, docs)

Credits

Original version for iOS: 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 bitflower avatar centvrio avatar fiveironfrnzy08 avatar gcoupelant avatar jesusgollonet avatar josx avatar jrobichaud avatar kalyansky avatar kmd-jamesgauld avatar micky2be avatar pcbl avatar shankari avatar thomashilzendegen avatar tripodsan avatar umcsdon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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

Clean cordova project ENOENT error

Hi,

cordova create prefTest com.example.pref prefTest
cd prefTest
cordova plugin add cordova-plugin-app-preferences
cordova platform add android

gives me this:
Error: ENOENT, open 'platforms/android/src/me/apla/cordova/AppPreferencesActivity.java'
at Error (native)

Cordova 5.3.1
NodeJS 0.12.7

I came across this because I couldn't get the plugin to run on my existing IONIC app.
@DavidePastore asked to try a clean Cordova setup.

Any ideas?

Are there any examples?

The documentation is a little thin. I don't really even know where to get started. Are there any examples?

Null value for all keys

I think I might be misunderstanding how to implement this plugin. All keys return null, even after a "successful" store. Is there some setup of keys prior to using this module that is necessary for its use? Testing primarily on iOS.

private mode

It would be nice to be able to set the preference file as private.

For Android:
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(cordova.getActivity(), Context.MODE_PRIVATE);

Not sure if or how other systems offer private mode.

Version on plugin registry does not match any public repo commit

I've just installed the plugin through the plugin registry (cordova plugin add me.apla.cordova.app-preferences) and i got v0.4.2.

I tried to follow instructions but when i executed build-app-settings i got the following error:

/Volumes/Storage/nicolas/Development/projects/coqs/launcher/plugins/me.apla.cordova.app-preferences/bin/build-app-settings.js:27
            toggle: {
            ^^^^^^
SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:929:3

The error is quite obvious in the offending code:

#!/usr/bin/env node

var fs     = require('fs');
var plist  = require('plist');
var libxml = require('libxmljs');

function ucfirst(s) {
    return s.charAt(0).toUpperCase() + s.substring(1);
}

function SettingsGenerator () {

    this.config = {
        ios: {
            root: "PreferenceSpecifiers",
        },
        types: {
            group: {
                iosType: "PSGroupSpecifier",
            },
            select: {
                iosType: "PSMultiValueSpecifier",
            },
            radio: {
                iosType: "PSRadioGroupSpecifier",
            } // <----- HERE A MISSING COMMA
            toggle: {
                iosType: "PSToggleSwitchSpecifier",
                types: "boolean",
            },
            text: {
                iosType: "PSTextFieldSpecifier",
                types: "string",
            },
            slider: {
                iosType: "PSSliderSpecifier",
                types: "float",
            }

        }

    };
}

...

I was gonna fix it but i couldn't find the code in the repo. I checked the whole history and i didn't find any trace of the offending code.

Which leads to a big question, where does the plugin registry version come from ?

"no mapping for switch" error

v0.6.1

When following the readme file of Preferences interface generator for testing I'm getting the "no mapping for switch" error.

build-app-settings.js fails

> node plugins/cordova-plugin-app-preferences/bin/build-app-settings.js
cordova error { [Error: Cannot find module 'cordova/node_modules/cordova-lib/src/cordova/util'] code: 'MODULE_NOT_FOUND' }
module.js:338
    throw err;
          ^
Error: Cannot find module 'plist'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/[...]/plugins/cordova-plugin-app-preferences/bin/build-app-settings.js:34:15)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

No stored values after application reload

Hello,

plugin works on latest cordova 5.0.0 apps, but when I restart the application (or reload app's webview), nothing is stored in preferences anymore. During application lifecycle it's OK.

Bye

(dict != "") does not work in java

this is all over the place in /src/android/AppPreferences.java
if (dict != "")
is always true, because no string ever will be the same object as "".
correct would be
if ("".equals(dict))

as all apps currently store keys without a dict as .key, I would suggest you simply remove the check or replace it with if (true) for compatibility.

iOS build broken under 0.7.3 and 0.6.3

After installing the plugin, cordova build ios doesn't produce any output and after_build hooks are not executed.

The problem seems to be in ios.js, lines 77 to 81:

proj.parse(function (err) {
err ?
defer.reject(err) :
defer.resolve(proj);
});

The parse function never executes its callback so the promise won't be resolved nor rejected.

Event on update

Could be nice to receive an event when a property has been modified.
It would allow us to react based on it.

blackberry 10 share-social plugin

hi apla, i am a novice programmer and new to this and i guess am posting this in the wrong place but i need ur help in impleting your plugin on blackberry 10 ( me.apla.cordova.share-social). i have downloaded the code (src/blackberry10/index.js, share-social.js and plugin.xml) but i do not know how to call the share function from my code.

i have created a mobile app using blackberry webworks and cordova 2.6. i needed to include a share functionality and i am on a short timeframe. pls ur assistance will be greatly appreciated. this is my email [email protected]

Android preferences not being created

Hi I've recently pulled this module to my project from git repo,and noticed that the template given app-settings.js does not render more than just simple

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"/>

I've localized the source of said issue, the aData object variable is loosing it's contents few lines above being used for android preferenceScreen rendering code.

Quick fix follows:
either clone the iosData or do this on line 129

var iosData = JSON.parse(data);
var aData = JSON.parse(data);

instead of

var iosData = JSON.parse(data);
var aData = iosData;

as the iosData is being shifted,unshifted few lines below and for some reason it makes only (aData to iosData) reference to the same array/object so both loose content one ios Setting.bundle is done rendering.

This solution fixes android preferencesScreen from being rendered empty while ios Settings.bundle is rendered correctly.

Thanks,
Lukas

Settings.bundle for iOS is put in the wrong folder

I believe Settings.bundle is supposed to live inside platform/ios/MYPROJECT/Resources/ not platform/ios/MYPROJECT/

After adding the plugin I can't build because of this, moving the file to /Resources resolves the problem:
** BUILD FAILED **
The following build commands failed:
CpResource MYPROJECT/Resources/Settings.bundle build/emulator/MYPROJECT.app/Settings.bundle
(1 failure)

bildschirmfoto 2015-11-11 um 06 19 06

Bug of npm xcode?

java.lang.RuntimeException in function onSharedPreferenceChanged() in file AppPreferences.java:39

Hello,

since yesterday I experienced an exception when using your plugin on an android device. Could you please elaborate on this and fix this issue?

Thank you!

Stack trace:

java.lang.RuntimeException: java.lang.Throwable: A WebView method was called on thread 'pool-2-thread-5'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {3b9ad6dd} called on null, FYI main Looper is Looper (main, tid 1) {3b9ad6dd})
at android.webkit.WebView.checkThread(WebView.java:2221)
at android.webkit.WebView.loadUrl(WebView.java:866)
at org.apache.cordova.CordovaWebView.loadUrlNow(CordovaWebView.java:458)
at org.apache.cordova.CordovaWebView.loadUrl(CordovaWebView.java:357)
at me.apla.cordova.AppPreferences$1.run(AppPreferences.java:39)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.Throwable: A WebView method was called on thread 'pool-2-thread-5'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {3b9ad6dd} called on null, FYI main Looper is Looper (main, tid 1) {3b9ad6dd})
at android.webkit.WebView.checkThread(WebView.java:2211)
at android.webkit.WebView.loadUrl(WebView.java:866)
at org.apache.cordova.CordovaWebView.loadUrlNow(CordovaWebView.java:458)
at org.apache.cordova.CordovaWebView.loadUrl(CordovaWebView.java:357)
at me.apla.cordova.AppPreferences$1.run(AppPreferences.java:39)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

Support for Cordova 5.0.0?

Any plans to add support for Cordova 5.X in the near future?

This plugin looked very promising, but according to the README which says it supports Cordova 3.x and my initial testing it's not working very well with Cordova 5.0.0.

In Windows, I have managed to call plugins.appPreferences.store() successfully, but when I retrieve the key value with plugins.appPreferences.fetch() I always get boolean true back no matter what value I stored.

In iOS 8 appPreferences isn't even available on the plugins object.

Regards,
Mattias

Android api 19 kitkat error

Hey I'm no sure if I have something setup incorrectly. I have tried this on android API 21 and above and it works fine, however on 19 I can't get it to work.. I get a “Window already focused, ignoring focus gain of:” when i try to open the preferences .

How to use build-app-settings.js?

I would like to work on the Settings plist generator. Are you running build-app-settings.js in your Cordova build? If not, how should I run it?

Android no value for key

Hi this behaves differently on Android to iOS.

On iOS if there is no value when fetching a key null is returned to the success callback, on android the errorCallback is called

line 145 :
if (sharedPrefs.contains(key)) {
....

line 177 :
} else {
// Log.d("", "no value");
callbackContext.error(0);
// callbackContext.sendPluginResult(new PluginResult ());
}

To rectify and fit my needs I changed this in the else
line 177 :
} else {
// Log.d("", "no value");
callbackContext.success(returnVal);
}

as returnVal is declared as null on line 144.

In my personal opinion I think its better for them both to return null to the success callback rather than the call the error callback

Preference pane with graceful degradation

If platform supports native preference pane, show it. Otherwise, display HTML form

For Android and iOS return to app from preference pane generates cordova resume event. This is unsupported for HTML form. Need to think about uniform API or event for preferences change. probably #37

  • Android preference activity
    • generation
    • show programatically
  • iOS preference pane
    • generation
    • switch programatically
  • Windows Store Desktop preference pane
    • generation
    • show programatically
  • HTML form fallback
    • generation
    • show programatically

Name attribute is regarded undefined during app build

after fix 39 the code is successfully generated, bt during building the app i get this error
during testing before issue 39 i had also skipped th loop with an if statement but reverted cause i thought that there was sth else wrong.
btw i m testing this on android


mypath\platforms\android\build\intermediates\res\deb
ug\xml\apppreferences.xml:4: error: Error: No resource found that matches the gi
ven name (at 'entries' with value '@apppreferences_strings/measurementunit').

mypath\platforms\android\build\intermediates\res\deb
ug\xml\apppreferences.xml:4: error: Error: No resource found that matches the gi
ven name (at 'entryValues' with value '@apppreferences_strings/measurementunitValues')
.

:processDebugResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':processDebugResources'.

    com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    mypath\AppData\Local\Android\sdk\build-tools\21.1.2\aapt.exe pac
    kage -f --no-crunch -I mypath\AppData\Local\Android\sdk\platforms\androi
    d-22\android.jar -M mypath\platforms\android\build\i
    ntermediates\manifests\full\debug\AndroidManifest.xml -S mypath\MYAPP\platforms\android\build\intermediates\res\debug -A MYPATH
    \MYAPPEn\platforms\android\build\intermediates\assets\debug -m -J D:\Ni
    kos\workspace\MYAPPEn\platforms\android\build\generated\source\r\debug -
    F mypath\platforms\android\build\intermediates\res\r
    esources-debug.ap_ --debug-mode --custom-package com.nickpapanik.v_stromrescueen
    -0 apk --output-text-symbols mypath\platforms\andro
    id\build\intermediates\symbols\debug
    Error Code:
    1
    Output:
    mypath\platforms\android\build\intermediates
    \res\debug\xml\apppreferences.xml:4: error: Error: No resource found that matche
    s the given name (at 'entries' with value '@apppreferences_strings/measurementunit').

    mypath\platforms\android\build\intermediates
    

    \res\debug\xml\apppreferences.xml:4: error: Error: No resource found that matche
    s the given name (at 'entryValues' with value '@apppreferences_strings/measurementunit
    Values').

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug
    option to get more log output.

BUILD FAILED

Total time: 15.788 secs

mypath\platforms\android\cordova\node_modules\q\q.js
:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "mypath\MYAPP
En\platforms\android\gradlew cdvBuildDebug -b mypath
\platforms\android\build.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: cmd: Command failed with exit code 8

You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 8
at ChildProcess.whenDone (mypath\AppData\Roaming\npm\node_modules\co
rdova\node_modules\cordova-lib\src\cordova\superspawn.js:134:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5))

cordova.exec.bind [undefined]

On an old android device, I have "TypeError: Resulst of expression 'cordova.exec.bind' [undefined] is not a function. at file:///android_[...]apppreferences.js:29

That error refers to:
platform.nativeExec = cordova.exec.bind (cordova);

It prevents "deviceready" event to be fired...

before_build hook issue

facing a small issue cause after #50
if i remove and re-add android platform getting following error -

Error: ENOENT, open 'platforms/android/src/me/apla/cordova/AppPreferencesActivity.java'
    at Error (native)

perhaps moving the hook to before_build might help?

I don't add platform directory to version control. I also do customization on plugins and sometimes need to reset platform directory.

got very strange test results

testPlugin();

[Error] fetched incorrect value for xint-test: expected 1 got null
[Error] fetched incorrect value for xstring-test: expected "xxx" got null
[Error] fetched incorrect value for xobj-test: expected {"a":"b"} got null
[Error] fetched incorrect value for xempty-string-test: expected "xxx" got null
[Error] fetched incorrect value for xarr-test: expected ["a","b"] got null
[Log] 35 tests passed
[Error] 5 tests failed

testPlugin();

[Error] fetched incorrect value for xint-test: expected 1 got null
[Error] fetched incorrect value for xobj-test: expected {"a":"b"} got null
[Error] fetched incorrect value for xarr-test: expected ["a","b"] got null
[Error] fetched incorrect value for xstring-test: expected "xxx" got null
[Log] 36 tests passed
[Error] 4 tests failed

testPlugin();

[Error] fetched incorrect value for xint-test: expected 1 got null
[Log] 39 tests passed
[Error] 1 tests failed

testPlugin();

[Log] 40 tests passed

testPlugin();

[Log] 40 tests passed

testPlugin();

[Log] 40 tests passed

Plugin add is broken for node 0.10.x

Hi,

I have phonegap 5.4.0 and cordova 5.3.7,
I am trying to add this plugin but I always get this error :

sudo phonegap cordova plugin add cordova-plugin-app-preferences
Fetching plugin "cordova-plugin-app-preferences" via npm

Installing "cordova-plugin-app-preferences" for ios

Error during processing of action! Attempting to revert...

Failed to install 'cordova-plugin-app-preferences':TypeError: Uh oh!
Object # has no method 'parse'
at module.exports.common.js-module.install (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/plugman/platforms/common.js:131:71)
at /usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/platforms/PlatformApiPoly.js:653:27
at Object.ActionStack.process (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-common/src/ActionStack.js:56:25)
at PlatformApiPoly.addPlugin (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/platforms/PlatformApiPoly.js:259:20)
at handleInstall (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:603:6)
at /usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:382:28
at _fulfilled (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/q/q.js:749:13)
at /usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/q/q.js:509:49

Error: Uh oh!
Object # has no method 'parse'

thanks for your support,

Stéphane

The latest version from master does not work on Android, only on iOS

Had to fork off the latest tag to fix the following:
[javac] Compiling 32 source files to /Users/ishaigorodsky/Workspace/git/ceMobileApp/platforms/android/ant-build/classes
[javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
[javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
[javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
[javac] /Users/ishaigorodsky/Workspace/git/ceMobileApp/platforms/android/src/me/apla/cordova/AppPreferences.java:18: error: cannot find symbol
[javac] import me.apla.cordova.AppPreferencesActivity;
[javac] ^
[javac] symbol: class AppPreferencesActivity
[javac] location: package me.apla.cordova
[javac] /Users/ishaigorodsky/Workspace/git/ceMobileApp/platforms/android/src/me/apla/cordova/AppPreferences.java:82: error: cannot find symbol
[javac] Intent i = new Intent(cordova.getActivity(), AppPreferencesActivity.class);
[javac] ^
[javac] symbol: class AppPreferencesActivity
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors
[javac] 3 warnings

placing xml file?

hi, i can't workout where the xml file with the value pairs should be placed..
i m getting an error [aapt] D:\path\to\project\platforms\android\res\xml\pref_ge
neral.xml:9: error: Error: No resource found that matches the given name (at 'en tries' with value '@array/measurementunit'). [aapt] D:\path\to\project\platforms\android\res\xml\pref_ge neral.xml:9: error: Error: No resource found that matches the given name (at 'en tryValues' with value '@array/measurementunitValues').

http://stackoverflow.com/questions/26205674/apache-cordova-application-preferences-apla

Syntax for list preferences

my application json

[
    {
        "type":"group",
        "title":"Measurement Units",
        "key":"measurement_units",
        "description":"Define which measurement unit is prefered",
        "items":[
            {
                "type":"radio",
                "items":[
                    {
                        "value":"kilometers_litres",
                        "title":"Use kilometers / litres"
                    },
                    {
                        "value":"miles_gallons",
                        "title":"Use miles / gallons"
                    }
                ],
                "default":"kilometers_litres",
                "title":"Measurement unit",
                "key":"measurement_unit",
                "name":"measurementunit"
            }
        ]
    }
]

and the error

mypath\plugins\cordova-plugin-app-preferences\bin\li
b\mobile_preferences.js:274
                config.attrs[attr] = config.attrs[attr].join ('|');
                                                        ^
TypeError: Object @apppreferences_strings/measurementunit has no method 'join'
    at androidBuildNode (mypath\plugins\cordova-plugin-app-preferences\bin\lib\mobile_preferences.js:274:43)
    at mypath\plugins\cordova-plugin-app-preferences\bin\lib\mobile_preferences.js:287:4
    at Array.forEach (native)
    at androidBuildNode (mypath\plugins\cordova-plugin-app-preferences\bin\lib\mobile_preferences.js:286:19)
    at mypath\plugins\cordova-plugin-app-preferences\bin\lib\mobile_preferences.js:312:3
    at Array.forEach (native)
    at Object.androidBuildSettings (mypath\plugins\cordova-plugin-app-preferences\bin\lib\mobile_preferences.js:303:13)
    at mypath\plugins\cordova-plugin-app-preferences\bin\build-app-settings.js:80:32
    at fs.js:272:14
    at C:\Users\project\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:103:5

Apache cordova plugin for social sharing

Hi ,

We are doing apache cordova build for our app , our app has social sharing feature which is not working in blackberry 10 build which is done using ripple emulator, so kindly suggest any good plugin for social sharing for blackberry.

strict mode triggers F09 AppPreferences787674544 n0 cordova.js:1046

Hi Ivan

I ran into the following error with the plugin while using strict mode.
Please let me know how this can be fixed.

Thank you,
Irena

processMessage failed: Message: F09 AppPreferences787674544 n0 cordova.js:1046
processMessage failed: Error: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them cordova.js:1044
processMessage failed: Stack: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
at Object.checkArgs (file:///android_asset/www/cordova.js:410:84)
at Object.Analytics.sendException (file:///android_asset/www/plugins/com.cmackay.plugins.googleanalytics/www/analytics.js:217:15)
at Object.fnSendException as sendException
at errorCallback (file:///android_asset/www/scripts/services/utilityServices.js:133:61)
at Object.cordova.callbackFromNative (file:///android_asset/www/cordova.js:294:48)
at processMessage (file:///android_asset/www/cordova.js:1039:21)
at Function.androidExec.processMessages (file:///android_asset/www/cordova.js:1076:13)
at pollOnce (file:///android_asset/www/cordova.js:944:17)
at pollOnceFromOnlineEvent (file:///android_asset/www/cordova.js:939:5) cordova.js:1045

trying it out...

First, thanks so much for making this work in 3.0!

Here's what I've discovered: I had to make a minor change to .js file. Something about that block didn't work. I made the dict value required which hard-coded the argList and thinned out the error checking. Not sure that the prepareKey is necessary if you require the params. I'm just hacking it for my use and I barely know what I'm doing... you can adjust as necessary:

AppPreferences.prototype.prepareKey = platform.prepareKey || function (mode, dict, key, value) {
var argList = [].slice.apply(arguments);
argList.shift();
if ((mode == 'get') || (mode == 'set')) { argList.unshift (void 0); }
var args = { key: argList[1] };
if (argList[0] !== void 0) args.dict = argList[2];
if (mode == 'set') args.value = argList[3];
return args;
}

then I was able to get the following to work in PhoneGap 3.1

window.plugins.AppPreferences.fetch(function(ok) { alert(ok); }, function(err) { alert(err); }, 'itunes', 'itunes');

window.plugins.AppPreferences.store(function(ok){}, function(err){ alert(err); }, 'itunes', 'itunes', '[email protected]' );

PS: when checking the Settings Preferences on my iPhone 5, the value is enclosed in Double-Quotes. I was not able to fix that as I'm already at the outer reaches of my programming capabilities.

Unable to build for iOS

Hi Ivan
I was so excited to find the plugin that will do the work of native preferences for me. I am able to build the app for Android. However, for iOS building on Yosemete resulted in the following errors.

Thanks you in advance,
Irena

Заранее спасибо

PhaseScriptExecution Copy\ www\ directory build/myApp.build/Debug-iphonesimulator/myApp.build/Script-304B58A110DAC018002A0835.sh
cd ~/Workspace/git/myApp/platforms/ios
/bin/sh -c ~/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/Script-304B58A110DAC018002A0835.sh

real 0m0.207s
user 0m0.084s
sys 0m0.121s

ProcessInfoPlistFile build/emulator/myApp.app/Info.plist myApp/myApp-Info.plist
cd ~/Workspace/git/myApp/platforms/ios
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin:/opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin/:/usr/local/mysql/bin:/Applications/p4merge.app/Contents/MacOS/:/Applications/Android Studio.app/sdk/tools:/Applications/Android Studio.app/sdk/platform-tools:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-infoPlistUtility ~/Workspace/git/myApp/platforms/ios/myApp/myApp-Info.plist -genpkginfo ~/Workspace/git/myApp/platforms/ios/build/emulator/myApp.app/PkgInfo -expandbuildsettings -format binary -platform iphonesimulator -additionalcontentfile ~/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/MainViewController-PartialInfo.plist -o ~/Workspace/git/myApp/platforms/ios/build/emulator/myApp.app/Info.plist

CompileC build/myApp.build/Debug-iphonesimulator/myApp.build/Objects-normal/i386/CDVStatusBar.o myApp/Plugins/org.apache.cordova.statusbar/CDVStatusBar.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Workspace/git/myApp/platforms/ios
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin:/opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin/:/usr/local/mysql/bin:/Applications/p4merge.app/Contents/MacOS/:/Applications/Android Studio.app/sdk/tools:/Applications/Android Studio.app/sdk/platform-tools:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch i386 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=c99 -fobjc-arc -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-implicit-atomic-properties -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -fexceptions -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -fvisibility=hidden -Wno-sign-conversion -fobjc-abi-version=2 -fobjc-legacy-dispatch -mios-simulator-version-min=6.0 -iquote /Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/myApp-generated-files.hmap -I/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/myApp-own-target-headers.hmap -I
/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/myApp-all-target-headers.hmap -iquote /Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/myApp-project-headers.hmap -I/Workspace/git/myApp/platforms/ios/build/emulator/include -I~/Workspace/git/myApp/platforms/ios/build/emulator/usr/local/lib/include -I~/Workspace/git/myApp/platforms/ios/build/UninstalledProducts/include -I~/Workspace/git/myApp/platforms/ios/build/emulator -I~/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/DerivedSources/i386 -I~/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/DerivedSources -F~/Workspace/git/myApp/platforms/ios/build/emulator -include /var/folders/3h/9c4nf4vs3qbd916nc_ms9zr40000gn/C/com.apple.DeveloperTools/6.1-6A1052d/Xcode/SharedPrecompiledHeaders/myApp-Prefix-askhkaisnqgjcxgnfxlodqmsjfsq/myApp-Prefix.pch -MMD -MT dependencies -MF ~/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/Objects-normal/i386/CDVStatusBar.d --serialize-diagnostics ~/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/Objects-normal/i386/CDVStatusBar.dia -c ~/Workspace/git/myApp/platforms/ios/myApp/Plugins/org.apache.cordova.statusbar/CDVStatusBar.m -o /Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/Objects-normal/i386/CDVStatusBar.o
clang: error: no such file or directory: '
/Workspace/git/myApp/platforms/ios/myApp/Plugins/org.apache.cordova.statusbar/CDVStatusBar.m'
clang: error: no input files
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

CompileC build/myApp.build/Debug-iphonesimulator/myApp.build/Objects-normal/i386/AppPreferences.o myApp/Plugins/me.apla.cordova.app-preferences/AppPreferences.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Workspace/git/myApp/platforms/ios
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin:/opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin/:/usr/local/mysql/bin:/Applications/p4merge.app/Contents/MacOS/:/Applications/Android Studio.app/sdk/tools:/Applications/Android Studio.app/sdk/platform-tools:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch i386 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=c99 -fobjc-arc -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-implicit-atomic-properties -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -fexceptions -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -fvisibility=hidden -Wno-sign-conversion -fobjc-abi-version=2 -fobjc-legacy-dispatch -mios-simulator-version-min=6.0 -iquote /Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/myApp-generated-files.hmap -I/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/myApp-own-target-headers.hmap -I
/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/myApp-all-target-headers.hmap -iquote /Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/myApp-project-headers.hmap -I/Workspace/git/myApp/platforms/ios/build/emulator/include -I~/Workspace/git/myApp/platforms/ios/build/emulator/usr/local/lib/include -I~/Workspace/git/myApp/platforms/ios/build/UninstalledProducts/include -I~/Workspace/git/myApp/platforms/ios/build/emulator -I~/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/DerivedSources/i386 -I~/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/DerivedSources -F~/Workspace/git/myApp/platforms/ios/build/emulator -include /var/folders/3h/9c4nf4vs3qbd916nc_ms9zr40000gn/C/com.apple.DeveloperTools/6.1-6A1052d/Xcode/SharedPrecompiledHeaders/myApp-Prefix-askhkaisnqgjcxgnfxlodqmsjfsq/myApp-Prefix.pch -MMD -MT dependencies -MF ~/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/Objects-normal/i386/AppPreferences.d --serialize-diagnostics ~/Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/Objects-normal/i386/AppPreferences.dia -c ~/Workspace/git/myApp/platforms/ios/myApp/Plugins/me.apla.cordova.app-preferences/AppPreferences.m -o /Workspace/git/myApp/platforms/ios/build/myApp.build/Debug-iphonesimulator/myApp.build/Objects-normal/i386/AppPreferences.o
clang: error: no such file or directory: '
/Workspace/git/myApp/platforms/ios/myApp/Plugins/me.apla.cordova.app-preferences/AppPreferences.m'
clang: error: no input files
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

Settings.bundle on iOS not updated from app-settings.json, Android works

Initially preferences are ok, steps:

  • adding the plugin
  • ionic build ios
  • open XCode
  • run app
    -> OK

Then changing some settings in app-settings.json:

  • ionic build ios
    • open XCode
    • run app
      -> Settings are updated but again in the "wrong" Settings.bundle in the platform root as in #60

You have to copy the updated Settings.bundle to /MYPROJECT/Resources manually to get the updated settings.

Remove value of a certain key

I would like to remove values for my email address and password values to null, but how can I reset it into null values or an empty string?

I thought there's method for removing values or for a certain key.

App preference activity theme

as of now when i do perf.show(); the activity window is material black (on android) . is there any way it can be customized using some preference?

Javascript error

hi,

although the plugin seems to work ok for me, i still capture an error on the logs

Uncaught ReferenceError: require is not defined AppPreferences.js 4
i suspect it has to do with the include of the file but i m not 100% sure

Settings.bundle file for Android?

For starters, I do not have the dev experience most of you have posting here but I am having trouble getting this plugin to work for Android and figured this is where I would get the most informative response.

Yesterday I installed the plugin and was able to read from my Root.plist file in the Settings.bundle file for iOS. To do so required copying the Settings.bundle into my Xcode project.

Is there a similar step or file to copy over for Android? I have not defined a key or value for android so I assume this is the issue. Also, I receive the following error while trying to emulate for Android:

Error Code:
    1
  Output:
    /Users/shredmer/Applications/NoHarm_Basic2/platforms/android/build/intermediates/res/debug/xml/apppreferences.xml:2: error: Error: No resource found that matches the given name (at 'entries' with value '@array/apppreferences_lang').

    /Users/shredmer/Applications/NoHarm_Basic2/platforms/android/build/intermediates/res/debug/xml/apppreferences.xml:2: error: Error: No resource found that matches the given name (at 'entryValues' with value '@array/apppreferences_langValues').

Thank you for your help.

Preferences not accessable from java.

Hi,
Thanks for the plugin.

I set preference and I can able to read using plugin. But, when I tried to access the same preferences from Java code, its not available. Can you please guide me on this.

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.