I’m pretty sure your solution will *not* work on Android. The reason is that Android won’t display the status bar immediately because the operation is posted on another thread. That means you’ll get a value of zero in this case.
Yes, your solution will work for the top status bar on iOS. I’m not sure if it’ll work on Android since displaying its top status bar is done via another thread, meaning the status bar is not shown yet by the time you are reading its height.