rn保持屏幕常亮 react-native-idle 及1.1.0在iOS模拟器或SE真机闪退的某个原因解决方法
react-native-idle
Prevent screen to sleep in ReactNative app.
Install
npm install react-native-idle --save react-native link react-native-idle
Usage
import RNIdle from 'react-native-idle'
RNIdle.disableIdleTimer() //保持屏幕常亮
RNIdle.enableIdleTimer() //退出屏幕常亮
npm地址:https://www.npmjs.com/package/react-native-idle
闪退解决方式:
RNIdle.m中替换下面的代码:
RCT_EXPORT_METHOD(disableIdleTimer)
{
// DON'T let the device go to sleep during our sync
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
});
}
RCT_EXPORT_METHOD(enableIdleTimer)
{
// DON'T let the device go to sleep during our sync
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
});
}
本文地址:https://blog.csdn.net/loveseal518/article/details/109644407
下一篇: 你脸皮厚得让我无颜活在这个世上