Nick Wallbridge
Nick Wallbridge

Reputation: 196

Set Cordova StatusBar Plugin Defaults on Cordova Build

I am using the Cordova (4.2.0) StatusBar plugin. The options I want are:

<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarStyle" value="lightcontent" />
<preference name="StatusBarBackgroundColor" value="#A7A7A7"/>

All is fine, when I directly edit the config.xml file in XCode before building (in Xcode) and running the app on a device.

My issue is that as soon as a re-run "cordova build ios", the settings in the config.xml file revert to the defaults of:

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

Ok - so I know about default.xml and put my required settings in there. Trouble is now I get (unnecessary lines edited out):

<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarStyle" value="lightcontent" />
<preference name="StatusBarBackgroundColor" value="#A7A7A7" />

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

Note the second "StatusBarOverlaysWebView" entry and this "StatusBarOverlaysWebView" entry overrides the first!!

So I dig deeper and find plugin.xml, which contains:

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

That has got to be it, so I change that to my required defaults ... but no, I still get the second "StatusBarOverlaysWebView" and I have no idea why or where it is coming from. Can anyone help?

Thanks in advance Nick

Upvotes: 1

Views: 1205

Answers (1)

Mike Dailor
Mike Dailor

Reputation: 1266

Try this:

  1. Remove the iOS platform (cordova platform rm ios).
  2. Uninstall the plugin (cordova plugin rm org.apache.cordova.statusbar).
  3. Edit the config.xml in your root directory and add your 3 preferences there.
  4. Reinstall the plugin (cordova plugin add org.apache.cordova.statusbar).
  5. Edit plugin.xml and remove the 2 default preferences.
  6. Add back the iOS platform (cordova platform add ios).

I'm betting that will fix you.

Upvotes: 1

Related Questions