I followed some discussions, for example this one, and tried with following suggested code:
let state = UIApplication.shared.applicationState
if state == .background {
print("App in Background")
}else if state == .active {
print("App in Foreground or Active")
}
But it gives me prints only in active state. I get nothing from the background state. How could I get notice if my app is in background? Where I should call this function? Has somebody any experiences with this problem?