├── .gitignore ├── LICENSE ├── README.md ├── package.json ├── plugin.xml ├── src ├── android │ └── NativeSettings.java └── ios │ ├── NativeSettings.h │ └── NativeSettings.m └── www └── settings.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Guy Rombaut 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NativeSettings plugin for Cordova (6/7) 2 | 3 | The plugin allows you to open OS settings on iOS 8/9/10 and Android, via cordova-based app. For example, it will allow you to open the keyboard settings, Wifi, bluetooth etc (full list below). 4 | 5 | ## Adding/Removing the Plugin 6 | It will be saved to the config.xml file 7 | 8 | Ionic Framework: 9 | 10 | ```bash 11 | ionic cordova plugin (add|rm) cordova-open-native-settings 12 | ``` 13 | 14 | Cordova: 15 | 16 | ```bash 17 | cordova plugin (add|rm) cordova-open-native-settings --save 18 | ``` 19 | 20 | or via npm (It will be saved to the package.json file) 21 | 22 | ```bash 23 | npm (install|uninstall) cordova-open-native-settings --save 24 | ``` 25 | 26 | ## Using the plugin (opens Location Settings in Android and Application Settings in iOS) 27 | 28 | ``` 29 | cordova.plugins.settings.open(setting_constant, success_callback, failure_callback); 30 | ``` 31 | 32 | ### Example for iOS and Android - open Wifi settings 33 | 34 | ```js 35 | if (window.cordova && window.cordova.plugins.settings) { 36 | console.log('openNativeSettingsTest is active'); 37 | window.cordova.plugins.settings.open("wifi", function() { 38 | console.log('opened settings'); 39 | }, 40 | function () { 41 | console.log('failed to open settings'); 42 | } 43 | ); 44 | } else { 45 | console.log('openNativeSettingsTest is not active!'); 46 | } 47 | ``` 48 | 49 | In Android, by default it is opened in the same application as a new activity, the hardware back button will bring the user back to the previous activity (the app). In order to open settings as a new application (two applications will appear in "recent/opened" apps list) the following code can be used: 50 | `window.cordova.plugins.settings.open(["wifi", true], function() {}, function() {}); ....` 51 | 52 | ## Settings Options (Android) 53 | 54 | Setting constant | Description 55 | -----------------|------------ 56 | "accessibility" | Show settings for accessibility modules 57 | "account" | Show add account screen for creating a new account 58 | "airplane_mode" | Show settings to allow entering/exiting airplane mode 59 | "apn" | Show settings to allow configuration of APNs 60 | "application_details" | Show screen of details about a particular application 61 | "application_development" | Show settings to allow configuration of application development-related settings 62 | "application" | Show settings to allow configuration of application-related settings 63 | "battery_optimization" | Show screen for controlling which apps can ignore battery optimizations 64 | "biometric" | Show screen for configuring biometric based device security 65 | "bluetooth" | Show settings to allow configuration of Bluetooth 66 | "captioning" | Show settings for video captioning 67 | "cast" | Show settings to allow configuration of cast endpoints 68 | "data_roaming" | Show settings for selection of 2G/3G 69 | "date" | Show settings to allow configuration of date and time 70 | "display" | Show settings to allow configuration of display 71 | "dream" | Show Daydream settings 72 | "home" | Show Home selection settings 73 | "keyboard" | Show settings to configure input methods, in particular allowing the user to enable input methods 74 | "keyboard_subtype" | Show settings to enable/disable input method subtypes 75 | "locale" | Show settings to allow configuration of locale 76 | "location" | Show settings to allow configuration of current location sources 77 | "manage_all_applications" | Show settings to manage all applications 78 | "manage_applications" | Show settings to manage installed applications 79 | "memory_card" | Show settings for memory card storage 80 | "network" | Show settings for selecting the network operator 81 | "nfcsharing" | Show NFC Sharing settings 82 | "nfc_payment" | Show NFC Tap & Pay settings 83 | "nfc_settings" | Show NFC settings 84 | "notification_id" | Settings > Notifications 85 | "print" | Show the top level print settings 86 | "privacy" | Show settings to allow configuration of privacy options 87 | "quick_launch" | Show settings to allow configuration of quick launch shortcuts 88 | "search" | Show settings for global search 89 | "security" | Show settings to allow configuration of security and location privacy 90 | "settings" | Show system settings 91 | "show_regulatory_info" | Show the regulatory information screen for the device 92 | "sound" | Show settings to a llow configuration of sound and volume 93 | "storage" | Show settings for internal storage 94 | "store" | Open the Play Store page of the current application 95 | "sync" | Show settings to allow configuration of sync settings 96 | "usage" | Show settings to control access to usage information 97 | "user_dictionary" | Show settings to manage the user input dictionary 98 | "voice_input" | Show settings to configure input methods, in particular allowing the user to enable input methods 99 | "wifi_ip" | Show settings to allow configuration of a static IP address for Wi-Fi 100 | "wifi" | Show settings to allow configuration of Wi-Fi 101 | "wireless" | Show settings to allow configuration of wireless controls such as Wi-Fi, Bluetooth and Mobile networks 102 | 103 | 104 | ## Settings Options (iOS) 105 | 106 | Setting constant | Description 107 | -----------------|------------ 108 | "about" | Settings > General > About 109 | "accessibility" | Settings > General > Accessibility 110 | "account" | Settings > _Your name_ 111 | "airplane_mode" | Settings > Airplane Mode 112 | "application_details" | Settings 113 | "autolock" | Settings > General > Auto-Lock (before iOS 10) 114 | "battery" | Settings > Battery 115 | "bluetooth" | Settings > General > Bluetooth (before iOS 9)
Settings > Bluetooth (after iOS 9) 116 | "browser" | Settings > Safari 117 | "castle" | Settings > iCloud 118 | "cellular_usage" | Settings > General > Cellular Usage 119 | "configuration_list" | Settings > General > Profile 120 | "date" | Settings > General > Date & Time 121 | "display" | Settings > Display & Brightness 122 | "do_not_disturb" | Settings > Do Not Disturb 123 | "facetime" | Settings > Facetime 124 | "keyboard" | Settings > General > Keyboard 125 | "keyboards" | Settings > General > Keyboard > Keyboards 126 | "locale" | Settings > General > Language & Region 127 | "location" | Settings > Location Services (in older versions of iOS) 128 | "locations" | Settings > Privacy > Location Services (in newer versions of iOS) 129 | "tracking" | Settings > Privacy > Tracking (iOS 14+) 130 | "mobile_data" | Settings > Mobile Data (after iOS 10) 131 | "music" | Settings > iTunes 132 | "music_equalizer" | Settings > Music > EQ 133 | "music_volume" | Settings > Music > Volume Limit 134 | "network" | Settings > General > Network 135 | "nike_ipod" | Settings > Nike + iPod 136 | "notes" | Settings > Notes 137 | "notification_id" | Settings > Notifications 138 | "passbook" | Settings > Passbook & Apple Pay 139 | "phone" | Settings > Phone 140 | "photos" | Settings > Photo & Camera 141 | "privacy" | Settings > Privacy 142 | "reset" | Settings > General > Reset 143 | "ringtone" | Settings > Sounds > Ringtone 144 | "search" | Settings > General > Assistant (before iOS 10)
Settings > Siri (after iOS 10) 145 | "settings" | Settings > General 146 | "sound" | Settings > Sounds 147 | "software_update" | Settings > General > Software Update 148 | "storage" | Settings > iCloud > Storage & Backup 149 | "store" | Settings > iTunes & App Store 150 | "tethering" | Settings > Personal Hotspot 151 | "touch" | Settings > Touch ID & Passcode 152 | "twitter" | Settings > Twitter 153 | "usage" | Settings > General > Storage & iCloud Usage 154 | "video" | Settings > Video 155 | "vpn" | Settings > General > VPN 156 | "wallpaper" | Settings > Wallpaper 157 | "wifi" | Settings > WIFI 158 | 159 | ## Notes 160 | * Android plugin based on the following information: https://developer.android.com/reference/android/provider/Settings.html#ACTION_DREAM_SETTINGS 161 | * iOS plugin based on the following information: https://gist.github.com/phynet/471089a51b8f940f0fb4 162 | * In iOS, this plugin generates a URL scheme for the *-Info.plist configurations file. 163 | * The plugin for Android is based on the forked repository and was refactored. The iOS part was built from skretch. 164 | 165 | ## License 166 | ``` 167 | The MIT License 168 | 169 | Copyright (c) 2016 Guy Rombaut 170 | 171 | Permission is hereby granted, free of charge, to any person obtaining a copy 172 | of this software and associated documentation files (the "Software"), to deal 173 | in the Software without restriction, including without limitation the rights 174 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 175 | copies of the Software, and to permit persons to whom the Software is 176 | furnished to do so, subject to the following conditions: 177 | 178 | The above copyright notice and this permission notice shall be included in 179 | all copies or substantial portions of the Software. 180 | 181 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 182 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 183 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 184 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 185 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 186 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 187 | THE SOFTWARE. 188 | ``` 189 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-open-native-settings", 3 | "version": "1.5.5", 4 | "description": "Native settings opener for Cordova", 5 | "cordova": { 6 | "id": "cordova-open-native-settings", 7 | "platforms": [ 8 | "android", 9 | "ios" 10 | ] 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/guyromb/Cordova-open-native-settings" 15 | }, 16 | "keywords": [ 17 | "native-settings", 18 | "ecosystem:cordova", 19 | "cordova-android", 20 | "cordova-ios" 21 | ], 22 | "engines": { 23 | "cordovaDependencies": { 24 | "1.5.0": { 25 | "cordova": ">4.0.0" 26 | } 27 | } 28 | }, 29 | "author": "Guy Rombaut ", 30 | "contributors": [ 31 | { 32 | "name": "Guy Rombaut", 33 | "email": "admin@gsrweb.net", 34 | "url": "http://gsrweb.net", 35 | "username": "guyromb" 36 | }, 37 | { 38 | "name": "unknown", 39 | "username": "deefactorial" 40 | }, 41 | { 42 | "name": "unknown", 43 | "username": "selahssea" 44 | }, 45 | { 46 | "name": "unknown", 47 | "username": "asmund1" 48 | }, 49 | { 50 | "name": "unknown", 51 | "username": "perlish" 52 | }, 53 | { 54 | "name": "unknown", 55 | "username": "emcniece" 56 | } 57 | ], 58 | "license": "MIT", 59 | "bugs": { 60 | "url": "https://github.com/guyromb/Cordova-open-native-settings/issues" 61 | }, 62 | "homepage": "https://github.com/guyromb/Cordova-open-native-settings#readme" 63 | } 64 | -------------------------------------------------------------------------------- /plugin.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | Native settings 7 | Native settings opener for Cordova 4.0 8 | MIT 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 | -------------------------------------------------------------------------------- /src/android/NativeSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PhoneGap is available under *either* the terms of the modified BSD license *or* the 3 | * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text. 4 | * 5 | * Copyright (c) 2005-2010, Nitobi Software Inc. 6 | * Copyright (c) 2011, IBM Corporation 7 | */ 8 | 9 | package com.phonegap.plugins.nativesettings; 10 | 11 | import org.json.JSONArray; 12 | import org.json.JSONException; 13 | 14 | import android.content.Intent; 15 | import android.content.Context; 16 | import android.net.Uri; 17 | 18 | import android.provider.Settings; 19 | 20 | import android.os.Build; 21 | 22 | import org.apache.cordova.CallbackContext; 23 | import org.apache.cordova.CordovaPlugin; 24 | import org.apache.cordova.PluginResult; 25 | 26 | public class NativeSettings extends CordovaPlugin { 27 | 28 | @Override 29 | public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { 30 | Context context=this.cordova.getActivity().getApplicationContext(); 31 | PluginResult.Status status = PluginResult.Status.OK; 32 | Uri packageUri = Uri.parse("package:" + this.cordova.getActivity().getPackageName()); 33 | String result = ""; 34 | 35 | //Information on settings can be found here: 36 | //http://developer.android.com/reference/android/provider/Settings.html 37 | 38 | action = args.getString(0); 39 | Intent intent = null; 40 | 41 | if (action.equals("accessibility")) { 42 | intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS); 43 | } else if (action.equals("account")) { 44 | intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT); 45 | } else if (action.equals("airplane_mode")) { 46 | intent = new Intent(android.provider.Settings.ACTION_AIRPLANE_MODE_SETTINGS); 47 | } else if (action.equals("apn")) { 48 | intent = new Intent(android.provider.Settings.ACTION_APN_SETTINGS); 49 | } else if (action.equals("application_details")) { 50 | intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageUri); 51 | } else if (action.equals("application_development")) { 52 | intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); 53 | } else if (action.equals("application")) { 54 | intent = new Intent(android.provider.Settings.ACTION_APPLICATION_SETTINGS); 55 | } 56 | //else if (action.equals("battery_saver")) { 57 | // intent = new Intent(android.provider.Settings.ACTION_BATTERY_SAVER_SETTINGS); 58 | //} 59 | else if (action.equals("battery_optimization")) { 60 | intent = new Intent(android.provider.Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS); 61 | } else if (action.equals("biometric")) { 62 | 63 | intent = new Intent(); 64 | // Uncomment the below code when Cordova supports Android 30 / R 65 | /*if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){ 66 | intent = new Intent(android.provider.Settings.ACTION_BIOMETRIC_ENROLL); 67 | } else */ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { 68 | intent = new Intent(android.provider.Settings.ACTION_FINGERPRINT_ENROLL); 69 | } else { 70 | // Atleast open the settings landing page 71 | intent = new Intent(android.provider.Settings.ACTION_SETTINGS); 72 | } 73 | } else if (action.equals("bluetooth")) { 74 | intent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS); 75 | } else if (action.equals("captioning")) { 76 | intent = new Intent(android.provider.Settings.ACTION_CAPTIONING_SETTINGS); 77 | } else if (action.equals("cast")) { 78 | intent = new Intent(android.provider.Settings.ACTION_CAST_SETTINGS); 79 | } else if (action.equals("data_roaming")) { 80 | intent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS); 81 | } else if (action.equals("date")) { 82 | intent = new Intent(android.provider.Settings.ACTION_DATE_SETTINGS); 83 | } else if (action.equals("about")) { 84 | intent = new Intent(android.provider.Settings.ACTION_DEVICE_INFO_SETTINGS); 85 | } else if (action.equals("display")) { 86 | intent = new Intent(android.provider.Settings.ACTION_DISPLAY_SETTINGS); 87 | } else if (action.equals("dream")) { 88 | intent = new Intent(android.provider.Settings.ACTION_DREAM_SETTINGS); 89 | } else if (action.equals("home")) { 90 | intent = new Intent(android.provider.Settings.ACTION_HOME_SETTINGS); 91 | } else if (action.equals("keyboard")) { 92 | intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS); 93 | } else if (action.equals("keyboard_subtype")) { 94 | intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); 95 | } else if (action.equals("storage")) { 96 | intent = new Intent(android.provider.Settings.ACTION_INTERNAL_STORAGE_SETTINGS); 97 | } else if (action.equals("locale")) { 98 | intent = new Intent(android.provider.Settings.ACTION_LOCALE_SETTINGS); 99 | } else if (action.equals("location")) { 100 | intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); 101 | } else if (action.equals("manage_all_applications")) { 102 | intent = new Intent(android.provider.Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS); 103 | } else if (action.equals("manage_applications")) { 104 | intent = new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); 105 | } else if (action.equals("memory_card")) { 106 | intent = new Intent(android.provider.Settings.ACTION_MEMORY_CARD_SETTINGS); 107 | } else if (action.equals("network")) { 108 | intent = new Intent(android.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS); 109 | } else if (action.equals("nfcsharing")) { 110 | intent = new Intent(android.provider.Settings.ACTION_NFCSHARING_SETTINGS); 111 | } else if (action.equals("nfc_payment")) { 112 | intent = new Intent(android.provider.Settings.ACTION_NFC_PAYMENT_SETTINGS); 113 | } else if (action.equals("nfc_settings")) { 114 | intent = new Intent(android.provider.Settings.ACTION_NFC_SETTINGS); 115 | } else if (action.equals("notification_id")) { 116 | // from: https://stackoverflow.com/questions/32366649/any-way-to-link-to-the-android-notification-settings-for-my-app 117 | intent = new Intent(); 118 | if(android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1){ 119 | intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS"); 120 | intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName()); 121 | }else if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ 122 | intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS"); 123 | intent.putExtra("app_package", context.getPackageName()); 124 | intent.putExtra("app_uid", context.getApplicationInfo().uid); 125 | }else { 126 | intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); 127 | intent.addCategory(Intent.CATEGORY_DEFAULT); 128 | intent.setData(Uri.parse("package:" + context.getPackageName())); 129 | } 130 | } 131 | //else if (action.equals("notification_listner")) { 132 | // intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS); 133 | //} 134 | else if (action.equals("print")) { 135 | intent = new Intent(android.provider.Settings.ACTION_PRINT_SETTINGS); 136 | } else if (action.equals("privacy")) { 137 | intent = new Intent(android.provider.Settings.ACTION_PRIVACY_SETTINGS); 138 | } else if (action.equals("quick_launch")) { 139 | intent = new Intent(android.provider.Settings.ACTION_QUICK_LAUNCH_SETTINGS); 140 | } else if (action.equals("search")) { 141 | intent = new Intent(android.provider.Settings.ACTION_SEARCH_SETTINGS); 142 | } else if (action.equals("security")) { 143 | intent = new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS); 144 | } else if (action.equals("settings")) { 145 | intent = new Intent(android.provider.Settings.ACTION_SETTINGS); 146 | } else if (action.equals("show_regulatory_info")) { 147 | intent = new Intent(android.provider.Settings.ACTION_SHOW_REGULATORY_INFO); 148 | } else if (action.equals("sound")) { 149 | intent = new Intent(android.provider.Settings.ACTION_SOUND_SETTINGS); 150 | } else if (action.equals("store")) { 151 | intent = new Intent(Intent.ACTION_VIEW, 152 | Uri.parse("market://details?id=" + this.cordova.getActivity().getPackageName())); 153 | } else if (action.equals("sync")) { 154 | intent = new Intent(android.provider.Settings.ACTION_SYNC_SETTINGS); 155 | } else if (action.equals("usage")) { 156 | intent = new Intent(android.provider.Settings.ACTION_USAGE_ACCESS_SETTINGS); 157 | } else if (action.equals("user_dictionary")) { 158 | intent = new Intent(android.provider.Settings.ACTION_USER_DICTIONARY_SETTINGS); 159 | } else if (action.equals("voice_input")) { 160 | intent = new Intent(android.provider.Settings.ACTION_VOICE_INPUT_SETTINGS); 161 | } else if (action.equals("wifi_ip")) { 162 | intent = new Intent(android.provider.Settings.ACTION_WIFI_IP_SETTINGS); 163 | } else if (action.equals("wifi")) { 164 | intent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS); 165 | } else if (action.equals("wireless")) { 166 | intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS); 167 | } else { 168 | status = PluginResult.Status.INVALID_ACTION; 169 | callbackContext.sendPluginResult(new PluginResult(status, result)); 170 | return false; 171 | } 172 | 173 | if(args.length() > 1 && args.getBoolean(1)) { 174 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 175 | } 176 | this.cordova.getActivity().startActivity(intent); 177 | 178 | callbackContext.sendPluginResult(new PluginResult(status, result)); 179 | return true; 180 | } 181 | } 182 | 183 | -------------------------------------------------------------------------------- /src/ios/NativeSettings.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface NativeSettings : CDVPlugin 5 | 6 | #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) 7 | 8 | - (void)open:(CDVInvokedUrlCommand*)command; 9 | @end 10 | -------------------------------------------------------------------------------- /src/ios/NativeSettings.m: -------------------------------------------------------------------------------- 1 | #import "NativeSettings.h" 2 | 3 | @implementation NativeSettings 4 | 5 | - (BOOL)do_open:(NSString *)pref { 6 | if ([[UIApplication sharedApplication] openURL:[NSURL URLWithString:pref]]) { 7 | return YES; 8 | } else { 9 | return NO; 10 | } 11 | } 12 | 13 | - (void)open:(CDVInvokedUrlCommand*)command 14 | { 15 | CDVPluginResult* pluginResult = nil; 16 | NSString* key = [command.arguments objectAtIndex:0]; 17 | NSString* prefix = @"App-Prefs:"; 18 | BOOL result = NO; 19 | 20 | if(SYSTEM_VERSION_LESS_THAN(@"11.3")){ 21 | prefix = @"app-settings:"; 22 | } 23 | 24 | 25 | if ([key isEqualToString:@"application_details"]) { 26 | result = [self do_open:UIApplicationOpenSettingsURLString]; 27 | } 28 | else if ([key isEqualToString:@"settings"]) { 29 | result = [self do_open:prefix]; 30 | } 31 | else if ([key isEqualToString:@"about"]) { 32 | result = [self do_open:[prefix stringByAppendingString:@"General&path=About"]]; 33 | } 34 | else if ([key isEqualToString:@"accessibility"]) { 35 | result = [self do_open:[prefix stringByAppendingString:@"General&path=ACCESSIBILITY"]]; 36 | } 37 | else if ([key isEqualToString:@"account"]) { 38 | result = [self do_open:[prefix stringByAppendingString:@"ACCOUNT_SETTINGS"]]; 39 | } 40 | else if ([key isEqualToString:@"autolock"]) { 41 | result = [self do_open:[prefix stringByAppendingString:@"DISPLAY&path=AUTOLOCK"]]; 42 | } 43 | else if ([key isEqualToString:@"display"]) { 44 | result = [self do_open:[prefix stringByAppendingString:@"Brightness"]]; 45 | } 46 | else if ([key isEqualToString:@"bluetooth"]) { 47 | result = [self do_open:[prefix stringByAppendingString:@"Bluetooth"]]; 48 | } 49 | else if ([key isEqualToString:@"castle"]) { 50 | result = [self do_open:[prefix stringByAppendingString:@"CASTLE"]]; 51 | } 52 | else if ([key isEqualToString:@"cellular_usage"]) { 53 | result = [self do_open:[prefix stringByAppendingString:@"General&path=USAGE/CELLULAR_USAGE"]]; 54 | } 55 | else if ([key isEqualToString:@"configuration_list"]) { 56 | result = [self do_open:[prefix stringByAppendingString:@"General&path=ManagedConfigurationList"]]; 57 | } 58 | else if ([key isEqualToString:@"date"]) { 59 | result = [self do_open:[prefix stringByAppendingString:@"General&path=DATE_AND_TIME"]]; 60 | } 61 | else if ([key isEqualToString:@"facetime"]) { 62 | result = [self do_open:[prefix stringByAppendingString:@"FACETIME"]]; 63 | } 64 | else if ([key isEqualToString:@"settings"]) { 65 | result = [self do_open:[prefix stringByAppendingString:@"General"]]; 66 | } 67 | else if ([key isEqualToString:@"tethering"]) { 68 | result = [self do_open:[prefix stringByAppendingString:@"INTERNET_TETHERING"]]; 69 | } 70 | else if ([key isEqualToString:@"music"]) { 71 | result = [self do_open:[prefix stringByAppendingString:@"MUSIC"]]; 72 | } 73 | else if ([key isEqualToString:@"music_equalizer"]) { 74 | result = [self do_open:[prefix stringByAppendingString:@"MUSIC&path=EQ"]]; 75 | } 76 | else if ([key isEqualToString:@"music_volume"]) { 77 | result = [self do_open:[prefix stringByAppendingString:@"MUSIC&path=VolumeLimit"]]; 78 | } 79 | else if ([key isEqualToString:@"keyboard"]) { 80 | result = [self do_open:[prefix stringByAppendingString:@"General&path=Keyboard"]]; 81 | } 82 | else if ([key isEqualToString:@"locale"]) { 83 | result = [self do_open:[prefix stringByAppendingString:@"General&path=INTERNATIONAL"]]; 84 | } 85 | else if ([key isEqualToString:@"location"]) { 86 | result = [self do_open:[prefix stringByAppendingString:@"LOCATION_SERVICES"]]; 87 | } 88 | else if ([key isEqualToString:@"locations"]) { 89 | result = [self do_open:[prefix stringByAppendingString:@"Privacy&path=LOCATION"]]; 90 | } 91 | else if ([key isEqualToString:@"tracking"]) { 92 | result = [self do_open:[prefix stringByAppendingString:@"Privacy&path=USER_TRACKING"]]; 93 | } 94 | else if ([key isEqualToString:@"network"]) { 95 | result = [self do_open:[prefix stringByAppendingString:@"General&path=Network"]]; 96 | } 97 | else if ([key isEqualToString:@"nike_ipod"]) { 98 | result = [self do_open:[prefix stringByAppendingString:@"NIKE_PLUS_IPOD"]]; 99 | } 100 | else if ([key isEqualToString:@"notes"]) { 101 | result = [self do_open:[prefix stringByAppendingString:@"NOTES"]]; 102 | } 103 | else if ([key isEqualToString:@"notification_id"]) { 104 | result = [self do_open:[prefix stringByAppendingString:@"NOTIFICATIONS_ID"]]; 105 | } 106 | else if ([key isEqualToString:@"passbook"]) { 107 | result = [self do_open:[prefix stringByAppendingString:@"PASSBOOK"]]; 108 | } 109 | else if ([key isEqualToString:@"phone"]) { 110 | result = [self do_open:[prefix stringByAppendingString:@"Phone"]]; 111 | } 112 | else if ([key isEqualToString:@"photos"]) { 113 | result = [self do_open:[prefix stringByAppendingString:@"Photos"]]; 114 | } 115 | else if ([key isEqualToString:@"reset"]) { 116 | result = [self do_open:[prefix stringByAppendingString:@"General&path=Reset"]]; 117 | } 118 | else if ([key isEqualToString:@"ringtone"]) { 119 | result = [self do_open:[prefix stringByAppendingString:@"Sounds&path=Ringtone"]]; 120 | } 121 | else if ([key isEqualToString:@"browser"]) { 122 | result = [self do_open:[prefix stringByAppendingString:@"Safari"]]; 123 | } 124 | else if ([key isEqualToString:@"search"]) { 125 | result = [self do_open:[prefix stringByAppendingString:@"SIRI"]]; 126 | } 127 | else if ([key isEqualToString:@"sound"]) { 128 | result = [self do_open:[prefix stringByAppendingString:@"Sounds"]]; 129 | } 130 | else if ([key isEqualToString:@"software_update"]) { 131 | result = [self do_open:[prefix stringByAppendingString:@"General&path=SOFTWARE_UPDATE_LINK"]]; 132 | } 133 | else if ([key isEqualToString:@"storage"]) { 134 | result = [self do_open:[prefix stringByAppendingString:@"CASTLE&path=STORAGE_AND_BACKUP"]]; 135 | } 136 | else if ([key isEqualToString:@"store"]) { 137 | result = [self do_open:[prefix stringByAppendingString:@"STORE"]]; 138 | } 139 | else if ([key isEqualToString:@"usage"]) { 140 | result = [self do_open:[prefix stringByAppendingString:@"General&path=USAGE"]]; 141 | } 142 | else if ([key isEqualToString:@"video"]) { 143 | result = [self do_open:[prefix stringByAppendingString:@"VIDEO"]]; 144 | } 145 | else if ([key isEqualToString:@"vpn"]) { 146 | result = [self do_open:[prefix stringByAppendingString:@"General&path=Network/VPN"]]; 147 | } 148 | else if ([key isEqualToString:@"wallpaper"]) { 149 | result = [self do_open:[prefix stringByAppendingString:@"Wallpaper"]]; 150 | } 151 | else if ([key isEqualToString:@"wifi"]) { 152 | result = [self do_open:[prefix stringByAppendingString:@"WIFI"]]; 153 | } 154 | else if ([key isEqualToString:@"touch"]) { 155 | result = [self do_open:[prefix stringByAppendingString:@"TOUCHID_PASSCODE"]]; 156 | } 157 | else if ([key isEqualToString:@"battery"]) { 158 | result = [self do_open:[prefix stringByAppendingString:@"BATTERY_USAGE"]]; 159 | } 160 | else if ([key isEqualToString:@"privacy"]) { 161 | result = [self do_open:[prefix stringByAppendingString:@"Privacy"]]; 162 | } 163 | else if ([key isEqualToString:@"do_not_disturb"]) { 164 | result = [self do_open:[prefix stringByAppendingString:@"General&path=DO_NOT_DISTURB"]]; 165 | } 166 | else if ([key isEqualToString:@"keyboards"]) { 167 | result = [self do_open:[prefix stringByAppendingString:@"General&path=Keyboard/KEYBOARDS"]]; 168 | } 169 | else if ([key isEqualToString:@"mobile_data"]) { 170 | result = [self do_open:[prefix stringByAppendingString:@"MOBILE_DATA_SETTINGS_ID"]]; 171 | } 172 | else { 173 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid Action"]; 174 | } 175 | 176 | if (result) { 177 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Opened"]; 178 | } else { 179 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Cannot open"]; 180 | } 181 | 182 | [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 183 | } 184 | 185 | @end 186 | -------------------------------------------------------------------------------- /www/settings.js: -------------------------------------------------------------------------------- 1 | var NativeSettings = function() { 2 | }; 3 | 4 | NativeSettings.open = function(setting, onsucess, onfail) { 5 | var settings = (typeof setting === 'string' || setting instanceof String) ? [setting] : setting; 6 | cordova.exec(onsucess, onfail, "NativeSettings", "open", settings); 7 | }; 8 | 9 | module.exports = NativeSettings; --------------------------------------------------------------------------------