I want my app to keep running and interacting with the user, even if the user presses the sleep button.
So far I have learned, that my app can stay alive with the following code:
NSTimer *timer = [NSTimer timerWithTimeInterval:0.5 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
This succeeds. The method
- (void)timerFireMethod:(NSTimer*)theTimer
will be called every 0.5s even if I am in sleep mode.
So know my problem is: How can I interact with my Application in sleep mode?
I simply need a trigger to start playing a custom audio file. Therefore I need a trigger event, something like detecting:
-a touch at the display
-an acceleration activity
-a MotionShake Event
But after getting the applicationWillResignActive
-Event, nothing of the above is working. My accelerometer stops delivery of acceleration events. And I am unable to start them again.
MotionShake Event will not be delivered and I don't know, if it is possible to catch a touch event while sleeping.
Update
I expect the user to use my app for lets say 5hours. If it is idle for some time, it will go to sleep on its own.
I probably misinterpreted what I mean with sleep mode. The Iphone should be up and running all the time, but I do not need the display and the background light to be on all the time (these are the most power consuming parts). I know that while playing a noiseless sound every 10 seconds, the iphone is not going to sleep. And I know that the IPod application is able to run in that mode and the user can interact with it by shaking the device. So isn't there any official way for an app to do the same?
---
Has anyone any idea?
Thanks Zensursula