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
  • 513,640
  • 108
  • 821
  • 1,164
Zeeshan Rang
  • 17,525
  • 27
  • 65
  • 96

2 Answers2

71

Try this

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
epatel
  • 44,965
  • 17
  • 105
  • 143
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
  • 922
  • 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