Search code examples
angularjsionic-frameworksharedpreferencescordova-plugins

Plugin not enabled Error


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

  • I downloaded plugin with cordova plugin add cordova-plugin-app-preferences
  • installed ngCordova
  • added ng-cordova.js in index.html before cordova.js
  • added ngCordova' in my starter module
  • injected $cordovaPreferences in controller

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.


Solution

  • 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