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

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.

Related

How do I prevent iOS device from locking while on a particular screen?

My app includes a 'Sleep Mode' that is initiated by pressing a button on the main screen. While on this screen I want to prevent the phone from locking automatically but still allow auto dimming. If the user leaves the app by manually locking their device or pressing the home button they should be able to navigate back to the app and have their device remain unlocked. What is the best way to accomplish this in objective-c?
You can add the following code to prevent device getting auto locked
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

Is there anyway to stop screen-lock while my app is in foreground in iOS App?

I do not want the user to be able to lock the screen while app is in foreground, even when the user forcefully tries to lock the screen with hardware lock button. Is there anyway to make it function programmatically?
Please do not tell me idleTimerDisabled property of UIApplication class.
[UIApplication sharedApplication].idleTimerDisabled = YES;
It does not work for what i'm looking.
This is not possible using the iOS SDK. You have no mechanism for making the user unable to do things like lock the screen or not press the home button.

Objective C - Detect if finger is held on screen at app startup

I'd like to perform an action when the user has their finger held on the screen when my app startups.
To give an example: When the App launches and the launch screen is showing up, the user has a finger on the screen as long as the first ViewController appears. When the first ViewController gets into the viewDidAppear() function, I want to detect, that the users finger is on the screen and perform an action, like f.ex. jumping straight into the lastest received email. Basically this is supposed to be a kind of shortcut to an main action.
Is there any method to detect an already laying finger on the screen? To be exactly I'd like to check for the tap in viewDidAppear()
Unless the nature of Time has changed since the last time I checked, your app cannot detect what the user was doing before the app launched. The app, ex hypothesi, was not running at that time. And the mere presence of a finger on the screen during app launch will not generate a touch event that the app can detect.
The system can detect it, however, since is running before your app launches. That is why Apple added force-touch Shortcuts (for appropriate hardware). The only way you can do what you're asking is to rely on that API. Hardware that lacks this feature will simply have to do without this feature.
(After all, this is how Apple makes money: by trying to make users jealous of hardware they don't have, so that they buy new hardware. You would want to rob Apple of its income by reading this feature backwards onto old hardware, even if you could, now would you?)

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.

Lock and unlock screen - iPad

Would it be possible to lock a device screen and unlock it again? The reason I would want to do this is we have a kiosk type app and we would like to turn of the screen between certain times.
I would think a type of push notification would be needed?
Once iPad is locked you're not going to be able to unlock it programmatically, even through a push notification. Assuming these devices are always plugged in you may be better off turning off the idleTimer (which I'm assuming you already have) then invoke some sort of screen save or idle screen that displays during those hours. That way your app never allows the iPad to lock natively and you can control when clients do & don't see the content.
That brings up a design question, though... what happens if someone is present when the idle screen is up? Should you override or keep it on the idle screen? Just thinking out loud.

Resources