Make iOS application run at startup

瘦欲@ 提交于 2019-12-01 07:16:55

问题


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.


回答1:


The only way is Guided Access

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

So when the Guided Access is ON, your app run at 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.




回答2:


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.




回答3:


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...



来源:https://stackoverflow.com/questions/20864999/make-ios-application-run-at-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!