forked from selahssea-zz/Cordova-open-native-settings
-
Notifications
You must be signed in to change notification settings - Fork 105
/
NativeSettings.m
185 lines (176 loc) · 7.76 KB
/
NativeSettings.m
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#import "NativeSettings.h"
@implementation NativeSettings
- (BOOL)do_open:(NSString *)pref {
if ([[UIApplication sharedApplication] openURL:[NSURL URLWithString:pref]]) {
return YES;
} else {
return NO;
}
}
- (void)open:(CDVInvokedUrlCommand*)command
{
CDVPluginResult* pluginResult = nil;
NSString* key = [command.arguments objectAtIndex:0];
NSString* prefix = @"App-Prefs:";
BOOL result = NO;
if(SYSTEM_VERSION_LESS_THAN(@"11.3")){
prefix = @"app-settings:";
}
if ([key isEqualToString:@"application_details"]) {
result = [self do_open:UIApplicationOpenSettingsURLString];
}
else if ([key isEqualToString:@"settings"]) {
result = [self do_open:prefix];
}
else if ([key isEqualToString:@"about"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=About"]];
}
else if ([key isEqualToString:@"accessibility"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=ACCESSIBILITY"]];
}
else if ([key isEqualToString:@"account"]) {
result = [self do_open:[prefix stringByAppendingString:@"ACCOUNT_SETTINGS"]];
}
else if ([key isEqualToString:@"autolock"]) {
result = [self do_open:[prefix stringByAppendingString:@"DISPLAY&path=AUTOLOCK"]];
}
else if ([key isEqualToString:@"display"]) {
result = [self do_open:[prefix stringByAppendingString:@"Brightness"]];
}
else if ([key isEqualToString:@"bluetooth"]) {
result = [self do_open:[prefix stringByAppendingString:@"Bluetooth"]];
}
else if ([key isEqualToString:@"castle"]) {
result = [self do_open:[prefix stringByAppendingString:@"CASTLE"]];
}
else if ([key isEqualToString:@"cellular_usage"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=USAGE/CELLULAR_USAGE"]];
}
else if ([key isEqualToString:@"configuration_list"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=ManagedConfigurationList"]];
}
else if ([key isEqualToString:@"date"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=DATE_AND_TIME"]];
}
else if ([key isEqualToString:@"facetime"]) {
result = [self do_open:[prefix stringByAppendingString:@"FACETIME"]];
}
else if ([key isEqualToString:@"settings"]) {
result = [self do_open:[prefix stringByAppendingString:@"General"]];
}
else if ([key isEqualToString:@"tethering"]) {
result = [self do_open:[prefix stringByAppendingString:@"INTERNET_TETHERING"]];
}
else if ([key isEqualToString:@"music"]) {
result = [self do_open:[prefix stringByAppendingString:@"MUSIC"]];
}
else if ([key isEqualToString:@"music_equalizer"]) {
result = [self do_open:[prefix stringByAppendingString:@"MUSIC&path=EQ"]];
}
else if ([key isEqualToString:@"music_volume"]) {
result = [self do_open:[prefix stringByAppendingString:@"MUSIC&path=VolumeLimit"]];
}
else if ([key isEqualToString:@"keyboard"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=Keyboard"]];
}
else if ([key isEqualToString:@"locale"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=INTERNATIONAL"]];
}
else if ([key isEqualToString:@"location"]) {
result = [self do_open:[prefix stringByAppendingString:@"LOCATION_SERVICES"]];
}
else if ([key isEqualToString:@"locations"]) {
result = [self do_open:[prefix stringByAppendingString:@"Privacy&path=LOCATION"]];
}
else if ([key isEqualToString:@"tracking"]) {
result = [self do_open:[prefix stringByAppendingString:@"Privacy&path=USER_TRACKING"]];
}
else if ([key isEqualToString:@"network"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=Network"]];
}
else if ([key isEqualToString:@"nike_ipod"]) {
result = [self do_open:[prefix stringByAppendingString:@"NIKE_PLUS_IPOD"]];
}
else if ([key isEqualToString:@"notes"]) {
result = [self do_open:[prefix stringByAppendingString:@"NOTES"]];
}
else if ([key isEqualToString:@"notification_id"]) {
result = [self do_open:[prefix stringByAppendingString:@"NOTIFICATIONS_ID"]];
}
else if ([key isEqualToString:@"passbook"]) {
result = [self do_open:[prefix stringByAppendingString:@"PASSBOOK"]];
}
else if ([key isEqualToString:@"phone"]) {
result = [self do_open:[prefix stringByAppendingString:@"Phone"]];
}
else if ([key isEqualToString:@"photos"]) {
result = [self do_open:[prefix stringByAppendingString:@"Photos"]];
}
else if ([key isEqualToString:@"reset"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=Reset"]];
}
else if ([key isEqualToString:@"ringtone"]) {
result = [self do_open:[prefix stringByAppendingString:@"Sounds&path=Ringtone"]];
}
else if ([key isEqualToString:@"browser"]) {
result = [self do_open:[prefix stringByAppendingString:@"Safari"]];
}
else if ([key isEqualToString:@"search"]) {
result = [self do_open:[prefix stringByAppendingString:@"SIRI"]];
}
else if ([key isEqualToString:@"sound"]) {
result = [self do_open:[prefix stringByAppendingString:@"Sounds"]];
}
else if ([key isEqualToString:@"software_update"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=SOFTWARE_UPDATE_LINK"]];
}
else if ([key isEqualToString:@"storage"]) {
result = [self do_open:[prefix stringByAppendingString:@"CASTLE&path=STORAGE_AND_BACKUP"]];
}
else if ([key isEqualToString:@"store"]) {
result = [self do_open:[prefix stringByAppendingString:@"STORE"]];
}
else if ([key isEqualToString:@"usage"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=USAGE"]];
}
else if ([key isEqualToString:@"video"]) {
result = [self do_open:[prefix stringByAppendingString:@"VIDEO"]];
}
else if ([key isEqualToString:@"vpn"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=Network/VPN"]];
}
else if ([key isEqualToString:@"wallpaper"]) {
result = [self do_open:[prefix stringByAppendingString:@"Wallpaper"]];
}
else if ([key isEqualToString:@"wifi"]) {
result = [self do_open:[prefix stringByAppendingString:@"WIFI"]];
}
else if ([key isEqualToString:@"touch"]) {
result = [self do_open:[prefix stringByAppendingString:@"TOUCHID_PASSCODE"]];
}
else if ([key isEqualToString:@"battery"]) {
result = [self do_open:[prefix stringByAppendingString:@"BATTERY_USAGE"]];
}
else if ([key isEqualToString:@"privacy"]) {
result = [self do_open:[prefix stringByAppendingString:@"Privacy"]];
}
else if ([key isEqualToString:@"do_not_disturb"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=DO_NOT_DISTURB"]];
}
else if ([key isEqualToString:@"keyboards"]) {
result = [self do_open:[prefix stringByAppendingString:@"General&path=Keyboard/KEYBOARDS"]];
}
else if ([key isEqualToString:@"mobile_data"]) {
result = [self do_open:[prefix stringByAppendingString:@"MOBILE_DATA_SETTINGS_ID"]];
}
else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid Action"];
}
if (result) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Opened"];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Cannot open"];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
@end