{"id":4631,"url":"https://github.com/c19354837/react-native-system-setting","last_synced_at":"2025-09-28T01:52:41.371Z","repository":{"id":38359906,"uuid":"92792753","full_name":"c19354837/react-native-system-setting","owner":"c19354837","description":"A library to access system setting, and change it easily. eg: volume, brightness, wifi","archived":false,"fork":false,"pushed_at":"2023-06-27T03:13:18.000Z","size":1511,"stargazers_count":446,"open_issues_count":68,"forks_count":162,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-07-22T23:25:23.299Z","etag":null,"topics":["airplane","bluetooth","brightness","location","react-native","setting","system","volume","wifi"],"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/c19354837.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-05-30T02:50:48.000Z","updated_at":"2025-07-12T11:21:21.000Z","dependencies_parsed_at":"2022-08-10T07:00:25.158Z","dependency_job_id":"ebe01230-3ba5-410d-bfa6-ba4791805e9d","html_url":"https://github.com/c19354837/react-native-system-setting","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/c19354837/react-native-system-setting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c19354837%2Freact-native-system-setting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c19354837%2Freact-native-system-setting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c19354837%2Freact-native-system-setting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c19354837%2Freact-native-system-setting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c19354837","download_url":"https://codeload.github.com/c19354837/react-native-system-setting/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c19354837%2Freact-native-system-setting/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268636491,"owners_count":24282098,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["airplane","bluetooth","brightness","location","react-native","setting","system","volume","wifi"],"created_at":"2024-01-05T20:17:18.478Z","updated_at":"2025-09-28T01:52:36.286Z","avatar_url":"https://github.com/c19354837.png","language":"Java","readme":"## react-native-system-setting\nIt provides some system setting APIs for you. Support iOS and Android both.\n\n### Support\n\n* Volume ( with listener)\n* Brightness\n* Wifi switch\n* Location\n* Bluetooth\n* Airplane\n\n### Note\n\n**[Example](https://github.com/c19354837/react-native-system-setting/tree/master/examples/SystemSettingExample) only work in the real device**\n\n### Change Log\n\n[Change Log](https://github.com/c19354837/react-native-system-setting/blob/master/CHANGELOG.md)\n\nbreaking change for permission since V1.5.0, see [Android Permission](https://github.com/c19354837/react-native-system-setting#android-permission)\n\n## Look like\n\nI really want to show the .gif, while it has no difference with .jpg for some system limit.\n\nI strongly recommend you to run the example in real device to see how it works.\n\n\u003cimg src=\"https://raw.githubusercontent.com/c19354837/react-native-system-setting/master/screenshot/ios.png\" width = \"40%\"/\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\n\u003cimg src=\"https://raw.githubusercontent.com/c19354837/react-native-system-setting/master/screenshot/android.jpg\" width = \"40%\" /\u003e\n\n## Install\nRun `npm i -S react-native-system-setting`\n\n**Note: if your project was created by [Create React Native App](https://github.com/react-community/create-react-native-app), you should [Eject](https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md) before link it.**\n\n#### iOS\nRun `react-native link` to link this library.\n\nOr add `pod 'RCTSystemSetting', :path =\u003e '../node_modules/react-native-system-setting'` in `Podfile` for Cocoapods.\n\nIf link does not work, you can do it [manually](https://facebook.github.io/react-native/docs/linking-libraries-ios.html).\n\n#### Android\nRun `react-native link` to link this library.\n\nThat's all.\n\nIf link does not work, you can do it manually. Just follow this way:\n\n**android/settings.gradle**\n\n```gradle\ninclude ':react-native-system-setting'\nproject(':react-native-system-setting').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-system-setting/android')\n```\n\n**android/app/build.gradle**\n\n```gradle\ndependencies {\n   ...\n   compile project(':react-native-system-setting')\n}\n```\n\n**android/app/src/main/java/..packageName../MainApplication.java**\n\nOn top, where imports are:\n\n```java\nimport com.ninty.system.setting.SystemSettingPackage;\n```\n\nAdd the `SystemSettingPackage` class to your list of exported packages.\n\n```java\n@Override\nprotected List\u003cReactPackage\u003e getPackages() {\n    return Arrays.asList(\n            new MainReactPackage(),\n            new SystemSettingPackage()\n    );\n}\n```\n\n## Usage\n\n**Common import**\n\n```javascript\nimport SystemSetting from 'react-native-system-setting'\n```\n\n**volume**\n\n```javascript\n//get the current volume\nSystemSetting.getVolume().then((volume)=\u003e{\n    console.log('Current volume is ' + volume);\n});\n\n// change the volume\nSystemSetting.setVolume(0.5);\n\n// listen the volume changing if you need\nconst volumeListener = SystemSetting.addVolumeListener((data) =\u003e {\n    const volume = data.value;\n    console.log(volume);\n});\n\n//remove listener when you need it no more\nSystemSetting.removeVolumeListener(volumeListener)       \n```\n\n\u003e `setVolume` can do more, [more detail](https://github.com/c19354837/react-native-system-setting/blob/master/API.md) \n\n**brightness**\n\n```javascript\n//get the current brightness\nSystemSetting.getBrightness().then((brightness)=\u003e{\n    console.log('Current brightness is ' + brightness);\n});\n\n//change the brightness \u0026 check permission\nSystemSetting.setBrightnessForce(0.5).then((success)=\u003e{\n    !success \u0026\u0026 Alert.alert('Permission Deny', 'You have no permission changing settings',[\n\t   {'text': 'Ok', style: 'cancel'},\n\t   {'text': 'Open Setting', onPress:()=\u003eSystemSetting.grantWriteSettingPermission()}\n\t])\n});\n\n// save the value of brightness and screen mode.\nSystemSetting.saveBrightness();\n// restore the brightness and screen mode. you can get the old brightness value.\nSystemSetting.restoreBrightness().then((oldVal)=\u003e{\n    //if you need\n})\n\n// change app's brightness without any permission.\nSystemSetting.setAppBrightness(0.5);\nSystemSetting.getAppBrightness().then((brightness)=\u003e{\n    console.log('Current app brightness is ' + brightness);\n})\n```\n\n\u003e `setBrightness()` \u0026 `saveBrightness()` need [permission](https://github.com/c19354837/react-native-system-setting#android-permission) for Android\n\n**Wifi**\n\n```javascript\nSystemSetting.isWifiEnabled().then((enable)=\u003e{\n    const state = enable ? 'On' : 'Off';\n    console.log('Current wifi is ' + state);\n})\n\nSystemSetting.switchWifi(()=\u003e{\n    console.log('switch wifi successfully');\n})\n```\n\n\u003e `isWifiEnabled()` need [permission](https://github.com/c19354837/react-native-system-setting#android-permission) for Android\n\u003e \n\u003e `switchWifi()` is disabled by default for iOS since V1.7.0, [enable it](https://github.com/c19354837/react-native-system-setting/blob/master/iOS.md#ios)\n\n**Location**\n\n```javascript\nSystemSetting.isLocationEnabled().then((enable)=\u003e{\n    const state = enable ? 'On' : 'Off';\n    console.log('Current location is ' + state);\n})\n\nSystemSetting.switchLocation(()=\u003e{\n    console.log('switch location successfully');\n})\n```\n\u003e `switchLocation()` is disabled by default for iOS since V1.7.0, [enable it](https://github.com/c19354837/react-native-system-setting/blob/master/iOS.md#ios)\n\n**Bluetooth**\n\n```javascript\nSystemSetting.isBluetoothEnabled().then((enable)=\u003e{\n    const state = enable ? 'On' : 'Off';\n    console.log('Current bluetooth is ' + state);\n})\n\nSystemSetting.switchBluetooth(()=\u003e{\n    console.log('switch bluetooth successfully');\n})\n```\n\n\u003e `isBluetoothEnabled()` need [permission](https://github.com/c19354837/react-native-system-setting#android-permission) for Android\n\u003e\n\u003e All bluetooth-function are disabled by default for iOS since V1.7.0, [enable it](https://github.com/c19354837/react-native-system-setting/blob/master/iOS.md#ios)\n\n**Airplane**\n\n```javascript\nSystemSetting.isAirplaneEnabled().then((enable)=\u003e{\n    const state = enable ? 'On' : 'Off';\n    console.log('Current airplane is ' + state);\n})\n\nSystemSetting.switchAirplane(()=\u003e{\n    console.log('switch airplane successfully');\n})\n```\n\n\u003e `isAirplaneEnabled()` will always return `true` for iOS if your device has no SIM card, see [detail](https://github.com/c19354837/react-native-system-setting/issues/37)\n\u003e \n\u003e `switchAirplane()` is disabled by default for iOS since V1.7.0, [enable it](https://github.com/c19354837/react-native-system-setting/blob/master/iOS.md#ios)\n\n**Other**\n\n```javascript\n// open app setting page\nSystemSetting.openAppSystemSettings()\n```\n\n## API\n\n[API](https://github.com/c19354837/react-native-system-setting/blob/master/API.md)\n\n## Run example\n\n```\n$ cd example/SystemSettingExample\n$ npm install\n// if android\n$ react-native run-android\n// else\n$ react-native run-ios\n```\n\n## iOS\n\nTo be more friendly to app store, I disable some APIs for iOS since V1.7.0, You can [enable it](https://github.com/c19354837/react-native-system-setting/blob/master/iOS.md#ios) in a few steps.\n\n## Android permission\n \n### API\n\nDefault permissions are removed since V1.5.0, see [this PR](https://github.com/c19354837/react-native-system-setting/pull/44). You need to declare the corresponding permissions in your app's AndroidManifest.xml, see [example AndroidManifest.xml](https://github.com/c19354837/react-native-system-setting/blob/master/examples/SystemSettingExample/android/app/src/main/AndroidManifest.xml)\n\n**`android/app/src/main/AndroidManifest.xml`**\n\n```xml\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"YourPackageName\"\n    android:versionCode=\"1\"\n    android:versionName=\"1.0\"\u003e\n    \n    \u003c!-- setBrightness() \u0026 setScreenMode() \u0026 saveBrightness() --\u003e\n    \u003cuses-permission android:name=\"android.permission.WRITE_SETTINGS\" /\u003e\n    \n    \u003c!-- isWifiEnabled() --\u003e\n    \u003cuses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/\u003e\n    \n    \u003c!-- isBluetoothEnabled() --\u003e\n    \u003cuses-permission android:name=\"android.permission.BLUETOOTH\"/\u003e\n    \n    \u003c!-- * switchWifiSilence() --\u003e\n    \u003cuses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/\u003e\n\n    \u003c!-- * switchBluetoothSilence() --\u003e\n    \u003cuses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/\u003e\n    \n    ...\n\n\u003c/manifest\u003e\n```\n\n\u003e There are some different APIs that end with `silence`. They can do the job programmatically without direct user consent. These APIs maybe useful when you develop a system management app. Or, you should call `switchWifi()` \u0026 `switchBluetooth()` to get a better user experience\n\n### Do Not Disturb\n\n`setVolume()` may cause a crash: **Not allowed to change Do Not Disturb state**. See [detail](https://github.com/c19354837/react-native-system-setting/issues/48).\n\n### Runtime permission for Android 6+\n\nChange *brightness* and *screen mode* need `android.permission.WRITE_SETTINGS` which user can disable it in phone Setting. When you call `setScreenMode()`, `setBrightness()` or `setBrightnessForce()` , it will return false if the app has no permission, and you can call `SystemSetting.grantWriteSettingPermission()` to guide user to app setting page. see [example](https://github.com/c19354837/react-native-system-setting/tree/master/examples/SystemSettingExample)\n\n\u003e If you just want to change app's brightness, you can call `setAppBrightness(val)`, and it doesn't require any permission. see [API](https://github.com/c19354837/react-native-system-setting/blob/master/API.md)\n\n## In the end\n\nFeel free to open issue or pull request\n\n## License\n[**MIT**](https://github.com/c19354837/react-native-system-setting/blob/master/LICENSE.md)\n","funding_links":[],"categories":["Components","Java"],"sub_categories":["System"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc19354837%2Freact-native-system-setting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc19354837%2Freact-native-system-setting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc19354837%2Freact-native-system-setting/lists"}