iOS Always be on Startpage when App becomes active - ios

I'm programming a quiz for the iPad and when the user presses the homebutton while in a quiz and relaunches the app I want the quiz to be already cancled and back on the Startpage of the app.
Now it simply gets back to the last view it was on.
Also I want it to show the splashscreen again when the app relaunches.
A complete reset of the app, when pressing the homebutton, would be great.
Thanks in advance

Choose the 'application does not run in background' option in your project's plist. If the option isn't there, press the '+' on the side to add the property.
This will ensure that the app starts afresh every time it's opened.

So, you want to disable multitasking?
Set UIApplicationExitsOnSuspend = YES in your info.plist.
Unless you just want them to resume through the screen, in which case you'll want to look into the lifecycle callbacks for your AppDelegate.

Related

Is UIApplicationExitsOnSuspend the same as exit(0)?

I want to present a lock screen if TouchID/Pascode is set in my applications settings. I want it to work similar to Dropbox and 1Password where if you have this set, and then you press the Home button on the iPhone, if you reopen the app it automatically shows the lock screen and displays Touch ID alert.
For my app I want a similar behavior. In Ray Wenderlich's tutorial on security, they set UIApplicationExitsOnSuspend (also known as "Application does not run in background") to YES in the pList. The problem for me is that I don't want this set at all times - for my app it should only be set if Touch ID/Passcode is enabled by the user in my applications settings. So my concern is:
Can I set UIApplicationExitsOnSuspend programmatically in code?
If not, can I use exit(0) or exit(1)? I seen many stack overflow pages where they say not do this --- but I will only call this in applicationDidEnterBackground if Touch ID/Passcode is enabled by the user in my applications settings.
I want to launch this app to the app store as well. Thanks.

iOS disable let user swipe the app in background list

In the iOS, when the user double home button , the app show in the list at background.
Have possible hidden my app show in the list, or force the user swiped the app, the app in the background can't close?
I just known applicationDidEnterBackground can do something in the background. But
I wish force the user can't swipe the app in the list or hidden the app in the list, or have some mobile device management method can do this effect(we can use private api)?
I search many time , but I was not found some answer...
thank you very much.
This is not possible in iOS, the user is in control and Apple does not allow your app to hide it self in this list.
If you want this you will need to target jailbroke devices and hook on the task switch. Then detect you app from being closed and restarted it.

How to lock Iphone to a specific screen of app for some time, same like kids mode programmatically?

I am developing an app in which user gets alerts for Quran time. Now when user is in prayer i want to lock my device for that time same like enabling kids mode. How that can be achieved in iPhone.
Apple hasn't released any kind of Public API to do so. And I'll never recommend to use the Private API's (if available in this case), cause it's could lead to reject your app.
In my knowledge I only knew how to prevent the phone from locking while your app is running.
Objective-C
[UIApplication sharedApplication].idleTimerDisabled = YES
Swift
UIApplication.sharedApplication().idleTimerDisabled = true
You can add treatment for this inside the app, but unless the device is jailbroken, you cannot prevent the user from pressing the device's home button and leaving your app.
If you just want the user to stay on a specific screen of your app, you can disable user interaction (either by setting userInteractionEnabled = NO on the main ViewController's view, or by adding a transparent UIButton that will cover the entire screen, catch the presses and do nothing with them, as long as the payer is in session). You can also keep the screen from locking for that duration of time by using:
[UIApplication sharedApplication].idleTimerDisabled = YES;
And setting it back to NO when the prayer is done (only if you choose to).
However, the user will still be able to leave the app by using the device's physical home button that will take him back to the home screen.

Reset View hierarchy iOS

I'd like to add some code to the app delegate that resets the view hierarchy back to the beginning.
My app is basically a demonstration mockup, and I'd like EVERYTIME the app opens that it resets to the first view in the storyboard, and doesn't remember what page the user was on when they closed or 'minimized' the app.
I'm using iOS sdk 8.1, and Xcode 6.
Putting aside that it's actually quite bad user experience - it's very easy to do. You just need to specify that your app doesn't run in the background, and each time user closes app, next time - brand new copy will be launched.
Here is what you need to set in your project properties in Xcode:
If your'r info.plist Show raw keys/values option are enabled, the property is named UIApplicationExitsOnSuspend which you can get by right clicking on the empty space of info.plist properties table and selecting Add Row option as follows
and right after that you will be presented with following option,
where you can select second options which is Application does not run in the background.
Selecting the mentioned property and setting it to YES, the app opt out of background mode and it cycles between the not-running, inactive, and active states and never enters the background or suspended states and moved back to the not-running state. In other words, iOS will not preserved any states which allows the app to run as fresh on next launch.

Prevent application from entering background, requiring a code to close app

I would like to add functionality to my iPad app such that, when the home button is pressed and my app is about to enter the background, a message box pops up requesting a code. Only if the correct code is entered will the application go into the background, otherwise the app will not close.
Is this possible?
Short answer, no it's not possible.

Resources