Search code examples
iosios-simulator

How can I simulate a change is in the power state with the ios emulator


I have some functionality that changes based on the device battery status, i.e. if it is charging/full else running on battery. I'm not trying to find out if the phone is in 'low battery status', only if it is plugged in or not.

Is there a way I can test this with the iOS simulator?


Solution

  • I did not achieve this with a simulator however I used network debugging with my iPhone and then I could plug and unplug the power without affecting my debug session.

    Cmd + Shift + 2 and then select Connect via Network.

    Device Settings