added proper discovery of th app state when receiving notification