Titanium Sleep Prevention for iPhone

I try to read the accelerometer for a longer period of time (one to two hours).

However, when the iPhone goes into sleep mode and locks, the accelerometer reading stops.

My setInterval timer seems to work fine. I can also play sounds.

I see two solutions

a) Find a way to read the accelerometer when it is locked b) Find a way to prevent blocking

I am using Titanium with JavaScript.

+3
source share
4 answers

In version 0.9+, you can do the following:

Titanium.App.idleTimerDisabled = true;
+8
source

See docs for [UIApplication sharedApplication].idleTimerDisabled = YES

+2
source

Appcelerator 0.9

+1

If it actually blocks (rather than just sleeping), which causes the lock: Settings -> General -> Auto-Lock -> Never

0
source

Source: https://habr.com/ru/post/1727899/