Hi, I'd greatly appreciate any help with this problem. I have developed an app for both iOS and android. The app is built with Kivy and Python, it functions as expected however in Xcode I cannot find a way to prevent the phone/device from dimming and locking.
I'm very new to Xcode and iOS, but I ave tried several variations of.
[UIApplication sharedApplication].idleTimerDisabled = YES;
in multiple areas of the m Main but I cannot get it to work, no matter what I try the phone still goes to sleep/locks.
If that code above is supposed to work, I have no idea where to put it. As far as I can tell, the only places I could enter something like that is in the main.m, bridge.m and bridge.h code; or somewhere in the info.plist
I'm currently lost, feels like a simple problem.
took me forever but I hope this helps someone else.
For Kivy-iOS, this needs to be entered into the main.m file in Xcode, at the bottom of the main() function.
int main(int argc, char *argv[]) {
int ret = 0;
that's the start of main()
then all the main code, with the following code near the bottom.
// If other modules are using the thread, we need to initialize them before.
PyEval_InitThreads();
// Add an importer for builtin modules
load_custom_builtin_importer();
then, You need to put the below code after that
// Prevent sleep
[NSTimer scheduledTimerWithTimeInterval:2.0 repeats:YES block: ^(NSTimer * _Nonnull timer) {
[UIApplication sharedApplication].idleTimerDisabled = NO;
[UIApplication sharedApplication].idleTimerDisabled = YES;
NSLog(@"idle timer");
}];
NSLog(@"Initializing python");
Py_Initialize();
hope this helps someone else.