forked from rjblopes/react-native-device-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeviceSettings.js
45 lines (39 loc) · 850 Bytes
/
DeviceSettings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { NativeModules, Linking, Platform } from 'react-native';
const { RNOpenSettings } = NativeModules;
function open(){
try{
(Platform.OS === 'ios') ?
Linking.openURL('App-prefs:') :
RNOpenSettings.generalSettings();
}catch(err){
console.error(err);
}
}
function app(){
try{
(Platform.OS === 'ios') ?
Linking.openURL('app-settings:') :
RNOpenSettings.appSettings();
}catch(err){
console.error(err);
}
}
function wifi(){
try{
(Platform.OS === 'ios') ?
Linking.openURL('App-prefs:root=WIFI') :
RNOpenSettings.wifiSettings();
}catch(err){
console.error(err);
}
}
function location(){
try{
if (Platform.OS !== 'ios') {
RNOpenSettings.locationSettings();
}
}catch(err){
console.error(err);
}
}
module.exports = { open , app, wifi, location };