I would like to trigger action after some ammount of time (in production that will be 30 minutes) and right now I'm using NSTimer
s scheduledTimerWithTimeInterval
. During tests (with timeout being 20 seconds, not 1800 seconds) everything seems fine. In debbuging mode (running from XCode) everything seems fine as well, because the device does not autolock. But in real life, when application is ran on device, autolocking (precisely autolocking, triggering lock button does not) "freezes" the timer (or at least moves the timer trigger somehow to future).
Can I handle that situation? Of course I can disable idleTimer in UIApplication sharedApplication
but when application will enter background mode ipad still can autolock.
Actually you can,
First of all, create a default value for "startTimeOfMyExoticTimer" to NSUserDefaults:
Then kick of a timer to check if the valid time range is over:
Then implement your checker method:
This will be working even if the device is locked, the app is in background etc.
This approach worked for me, hope it'll work for you too