2
votes

We just updated our app on iOS 13, and app get crashed. Actually we are trying to get window object through statusBarWindow but at this point app get crashed and showing following error in log section.

  static var sb: UIWindow? {
        // We use a non-public key here to obtain the `statusBarWindow` window.
        // We have been using it in real world app and it won't be rejected by the review team for using this key.
        let s = "status", b = "Bar", w = "Window"
        return UIApplication.shared.value(forKey: s+b+w) as? UIWindow
    }

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'

Its clearly shows that we cannot use statusBarWindow instead we should use statusBarManager But I am unable to find how to use statusBarManager Object

1
Were you able to find how to use statusBarManager Objectuser2185354
Not yet , do you have any suggestionMatloob Hasnain

1 Answers

1
votes

We faced a similar problem. Although Key Window has been deprecated on iOS 13, we decided to use this solution for now. Hope it helps

if #available(iOS 13.0, *) {
    let statusBar = UIView(frame: 
   UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame 
?? CGRect.zero)
     statusBar.backgroundColor = UIColor.init(red: 243/250, green: 243/250, blue: 243/250, alpha: 1)
 UIApplication.shared.keyWindow?.addSubview(statusBar)
} else {
     UIApplication.shared.statusBarView?.backgroundColor = UIColor.init(red: 
243/250, green: 243/250, blue: 243/250, alpha: 1)
}