no sleep mode??
I can't get my iPhone app to work in sleep mode.
I've used Ti.App.idleTimerDisabled = true;
in app.js but the application just stops when the screen is dimmed and enters sleep mode.
am I missing something?
thanks!
3 Answers
-
I found out if I play a piece of sound and add a timer in the pause event listener, my app continues to function. (except in iphone 3G).
will this be accepted by apple?example:
function duh(){ Titanium.API.info("working"); } Titanium.App.addEventListener('pause',function(e){ sound_test.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK; sound_test.looping = true; sound_test.play(); var useless_timer = setInterval(duh,1000); sound_test.stop(); Titanium.API.info("pausing APP"); });
-
I did a bit more research and it seems timers do continue to work based on what NSTimer can do. Haven't looked through source, but I'm assuming setInterval is one of the timing bridges to that class.
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html
-
Hello,
I'm facing a similar situation with my timer. When the phone locks the timer stops responding and picks up again when I a "resumed" event is triggered. I tested your solution and seems to offer a workable scenario. My question is how you stop the "useless_timer" from the "resumed" event. I tried clearInterval(duh) but doesn't seem to work. BTW how do you deal with the timer when going into background?
Thanks
Vassilis