Nouman Rasheed
Nouman Rasheed

Reputation: 71

Plugin not enabled Error

I am new to ionic-framework, trying to implement shared prefrences in ionic platform for which cordovaPreferences is the plugin:

Then I am using:

$cordovaPreferences.store('key', 'myMagicValue')
  .success(function(value) {
     alert("Success: " + value);
   })
  .error(function(error) {
     alert("Error: " + error);
   })

But an alert is generated saying "Plugin not enabled":

Screen shot of error

Please Help.

Upvotes: 1

Views: 1079

Answers (3)

apla
apla

Reputation: 51

ngCordova preferences object is a wrapped version of cordova app preferences plugin. I'm author of that plugin.

When you use preferences too early (before deviceready event), ngCordova will display alert window with "Plugin not enabled" message. Here is the code. Wait for deviceready event as Dirk D. suggests:

$ionicPlatform.ready (function () {
    // your code here
})

Another possibility why you see this alert is that you're trying to test your app in browser with ionic serve or cordova serve or cordova run browser, but browser platform is not available till plugin version 0.7.7 which I released today.

Upvotes: 3

Dino
Dino

Reputation: 806

You need to run this app in Android or iOS. Some plugins are not for the browser.

Following command is to add platform android

ionic platform add android

To build

ionic build android

To Emulate

ionic emulate android

If you are not satisfied with the emulation, after the build command, just go to YourApp'sFolder\platforms\android\build\outputs\apk and copy the apk file to your device and install

Check that the plugin is working successfully

Upvotes: 1

deelde
deelde

Reputation: 1591

wrap your call into :

$ionicPlatform.ready(function() {

...

});

Upvotes: 0

Related Questions