Preferences?


#1

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


#2

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:


#3

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…


#4

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


#5

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

PR created https://github.com/driftyco/ng-cordova/pull/85

let me know if the implementation is sane…

//

pelle


#6

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


#7

@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


#8

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


#10

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


#11

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


#12

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?


#13

@mhartington Do you know what can we do?


#14

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

#15

@alexweber15 It worked for you?


#16

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


#17

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

#18

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


#20

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


#21

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?