In the past, I use UIApplication.shared.windows.first?.safeAreaInsets.bottom to get the bottom safe area, but in iOS 15, there is an warning shows that windows has been deprecated. My project is written in SwiftUI, so is there a way to get the global safeAreaInsets again and fits iOS 15?
The problem with your code is that you could be selecting any window, including one that is offscreen, private to the system, or otherwise incorrect for your needs, which is why UIKit deprecated the UIApplication
level window list.
If you have a UIView in your UI, you can obtain the window from that view, and request its safe area insets.