Reputation: 129
I am trying to get the default StatusBar which is black, but it's coming light. When I try to set as black the error is Uncaught ReferenceError: StatusBar is not defined including the plugin on https://github.com/apache/cordova-plugin-statusbar.git. I removed and added several times, but the StatusBar is still light.
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-file 4.1.0 "File"
cordova-plugin-media 2.1.0 "Media"
cordova-plugin-splashscreen 3.1.0 "Splashscreen"
cordova-plugin-statusbar 2.1.0 "StatusBar"
cordova-plugin-vibration 2.1.0 "Vibration"
cordova-plugin-whitelist 1.2.1 "Whitelist"
ionic-plugin-keyboard 1.0.8 "Keyboard"
The code is:
console.log(StatusBar);
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
Upvotes: 0
Views: 1123
Reputation: 3238
You need to wait for the deviceready
event to be able to use Cordova plugins.
The simplest way to do this would be to wrap your code in a ionic.Platform.ready()
call, like this:
ionic.Platform.ready(function() {
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
Upvotes: 2
Reputation: 937
I faced exactly the same problem.
ensure also that you delete manually the plugins folder from your projects after deleting you plugins using cordova plugin rm <PLUGIN NAME>
.
Tell me if it worked with you. Happy Coding.
Upvotes: 1