3

How can I make an app run at startup and not in the background. I need it in foreground for the whole time. Is that possible?

I have:

[UIApplication sharedApplication].idleTimerDisabled = YES;

Thats keeps an app always running in the foreground. But I don't know how make it run at iOS startup in foreground.

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
Dmitriy Pushkarev
  • 390
  • 2
  • 5
  • 26

3 Answers3

6

The only way is Guided Access

Guided Access restricts your device to a single app and allows you to control which app features are available.

So, when you enable Guided Access, your app will run upon startup.

In order for it to work after a reboot (after a power failure or so), the passcode of the device needs to be disabled.

Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102
  • Thats solution looks likes good! Not sure TV out works or not,i check it later. At anyway - Thank you so much! – Dmitriy Pushkarev Jan 01 '14 at 03:18
  • Seems that Guided Access mode has changed and is no longer to start an app at powerup. In iOS 10+, Guided Access mode requires a passcode. It won't proceed unless a passcode is set. – pmont Jan 26 '18 at 20:07
1

If you plan on releasing this app onto the app store or on unmodified phones, it won't be possible because of the restrictions Apple places on apps for security reasons. However, if you just need the app for your own phone, you can look into jailbreaking which will give you more access to the system outside of the sandbox apple keeps most apps in.

Edit: Looking at this answer, there are ways to have your app run in the background at startup, but I think having it run in the foreground is still impossible.

Community
  • 1
  • 1
Connor Pearson
  • 63,902
  • 28
  • 145
  • 142
0

Remember that your app running all the time eats battery. Is that really the best thing for the user, or is there some way to get close to what you are trying to to via one of the many API's that support background processing on demand?

Look into the background data API introduced in IOS7. That's the easiest way to accomplish what you are likely trying to do.

Otherwise, look at one of the backgrounding modes and see if any of them might apply to your application.

OR look at the motion coprocessor data that the new iPhone 5s's gather without needing your app to be running...

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
  • No reason to worry about battery, because thats solution implies use d with power socket. Battery just as back-ups.Thats app cannot be in background because it use TV out, which not works when app in background. – Dmitriy Pushkarev Jan 01 '14 at 02:49
  • Have you tried putting an app into kiosk mode and restarting the iPad? It may do what you want then, and it sounds like you would want the app in kiosk mode anyway: http://www.icapps.com/ipad-in-kiosk-mode/ (Edit: you can't power down while in Kiosk mode, and I didn't test what happens if it runs out of power) : further edit, I see another responder has mentioned Guided access. Good luck! – Kendall Helmstetter Gelner Jan 01 '14 at 03:29