views:

28

answers:

1

My app has a screen where it is constantly polling a server for information. When the user does not interact with the app it goes idle, the screen goes dim and then black.

In the background, the app still tries to poll to service, but gets -1009 error codes from NSURLConnection. (-1009 == NSURLErrorNotConnectedToInternet)

My idea is to stop polling to server for information, once the app enters this idle state.

Is there a way to get notified, when the device enters the idle state?

+1  A: 

If the screen gets locked you will be notified by the following method;

- (void)applicationWillResignActive:(UIApplication *)application

Apple documentation

Jeroen de Leeuw
oh thank you. i thought this method was introduced with iOS 4.0 and didnt looked at it for the specific question. i took a second look and it is supported from iOS 2.0 onwards.
Tomen