diff --git a/DeviceSettings.js b/DeviceSettings.js index dc05f03..ac57bec 100644 --- a/DeviceSettings.js +++ b/DeviceSettings.js @@ -42,4 +42,14 @@ function location(){ } } -module.exports = { open , app, wifi, location }; +function bluetooth(){ + try{ + (Platform.OS === 'ios') ? + Linking.openURL('App-prefs:root=Bluetooth') : + RNOpenSettings.bluetoothSettings(); + }catch(err){ + console.error(err); + } +} + +module.exports = { open , app, wifi, location, bluetooth }; diff --git a/README.md b/README.md index dd76357..331aa38 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ react-native link react-native-device-settings ``` ### Manual Install -### `iOS` +### iOS -NA: using Linking RN library. URLs applicable for IOS 10. @@ -61,6 +61,13 @@ DeviceSettings.app(); // Open wifi settings menu DeviceSettings.wifi(); + +// Open location settings menu [Android only] +DeviceSettings.location(); + +// Open Bluetooth settings menu +DeviceSettings.bluetooth(); + ``` diff --git a/android/src/main/java/com/rjblopes/opensettings/OpenSettings.java b/android/src/main/java/com/rjblopes/opensettings/OpenSettings.java index ba768c3..f9b6b8b 100644 --- a/android/src/main/java/com/rjblopes/opensettings/OpenSettings.java +++ b/android/src/main/java/com/rjblopes/opensettings/OpenSettings.java @@ -65,5 +65,15 @@ public void locationSettings() { reactContext.startActivity(intent); } } + + @ReactMethod + public void bluetoothSettings() { + Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); + if (intent.resolveActivity(reactContext.getPackageManager()) != null) { + reactContext.startActivity(intent); + } + } //endregion } diff --git a/package.json b/package.json index 4a0c5f9..54c01f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-device-settings", - "version": "1.2.0", + "version": "1.3.0", "description": "simple platform agnostic API to open device settings menus in react native", "main": "DeviceSettings.js", "scripts": {