28

I have made an iphone fitness application. The issue i am unable to resolve here is that, while the application is running, the iphone goes in the sleep mode, and hence the accelerometer and sound turns off. Which i dont want to happen.

Is there anyway i can avoid this from happening? If not that, atleast i could increase the time of my iphone to go into sleep mode.

Regards Zeeshan

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Zeeshan Rang
  • 19,375
  • 28
  • 72
  • 100

2 Answers2

71

Try this

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
epatel
  • 45,805
  • 17
  • 110
  • 144
11

As Jacob and epatel said, the [[ UIApplication sharedApplication ] setIdleTimerDisabled: YES ]; is the way you wanted. However, you'd better to implement when the application is interrupted by other signal. It means that you'd implement - (void)applicationWillResignActive:(UIApplication *)application method.

Because, there are enforced interruption on the iPhone/iPod touch. A phone call, push a power button, and so on.

KatokichiSoft
  • 932
  • 5
  • 8
  • 1
    KatokichiSoft, could you add an example of how to implement this method? – Brabbeldas Apr 03 '15 at 10:27
  • I put this code into (void)applicationWillResignActive, but it only works in the new iPad version. It does not work in the previous version iPad (just be older a little bit) – chipbk10 Apr 16 '15 at 08:27