Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion DeviceSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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();

```


Expand Down
10 changes: 10 additions & 0 deletions android/src/main/java/com/rjblopes/opensettings/OpenSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down