0.12.2 • Published 2 years ago
react-native-platform v0.12.2
Platform tools for React Native.
权限
根据需要,请在 AndroidManifest.xml 中加入如下权限
<!--电池优化-->
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<!--华为-->
<uses-permission android:name="com.huawei.systemmanager.permission.ACCESS_INTERFACE" />
电池优化设置
import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from 'react-native-platform'
batteryOptimization = async () => {
if (Platform.OS === 'android' && Platform.Version >= 23) {
const ignored = await isIgnoringBatteryOptimizations()
if (!ignored) {
requestIgnoreBatteryOptimizations()
} else {
Alert.alert('提示', '本 App 已加入电池保护名单')
}
} else {
Alert.alert('提示', '仅支持 Android6 以上系统')
}
}
后台运行设置
import { showBackgroundSetting, isBackgroundSettingSupported, backgroudSettingTip } from 'react-native-platform'
showBackgroundSetting = () => {
if (Platform.OS !== 'android') {
Alert.alert('提示', '仅支持 Android 平台')
return
}
if (!isBackgroundSettingSupported()) {
Alert.alert('提示', '这款手机不支持该项设置,请联系客服')
return
}
Alert.alert('操作步骤', backgroudSettingTip(), [
{
text: '确定',
onPress: () => {
showBackgroundSetting()
},
},
])
}
感谢
0.12.1
2 years ago
0.12.2
2 years ago
0.12.0
2 years ago
0.10.0
2 years ago
0.11.0
2 years ago
0.9.0
3 years ago
0.8.0
3 years ago
0.7.2
3 years ago
0.7.1
3 years ago
0.7.0
4 years ago
0.6.1
4 years ago
0.6.0
4 years ago
0.5.2
4 years ago
0.5.1
4 years ago
0.5.0
4 years ago
0.4.1
4 years ago
0.3.0
4 years ago
0.2.0
4 years ago
0.4.0
4 years ago
0.1.1
4 years ago
0.1.0
4 years ago