How to Power iOS Device Off

How to power iOS device off

You cannot do this with the Public APIs provided by apple. This may be done using the unreleased Private APIs.
But According to Apple's policy, usage of any Private APIs will lead to rejection of App from App Store.

How do you power-down an iPhone X in the Xcode simulator?

Change your simulator to required version from Hardware -> Device ->
That way you will have correct version loaded and of course there is no way of "Shutdown" a simulator but quit, as this is just an application not hardware.
If you have multiple simulators open, you can close the not required ones by highlighting them and select File -> Close Window or CMD+W

Another good info from Colin :

I also just noticed that if I turn off "show device bezels" I get
regular window controls for closing the window, too.

Programmatically powering off an iPhone?

I don't have any evidence for that, but this would involve modifying the "UserExperience" - which is something that Apple never would allow (and why still many people jailbreak their phones).

And this involves "power off" as well as "mute sound" - because both could destroy the UX (you wait for an important call, but application X broke the sound).

Detect before the iPhone shuts down?

Had to test it.

applicationWillResignActive will be called once you hold power for shut down and you have option to swipe.

If you swipe to shutdown applicationDidEnterBackground will be called then applicationWillTerminate.

Maybe try not to use breakpoint but print to test.

But not sure how to know if it is regular closing of the app or shutdown.



Related Topics



Leave a reply



Submit