Plugin not working correctly IOS
I'm using the following config.xml
<plugin name="cordova-plugin-statusbar" />
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#000000"/>
<preference name="StatusBarStyle" value="lightcontent" />
The statusbar text is white, thats OK but the statusbar itself is not black (#000000) as defined in the config.xml It is transparent...
Using:
<preference name="phonegap-version" value="cli-8.0.0" />
Device: IOS12 on iPhone6 Phonegap Build
Screenshot: https://i.imgur.com/IQejdi5.png When the keyboard pop up the content scrolls behind the statusbar content... :/
@stefangroenew Did you find any workaround to this? This has been a big problem for me with multiple apps. We've had to revert to earlier version of the Cordova CLI.
@bvosk Unfortunately I have not found a solution yet. Which version of Phonegap Build do you use? Can you send the config.xml code snippet? Thanks!
@stefangroenew Using this preference in the config.xml file makes the status bar work for us:
<preference name="phonegap-version" value="cli-6.5.0" />
Note that this causes problems on Android, so we've been building different copies for iOS and Android.
Despite the config, it looks like the status bar is in overlay mode. I took a quick look at the src code, and I think line 121 of CDVStatusBar.m is the fault.
https://github.com/apache/cordova-plugin-statusbar/blob/adcee9f66f01f95eaa286f956105bbccf62b14df/src/ios/CDVStatusBar.m#L121
I don't see at any point where the plugin on pluginInitialize obeys the config.xml value, and it appears hard code _statusBarOverlaysWebview = YES;
Does the problem persist if you programmatically turn overlay off by using StatusBar.overlaysWebView(false); after the device ready event fires?
@breautek That worked for me, so it seems you're right. Thanks so much for the help!
@breautek @bvosk Thank you for your comments, unfortunately the Javascript solution after the DeviceReady will not work (on IOS).
I have set a lime color that works well on Android.
StatusBar.overlaysWebView(false); StatusBar.backgroundColorByHexString("#adf907");
However, this does not work on IOS. The color is visible a verry short time. See this video: https://youtu.be/RS_5hFCWHSU
Any idea? Thanks! Stefan
@breautek @bvosk I found the issue! The Javascript solution was working but the framework I use was overwrite some settings. More info:
https://framework7.io/docs/statusbar.html#statusbar-styling
Thanks again for the help! Stefan
@stefangroenew The javascript solution wasn't really a solution. More like a workaround. The real solution in my opinion is to fix the native objective-c code to pull in the preference values from config.xml. That is however outside of my knowledge. I'm not an experienced iOS developer, nor do I have a personal iphone or mac to use to test with.
@stefangroenew I agree with @breautek, would better to leave this open because it should respect the preference in the config.xml file.
I did a little bit more investigating and found that this isn't indeed only an iOS issue.
On Android, StatusBarBackgroundColor, StatusBarStyle both do appear to work on startup. StatusBarOverlaysWebView however does not. Additionally Android does not use overlay mode by default, despite what the documentation says.
For android it appears to be an easy fix https://github.com/apache/cordova-plugin-statusbar/blob/adcee9f66f01f95eaa286f956105bbccf62b14df/src/android/StatusBar.java#L62-L66
We can see here it looks at the preference and sets up accordingly for the other preferences. But it doesn't do that for StatusBarOverlaysWebView. It doesn't even set it to true by default like iOS does.
Makes me wonder if it is better to keep it false by default for android and make a note in the documentation rather than changing the behaviour and potentially causing unexpected changes for people.
I can't reproduce on latest version of the plugin, cordova and cordova-ios. The code for checking the preference has always been there according to the git blame 9 years ago https://github.com/apache/cordova-plugin-statusbar/blame/3795486e33a4a9113773d5e688374d142f93828c/src/ios/CDVStatusBar.m#L113-L115 7 years ago https://github.com/apache/cordova-plugin-statusbar/blame/1672883a7fda51e73069d6f350393bb2719228e3/src/ios/CDVStatusBar.m#L190-L196
As far as I remember phonegap build had a problem with preferences not working and some users mention phonegap build, so it was probably the issue. If somebody still faces the issue with latest cordova, cordova-ios and cordova-plugin-statusbar, please, create a new issue and provide a sample app where the issue can be reproduced.