Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/listenzz/react-native-platform
Platform tools for React Native.
https://github.com/listenzz/react-native-platform
android ios platform react-native tools utils
Last synced: 4 days ago
JSON representation
Platform tools for React Native.
- Host: GitHub
- URL: https://github.com/listenzz/react-native-platform
- Owner: listenzz
- License: mit
- Created: 2020-01-09T08:53:07.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-14T06:33:24.000Z (11 months ago)
- Last Synced: 2024-10-31T18:56:32.470Z (14 days ago)
- Topics: android, ios, platform, react-native, tools, utils
- Language: Java
- Homepage:
- Size: 872 KB
- Stars: 7
- Watchers: 1
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Platform tools for React Native.
- 申请后台运行白名单 (Android 保活)
- 申请国内厂商后台管理白名单(Android 保活)
- 打开系统设置
- 打开 GPS 设置
## 权限
根据需要,请在 AndroidManifest.xml 中加入如下权限
```xml
```
## 申请加入电池优化白名单
```js
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 以上系统')
}
}
```## 申请国内厂商后台管理白名单
```js
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()
},
},
])
}
```## 感谢
- [QMUI_Android](https://github.com/Tencent/QMUI_Android)
- [Android 后台运行白名单,优雅实现保活](https://juejin.im/post/5dfaeccbf265da33910a441d)