After iOS13 keyWindow
concept in iOS anymore as a single app can have multiple windows. So just take the first one :
let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
let topPadding = window?.safeAreaInsets.top
let bottomPadding = window?.safeAreaInsets.bottom
CLICK HERE to find out more related problems solutions.