How to find the time app spent in suspended state (when app minimized on the device). I want to inform the user that your app spent 30 mins in background and please re-login to the app.
Asked
Active
Viewed 1,160 times
2 Answers
4
Simple. Store [NSDate date] when the app enters background. When the app returns from background compare [NSDate date] to the value you stored when you went into background. I know I'm genius thanks.

HackyStack
- 4,887
- 3
- 22
- 28
-
Yes I understand this way. What i was thinking was there might be some direct API where app tells us how much time it spent on particular state like Suspended State. There might be some thread running in the background to see which app is minimized for how much time. is it so ?? Any details on this ? – Srivathsa Nov 30 '12 at 09:50
1
In the appdelegate methode: - (void)applicationDidEnterBackground:(UIApplication *)application
save a NSDate
then in the - (void)applicationWillEnterForeground:(UIApplication *)application
check the time between that date and the current date.

rckoenes
- 69,092
- 8
- 134
- 166