Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access StatusBar in JavaScript #32

Open
andrewjmead opened this issue Apr 21, 2014 · 11 comments
Open

Unable to access StatusBar in JavaScript #32

andrewjmead opened this issue Apr 21, 2014 · 11 comments

Comments

@andrewjmead
Copy link

Let me preface this by saying I'm new to phonegap/cordova but not web development.


I added the following to my config.xml file:

...
<gap:plugin name="com.phonegap.plugin.statusbar"/>

<preference name="StatusBarOverlaysWebView" value="true" />

<feature name="StatusBar">
    <param name="ios-package" value="CDVStatusBar" onload="true" />
</feature>
...

I have also included phonegap.js in my project. It was loaded successfully and I have access to the cordova global variable.

As the README.md for this plugin implies I should be able to execute the following statement StatusBar.styleLightContent();. The issues is that StatusBar is not defined.

Am I missing something when it comes to using phonegap build plugins?

@andrewjmead andrewjmead changed the title Unable to access StatuBar in JavaScript Unable to access StatusBar in JavaScript Apr 21, 2014
@jayrodkc
Copy link

I'm having the same issue, took exact same steps.

@andrewjmead
Copy link
Author

I should have posted my solution. I was running my app via phonegap run ios. I then tried cordova run ios and the StatusBar plugin worked fine.

Would someone mind explaining why phonegap run ios was not working?

@jayrodkc
Copy link

I got it working. I changed from using com.phonegap.plugin.statusbar to org.apache.cordova.statusbar and it started to work. I won't claim to understand the guts of phonegap build well enough to makes sense of this.

@andrewjmead
Copy link
Author

I'm in the same position 😄

@jayrodkc
Copy link

Well, I say I got it working, but I'm still struggling with it a little. I can see the JavaScript object StatusBar, but am still trying to get it to actually control the look of it. When my app starts I try to call StatusBar.overlaysWebView(false); but it does not seem to have an affect.

@andrewjmead
Copy link
Author

Your calls to StatusBar may be firing before the device is ready. You might need to include com.phonegap.plugin.device and then add something like this to you JavaScript (this code worked for me).

function onDeviceReady() {
    // Now safe to use the PhoneGap API
    navigator.splashscreen.hide();
    StatusBar.styleLightContent();
}

document.addEventListener("deviceready", onDeviceReady, false);

@miemo
Copy link

miemo commented Sep 5, 2014

This seems to be same issue as #33

@miemo
Copy link

miemo commented Sep 5, 2014

BTW, @andrewjmead & @jayrodkc did you get it running on Phonegap Build or locally? It was a bit unclear from your comments....

@andrewjmead
Copy link
Author

I was working locally and I was able to get it to work.

@miemo
Copy link

miemo commented Sep 5, 2014

@andrewjmead OK, so it seems that the issue mentioned on #33 is limited to Build.

@andrewjmead
Copy link
Author

Cool, glad to help! Thanks for following up 😄!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants