apla / me.apla.cordova.app-preferences

App preferences plugin for cordova
Apache License 2.0
201 stars 210 forks source link

"TypeError: string is not a function" after calling prefs.store() #84

Closed egkozlov closed 8 years ago

egkozlov commented 8 years ago

I have a trouble with app preferences plugin on Android device Huawei Y560-U02.

The problem is happened when I call:

var prefs = plugins.appPreferences;
            prefs.store(function (succ) {
                console.log("succ " + succ);
            }, function (err) {
                console.log("err " + err);
            }, "islogin", "1");

I see next logs: TypeError: string is not a function at nativeExec (file:///android_asset/www/plugins/cordova-plugin-app-preferences/www/apppreferences.js:176:11) at AppPreferences.store (file:///android_asset/www/plugins/cordova-plugin-app-preferences/www/apppreferences.js:188:3) at Object.factory.rememeberCredentials (file:///android_asset/www/js/app.js:941:19) at successCallback (file:///android_asset/www/js/app.js:605:29) at processQueue (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:27879:28) at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:27895:27 at Scope.$eval (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:29158:28) at Scope.$digest (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:28969:31) at Scope.$apply (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:29263:24) at done (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:23676:47)

succ OK

The problem happened only on this device. On iOS and other Android devices that I have everything works fine.

Android version - 4.4.2. cordova - 6.0.0 cordova-android - 5.1.1

apla commented 8 years ago

Hi,

Can you uncomment this line in platform/android/assets/www/apppreferences.js to check what's going on?

egkozlov commented 8 years ago

Hi, thank you for the quick response. Actually I developed ionic app and using their $cordovaPreferences service. I noticed that this error is thrown by $cordovaPreferences.fetch("islogin", "1"), not by appPreference direct call. For this method I see logs: [null,null,null,null] {} apppreferences.js:75

for

var prefs = plugins.appPreferences;
            prefs.store(function (succ) {
                console.log("succ " + succ);
            }, function (err) {
                console.log("err " + err);
            }, "islogin", "1");

[null,"islogin","1",null] {"key":"islogin","value":"1"} apppreferences.js:75

So there is no bug with your lib, it's ngCordova issue. Sorry for the interruption