Original Answer
Although I'm answering this question very late but after one full day of the search, I got this working simply so I would like to share it with others.
According to the docs (and like jcesarmobile answered):
Hiding at startup
During runtime you can use the StatusBar.hide function below, but if
you want the StatusBar to be hidden at app startup, you must modify
your app's Info.plist file.
Add/edit these two attributes if not present. Set "Status bar is
initially hidden" to "YES" and set "View controller-based status bar
appearance" to "NO". If you edit it manually without Xcode, the keys
and values are:
This requires you to modify your app's info.plist
file inside platforms/ios/<app-name>/<app-name>-Info.plist
file to add the following lines:
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
But that is not recommended because this will require you to save that change which might get overwritten after the build process.
(Please see the Update 2 from here if you are using the latest Cordova CLI)
So as the clean alternative you should use cordova-custom-config. According to docs:
Why should I use it?
While some platform preferences can be set via
Cordova/Phonegap in the config.xml
, many (especially ones related to
newer platform releases) cannot. One solution is to manually edit the
configuration files in the platforms/ directory, however this is not
maintainable across multiple development machines or a CI environment
where subsequent build operations may overwrite your changes.
This plugin attempts to address this gap by allowing additional
platform-specific preferences to be set after the prepare operation
has completed, allowing either preferences set by Cordova to be
overridden or other unspecified preferences to be set. Since the
custom preferences are entered into the config.xml
, they can be
committed to version control and therefore applied across multiple
development machines, CI environments, and maintained between builds
or even if a platform is removed and re-added.
Now, all you have to do is to run the following command for your Cordova app:
cordova plugin add cordova-custom-config --save
And add this to your config.xml
file under <platform name="ios">
block:
Please refer cordova-custom-config (version > 5) plugin for more information
<custom-config-file parent="UIStatusBarHidden" platform="ios" target="*-Info.plist">
<true/>
</custom-config-file>
<custom-config-file parent="UIViewControllerBasedStatusBarAppearance" platform="ios" target="*-Info.plist">
<false/>
</custom-config-file>
Update 1 (20th Feb 2018)
If you are using cordova-custom-config plugin version < 5 then replace custom-config-file
tag with config-file
.
https://github.com/dpa99c/cordova-custom-config#changes-in-cordova-custom-config5
Update 2 (6th July 2018)
Since Cordova CLI 6, you now don't require to install the cordova-custom-config
plugin for altering the platforms/ios/*-info.plist
file. Cordova CLI has the inbuilt support of it using edit-config
tag. So now you can simply add the following in your config.xml
under <platform name="ios">
:
<edit-config file="*-Info.plist" mode="merge" target="UIStatusBarHidden">
<true />
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="UIViewControllerBasedStatusBarAppearance">
<false />
</edit-config>
This change might fail when you build your Cordova application because it will conflict with platform/ios/ios.json
file. To fix this you have two options (reference):
Option 1 (Overkill but working)
Re-add the iOS platform:
ionic cordova platform remove ios
ionic cordova platform add ios
https://issues.apache.org/jira/browse/CB-13564
Option 2 (Recommended but not working for me)
Use platform/ios/ios.json
instead of *-Info.plist
in the edit-config
file. So the final config you have to add:
<edit-config file="platforms/ios/ios.json" mode="merge" target="UIStatusBarHidden">
<true />
</edit-config>
<edit-config file="platforms/ios/ios.json" mode="merge" target="UIViewControllerBasedStatusBarAppearance">
<false />
</edit-config>
And then do:
cordova prepare ios