Batteries don’t last forever; when they run low, your iPhone can turn off without warning. Here’s what can cause an iPhone to turn on and off without warning, and some solutions that have worked for us.
My iPhone Keeps Turning On and Off? Here’s Why and How to Fix It!
If your iPhone doesn't stay on long enough to try these steps, visit an Apple Store (or use another device to access Apple's support website).
Restart your iPhone. We don’t mean putting it to sleep and waking it up; we mean turning it off. Once it’s off, press and hold the Sleep/Wake button to turn it back on (when you see the Apple logo on your iPhone’s screen).
Check the health of your battery. The Battery Health section will also tell you if your battery is at a point where it needs to be replaced.