'React Native: Phone won't go to sleep while app is open

I'm trying to test some behavior in my React Native app when the phone goes to sleep, but the phone won't sleep when the app is open. I have the auto-lock set to 30s, and when the app's closed it does go to sleep. There are no keep-awake libraries to keep the app awake. It is making API calls every 60s; not sure if that's important.

Does anyone know what might cause this or what I can do to force the app to sleep?



Solution 1:[1]

I have just worked on a bug fix ticket for React Native sleep mode and ran into the exact same problem. I found a way to force app sleep. If by connecting to a physical device with usb, just push the hardware button. It should be located at right hand side of iPhone, you might need to press several times to make it sleep. If on simulator: In the menu bar while iOS Simulator is open, Click Hardware -> Lock.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 huailun