I am doing it like this:
if Thread.isMainThread {
return UIApplication.shared.applicationState
} else {
var state: UIApplication.State?
DispatchQueue.main.sync {
state = UIApplication.shared.applicationState
}
return state!
}
works like a charm