Can I turn power off iPhone via App? - ios

Is it possible to make a sleep app for iPhone? It's like user sets a time and on that time the iphone automatically turns off.

No it is not possible. There is no public APIs available for switching off iOS device.

Related

Can we lock a phone with iOS programatically?

I need to set a timer to lock an iPhone from my app. While using the application, after 3 to 5 minutes the phone should become locked.
Short answer: You can't.
Long Answer: For the security of iOS users, Apple does not allow any application to work with important hardware matters, such as locking the iPhone or controlling the usage of other apps. If your app even attempts to do such a thing (using any method, like external APIs), your app will immediately be rejected by Apple. It is not even worth trying.
You cannot lock the screen programmatically without any private API. Even if you use a private API, your app may probably be rejected by App Store.
However you can indeed achieve by sending keyboard events from paired bluetooth hardware devices. But that means your code depends on a Bluetooth connection and I cannot think of any practice use of that. To do this with Bluetooth, click here.

iOS app to lock screen or turn off device after a specific time

I have experience programming in OS X but have never programmed in iOS. I want to create a special iOS apps for my special needs to prevent my kid from spending too much times in my IPhone/IPad. It's a simple app which allows the user to set the time and once the time elapses, the device can be either turned off or its screen will be locked.
May I know whether this is possible and what are the APIs involved? I just need a very brief idea for me to kick start.
Thanks in advance.
Your requirement is really special.
Unfortunately there is no way to lock your iOS device or automatically shut down it, unless you jailbreak the phone.
I would set the device to Kiosk Mode (Guided Access) or Single App Mode (Using Mobile Device Management). This will prevent your kid from exiting the app.
You could then program your app to stop responding after the elapsed time. It can't shut down the device, but should lock the screen after x minutes of inactivity (configured in the settings).

Lock iPhone and iPad Screen programmatically

I want to lock screen iPhone and iPad programmatically
I have searched a lot but didn't get proper idea. I have found one app Lock me but it is not worked on after iOS 7.
here is that link
https://github.com/neuroo/LockMeNow
as per my search I think we are able to implement this functionality using private api and using kiosk mode.
I don't think you can programmatically lock the iPhone or iPad from you application. that not full fit the apple policy and its guide line. In iOS app development we can not handle any API that out of the application. Apple not make any API for lock screen that you fire from your native app.
Other things is you are attached one link in your question. that clearly write the limitation that:
This application can obviously not be accepted (as is) on the Apple Store, and that's mostly why I put it here. If you want to use the application, you will need a developer cert (or a jailbroken device and using the iDevice build toolchain).

iOS Private API: lock device and power off the screen

I'm making an app for jailbreak that lock the device when the user launch the app. I've tried GSEventLockDevice(); from GraphicsServices.framework but this does not work properly because it locks the screen but does not power off the screen. Is there another way to lock the screen without MobileSubstrate?
Just as another alternative, check out this answer, which uses SBDimScreen(). You could use that in conjunction with GSEventLockDevice().
It appears that you may now (iOS 5+) need to add an entitlement to your app to use this call successfully. If you haven't done that before, here is an example of how to do so. Obviously, in this case, the entitlement in question must be changed to com.apple.backboard.client.
You also might see if #VictorRonin has experimented with this, as he commented on the question I linked to. I tested SBDimScreen() on a jailbroken iOS 4.2.1 device, but my newer devices are currently unavailable to run this test. I'll try it later on iOS 5.x and post an update.
Note: the answer I linked to from Elias has a different call altogether for iOS 6.
Look at these several questions:
Simulating System Wide Touch Events on iOS
Simulating System Wide Touch Events in iOS without jailbreaking the device
How to send a touch event to iPhone OS?
The idea is that you can simulate system wide events. One of events is power down event. If you simulate it, it will turn off device and will lock it.
BTW. You may be interested to google more on GSEvent which is the key for even simulation.
Here are couple of useful links:
http://iphonedevwiki.net/index.php/GSEvent
http://networkpx.blogspot.com/2009/08/gsevent-recording-and-playback-in-30.html
Also, this approach isn't limited to jailbroken phones. It works on jailed phone too (however, you won't be able to post it to AppStore).

Force other apps to release microphone in iOS

I noticed it is possible for an iOS app to continue recording audio in the background while another app is in the foreground recording audio (note that this isn't strait forward on the iOS simulator, but a hack involving a background process makes it possible).
Is there any way to ensure that no other apps are recording audio before you start to record? If so, is there any way to stop other recording apps so that an app can record?
No, you cannot hinder another applications functions (well not using the iOS SDK) the only way this would be possible is on a jailbroken iPhone. But with an application built for the App Store this is not possible.
I think you may just tell user you can not get access, let them to turn off other background app.

Resources