سؤال

I've taken reference from this SO question about how to detect inactivity of App & code based on the answer, this working fine in simulator but problem when I testing the same in device. If I've setting NSTimer interval to 60 seconds (1min) it works fine as my iPhone device timeout is 1min. If I set more then 1 min it lost (stop) detecting inactivity of App. So I set the 300 seconds (5mins) in simulator as its working fine. What I'm doing is when there's I find inactivity I'll pop to firstView of my App. Is there any ways that I need to configure so even my device locks it will still detecting inactivity in App.

You can see my code here, InActivityDetectClass.h and InActivityDetectClass.m. In each UIViewcontroller I've code like this to detect inactivity of the App.

Don't find where I'm doing wrong. I think its all about, when device locks and app goes in background the NSTimer may stops working but it's not the case with simulator as there's no chance of lock or offscreen?

هل كانت مفيدة؟

المحلول

Finally, I've found this [UIApplication sharedApplication].idleTimerDisabled; and set it to YES (default NO). That it makes my application always on & never locks. So the functionality that I wants I gets.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top