My app is constantly polling a web server.
In the interest of reducing the data usage for the user and to reduce the load on my server I would likely to check when the app has the screen locked and when the app is in background mode so I can stop the unnecessary web traffic.
Is there a handy method for check the state of the app?
Many Thanks
-Code
How about UIApplication‘s applicationState property? Its return value is an enum:
And, being a singleton, you can access it from anywhere via the
+sharedApplicationclass method.