Support the default value of UIViewControllerBasedStatusBarAppearance (true)
See original GitHub issueDescription
React Native currently requires that UIViewControllerBasedStatusBarAppearance
is set to NO. This is an app-global setting and Apple offers this to help bringing old (pre-iOS 7) apps over to newer OS versions. It’s not recommended that this is set for new apps. The methods for manual status bar control are already deprecated and Apple explicitly discourages using them:
To opt out of the view controller-based status bar appearance behavior, you must add the UIViewControllerBasedStatusBarAppearance key with a value of false to your app’s Info.plist file, but doing so is not recommended. https://developer.apple.com/reference/uikit/uiapplication/1622923-setstatusbarstyle#discussion
The check was added in 2015: https://github.com/facebook/react-native/blame/64a4c6070df7e711e7fd01c490f369bbd0d0fb28/React/Modules/RCTStatusBarManager.m#L109-L111
At PSPDFKit we offer a React Native module. We also have a very similar check that warns if the value of UIViewControllerBasedStatusBarAppearance
is still set to the old behavior.
https://pspdfkit.com/blog/2016/react-native-module/
Here’s our FAQ article about it: https://pspdfkit.com/guides/ios/current/faq/uiviewcontrollerbasedstatusbarappearance/
Other platforms (Xamarin) are switching to the new style as well: https://github.com/xamarin/Xamarin.Forms/pull/463
Reproduction
See the code check for UIViewControllerBasedStatusBarAppearance
. React should either support both or just default to the non-deprecated style. Currently any modification of the status bar requires this key to be set to false (true is the default)
Solution
This is tricky. See the related discussion on Twitter with Nick who wrote the original check: https://twitter.com/nicklockwood/status/816334935422337025
I realize that React doesn’t own the parent View Controller. There are still quite a few ways how the parent VC can be accessed and how hooks could be installed to both have the current flexibility (so we do not break any API) and offer compatibility with the new way of controlling the status bar.
I am willing to help and work on this but I’d first love to hear if there are any discussions around this that I missed while searching for it and what the mid- to long-term plans here are. I know that everything related to the status bar on iOS is painful, so I’m apologizing in advance for bringing up this issue.
Additional Information
- React Native version: 0.39
- Platform: iOS
- Operating System: MacOS
Issue Analytics
- State:
- Created 7 years ago
- Reactions:34
- Comments:32 (15 by maintainers)
Is nobody else running into this issue?
@hramos This is a conceptual issue and I have not seen a fix for it yet - please re-open this ticket.