Reputation: 71
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":
Please Help.
Upvotes: 1
Views: 1079
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
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