{"id":19269300,"url":"https://github.com/listenzz/react-native-platform","last_synced_at":"2025-04-21T20:32:29.718Z","repository":{"id":39996187,"uuid":"232764602","full_name":"listenzz/react-native-platform","owner":"listenzz","description":"Platform tools for React Native.","archived":false,"fork":false,"pushed_at":"2023-12-14T06:33:24.000Z","size":893,"stargazers_count":8,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T15:56:25.296Z","etag":null,"topics":["android","ios","platform","react-native","tools","utils"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/listenzz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-09T08:53:07.000Z","updated_at":"2024-11-07T01:47:25.000Z","dependencies_parsed_at":"2024-11-09T20:19:42.359Z","dependency_job_id":"6e480e06-6255-4256-a569-1e8861fb6f2f","html_url":"https://github.com/listenzz/react-native-platform","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2Freact-native-platform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2Freact-native-platform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2Freact-native-platform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2Freact-native-platform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/listenzz","download_url":"https://codeload.github.com/listenzz/react-native-platform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250128338,"owners_count":21379493,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","ios","platform","react-native","tools","utils"],"created_at":"2024-11-09T20:19:22.348Z","updated_at":"2025-04-21T20:32:29.390Z","avatar_url":"https://github.com/listenzz.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Platform tools for React Native.\n\n- 申请后台运行白名单 （Android 保活）\n\n- 申请国内厂商后台管理白名单（Android 保活）\n\n- 打开系统设置\n\n- 打开 GPS 设置\n\n## 权限\n\n根据需要，请在 AndroidManifest.xml 中加入如下权限\n\n```xml\n\u003c!--申请加入电池优化白名单--\u003e\n\u003cuses-permission android:name=\"android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS\" /\u003e\n\u003c!--申请华为后台管理白名单--\u003e\n\u003cuses-permission android:name=\"com.huawei.systemmanager.permission.ACCESS_INTERFACE\" /\u003e\n```\n\n## 申请加入电池优化白名单\n\n```js\nimport { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from 'react-native-platform'\n\nbatteryOptimization = async () =\u003e {\n  if (Platform.OS === 'android' \u0026\u0026 Platform.Version \u003e= 23) {\n    const ignored = await isIgnoringBatteryOptimizations()\n    if (!ignored) {\n      requestIgnoreBatteryOptimizations()\n    } else {\n      Alert.alert('提示', '本 App 已加入电池保护名单')\n    }\n  } else {\n    Alert.alert('提示', '仅支持 Android6 以上系统')\n  }\n}\n```\n\n## 申请国内厂商后台管理白名单\n\n```js\nimport { showBackgroundSetting, isBackgroundSettingSupported, backgroudSettingTip } from 'react-native-platform'\n\nshowBackgroundSetting = () =\u003e {\n  if (Platform.OS !== 'android') {\n    Alert.alert('提示', '仅支持 Android 平台')\n    return\n  }\n\n  if (!isBackgroundSettingSupported()) {\n    Alert.alert('提示', '这款手机不支持该项设置，请联系客服')\n    return\n  }\n\n  Alert.alert('操作步骤', backgroudSettingTip(), [\n    {\n      text: '确定',\n      onPress: () =\u003e {\n        showBackgroundSetting()\n      },\n    },\n  ])\n}\n```\n\n## 感谢\n\n- [QMUI_Android](https://github.com/Tencent/QMUI_Android)\n\n- [Android 后台运行白名单，优雅实现保活](https://juejin.im/post/5dfaeccbf265da33910a441d)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flistenzz%2Freact-native-platform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flistenzz%2Freact-native-platform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flistenzz%2Freact-native-platform/lists"}