Lock and unlock screen - iPad - ios

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.

Related

Determining if assets need to be re-cached in memory

Assume a game app, where user loads some contents into memory during first open. Afterwards they can:
Move app into background
Lock device
Close app completely
Get a phone call
etc...
Is there a way to know when our app's contents are no longer in memory or something of similar sorts to determine when re-caching of assets is required?
I studied few game apps and they tend to do one of the following
Show loading screen every time app comes back from background
Show loading screen only if device was locked or closed (app is still in the background)
And I'm interested in achieving no.2 to not show loading screens unnecessarily each time app comes back from the background.
You can use AppDelegate method applicationWillTerminate
https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623111-applicationwillterminate
And notification willTerminateNotification
https://developer.apple.com/documentation/uikit/uiapplication/1623061-willterminatenotification
If Application not terminate you don't need show any loading screen.

Notification with sound and vibration when iphone is Locked

I am currently working on an iOS app and i need some help.
I want the app to be able to notify the user about something in form a "push notification" even when the phone locked. The push notifications work fine when the phone is not locked but as soon as i lock the phone it wont give me any sound or vibration. It will only show me the visual part of the notification but it comes in completely silence. It does not even light the screen up when the notification gets pushed to the user.
I currently use
content.sound = UNNotificationSound.default()
And it works fine with sound and vibration when the phone is unlocked.
Is it because i need to do something with my settings? do i need any code to do such thing? do i need to have developer account?
Any help would make me really happy!!
3 STEPS TO HOPEFULLY RECOVER SOUND ON YOUR IPHONE FOR INCOMING NOTIFICATIONS.
Check that the ringer on the left of the phone doesn’t show an orange line – indicating sound switched off. If so, slide it to the right so only white is showing. This may have fixed it.
Swipe up from the bottom of the screen to reveal symbols, music etc. Ensure that the half moon symbol is grey and not white. If it’s white touch it to make it grey – this will switch off do not disturb. This may have fixed it.
Check your settings, Do not Disturb half moon icon, ensure that Manual is off and not showing a green on icon. If it is, touch the green icon which will make it white and switch it off. This may have fixed it.
(I hope that helps, it worked for my iphone 5C as I’d inadvertently switched on Do Not disturb as shown in step 2. above.)
Just an FYI if someone else is having this same issue. I was having the same troubles getting my notifications to come through on my phone when it was locked.
I realized the issue was I was building to my physical device which was also attached to the Apple Watch I was wearing. Since my watch is set to mirror my iPhone notifications the phone didn't play them as it expected my watch to take over when was locked. However, every time you build & run your app it takes a few minutes for your watch to recognize your app and take over the user notifications.
The solution here is to either wait 10 minutes or so after building and then try firing off a notification (which should appear on your watch) OR simple take off your watch before you build & run.

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.

Show ios push notification for long time on phone screen

Is there any way to show a particular type(some important) of push notification for some 5-10 seconds on the iOS device screen when app is in background.
No, the time is fixed.
You cannot customize it - a push-notification should be a short message that in the best case makes the user tap it and open the app. There is actually not really a need for a longer time. Keep it short, simple and interesting and the user will react accordingly anyway. A longer time should not really make any difference other than people getting annoyed because your messages are always staying on top, blocking other messages and wasting screen space.

Changing the behavior of the iOS Lockscreen

Is there a way to change the behavior of the iOS Lockscreen? For instance, can an app, if active, provide a user with dynamic content, such as pictures, as the phone's background, and, in addition, allow a user to swipe left (in addition to swiping right, if they want to unlock the phone) to engage said content?
Is there a way to change the behavior of the iOS Lockscreen?
No.
For instance, can an app, if active...
No.
iOS doesn't provide any API that would allow the sort of thing that you describe. It might be possible to modify or replace the lock screen if you jailbreak your phone -- all bets are off at that point. But an app that uses the Apple-provided API has no way to modify the lock screen.
Also, note that if the device is locked, your app won't be active. You may have intended a looser definition of "active," but looking at the linked chart of app states will help you understand that what you're looking to do isn't achievable with the current API. Apps have to be active to receive events, but a locked phone implies that your app will be in an inactive, background, or suspended state if it's running at all.
No. (Not if you're talking about an 'app' in the sense of the App Store)
The only way an app can interact with the lock screen is through notifications, and cannot alter the standard lock screen interface.
You can alter the lock screen with a MobileSubstrate tweak on a jailbroken phone, but this requires reverse-engineering SpringBoard (the iOS launcher app), can be quite complicated and obviously cannot be distributed through the App Store

Resources