Preferences?

hi,

whats “the ionic way” to set/get preferences - i’m gazing at:

where I can do

window.applicationPreferences.set('syncURL', 'http://sync.couchbasecloud.com:4984/todos4',
  function() {
    $log.log('syncURL pref. stored'); 
  },
  function(error) {
    $log.log('error:', error);   
  });

window.applicationPreferences.get("syncURL", function(value) {
  $log.log('syncURL:', value); 
    }, function(error) {
    $log.log('error:', error);   
});

other candidates:

it would of course be niece to use it with ngCordova - http://ngcordova.com/docs/

thx

//

pelle

There hasn’t been too much talk about setting preferences. But following angular practices should get you started. ngCordova is open source, so you can always make a PR and make an angular wrapper for the plugin you select :smile:

thx for the response !

i’ll look into make a PR for ngCordova then :smile:

if someone has other suggestions for a pref. plugin then let me know…

Preferably the first one because it suppers plugman and the api looks pretty straight forward

… so you can always make a PR and make an angular wrapper for the plugin you select

PR created $cordovaPreferences: adding support for a preferences plugin #83 by pellekrogholt · Pull Request #85 · ionic-team/ng-cordova · GitHub

let me know if the implementation is sane…

//

pelle

1 Like

Hi,

I’m using the ngCordova preferences plugin. I can’t seem to read existing preferences, but if I set a preference, then read it (both using $cordovaPreferences) it works. It seems like it doesn’t see the settings defined in the plist, and when I set a pref with the same identifier, it doesn’t update the settings viewable from the settings app on the device. Any help would be appreciated.

Cheers,
PJ

@pshields ok better late then never:

did you solve your problem - one thing is to be sure to use the right plugin it was changed from:

to:
https://github.com/xcodeguy/plugins-application-preferences

long story

if that did not solve your problem you would have upload a full app project somewhere / codepen wont work here - then I others might can help you further.

//

pelle

I greatly appreciate the info. I’ll try that when I next working on the project, as the client likely has some changes they want to make anyway.

Cheers,
PJ

http://ngcordova.com/docs/plugins/preferences/

$cordovaPreferences.get(‘name_identifier’) /.set doesn’t return callback.

Anyone having the same problem with beta 14 and Android 4.4.4?

@mhartington @pshields @pellekrogholt

Same problem
$cordovaPreferences.get and $cordovaPreferences.set doesn’t return callback

Has anyone been able to get $cordovaPreferences GET or SET to work within Ionic? Is there an alternative way to read iOS Settings.bundle in Ionic?

@mhartington Do you know what can we do?

Have you tried wrapping your usage of the plugin in $ionicPlatform.ready?

$ionicPlatform.ready(function () {
   $cordovaPreferences.get('name_identifier').then(function (name) {
    $scope.name = name;
  });
});

@alexweber15 It worked for you?

I actually haven’t tried, just in my experience with ngCordova you usually have to do that to get it to work… :slight_smile:

I have tried the following text, but it doesn’t works. Only the alert(1) is shown.

$ionicPlatform.ready(function () {
   alert(1);
   $cordovaPreferences.set('name_identifier', 'hi').then(function (name) {
      alert(2);
      $cordovaPreferences.get('name_identifier').then(function (result) {
       alert(result);
     });
  });
});

Check this: https://github.com/driftyco/ng-cordova/issues/473

Nice find! Again, In my experience, some of the ngCordova plugins aren’t really worth it because they add only marginal value as opposed to actually using the cordova plugins directly (and in that case it’s crucial to wrap it in the ready() call).

Hi Everyone, I am working on Ionic 2 application. For preferences I wish to use the cordova plugin https://github.com/chrisekelley/AppPreferences/ suggested in one of the answers above. I understand on IOS a plist file will be generated which can be modified from Application Settings in IOS as a means to update settings. How and where can I have a similar page/functionality on android?