The iOS device goes into standby mode, the network stops. How do I get an alert to enter an "idle" state?

My application has a screen on which it constantly requests information about the server. When the user does not interact with the application, he goes into standby mode, the screen becomes dim and then black.

In the background, the application is still trying to interrogate the service, but it receives error codes -1009 from NSURLConnection. (-1009 == NSURLErrorNotConnectedToInternet)

My idea is to stop polling on the server for information as soon as the application goes into this idle state.

Is there a way to get notified when a device goes into standby state?

+3
source share
1 answer

If the screen is locked, you will receive a notification using the following method:

- (void)applicationWillResignActive:(UIApplication *)application

Apple Documentation

+2
source

Source: https://habr.com/ru/post/1768955/


All Articles