diff --git a/README.md b/README.md index c590621..13c62ce 100644 --- a/README.md +++ b/README.md @@ -202,38 +202,39 @@ might break in future iOS versions or have your app rejected in the App Store. #### IOSSettings -| Members | Value | Description | -| ------------------------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | -| **`About`** | 'about' | Settings > About page | -| **`App`** | 'app' | Opens your app-specific settings screen. Note that this is the only officially supported settings screen by Apple. | -| **`AutoLock`** | 'autoLock' | Used to set if and when the screen should be automatically locked. | -| **`Bluetooth`** | 'bluetooth' | Bluetooth settings. Allows the users to enable/disable bluetooth and to search for devices. | -| **`DateTime`** | 'dateTime' | Date and time settings. | -| **`FaceTime`** | 'facetime' | FaceTime settings. | -| **`General`** | 'general' | Opens iOS general settings screen. | -| **`Keyboard`** | 'keyboard' | Keyboard settings. | -| **`ICloud`** | 'iCloud' | iCloud settings. | -| **`ICloudStorageBackup`** | 'iCloudStorageBackup' | iCloud Storage and Backup settings. | -| **`International`** | 'international' | Language and region settings. | -| **`LocationServices`** | 'locationServices' | Show settings to allow configuration of current location sources | -| **`Music`** | 'music' | Music settings. | -| **`Notes`** | 'notes' | Notes settings. | -| **`Notifications`** | 'notifications' | Notifications settings. | -| **`Phone`** | 'phone' | Phone settings. | -| **`Photos`** | 'photos' | Photos settings. | -| **`ManagedConfigurationList`** | 'managedConfigurationList' | Allows the user to manage configuration profiles that are installed on the phone. | -| **`Reset`** | 'reset' | Screen where the user can reset the phone to factory settings. | -| **`Ringtone`** | 'ringtone' | Ringtone settings. | -| **`Sounds`** | 'sounds' | Used to set phone volume, vibration settings, etc. | -| **`SoftwareUpdate`** | 'softwareUpdate' | Software update screen. | -| **`Store`** | 'store' | Store settings. | -| **`Tracking`** | 'tracking' | Tracking settings. | -| **`Wallpaper`** | 'wallpaper' | Wallpaper settings. | -| **`WiFi`** | 'wifi' | WiFi settings. | -| **`Tethering`** | 'tethering' | Tethering settings (used to create a hotspot with mobile data). | -| **`DoNotDisturb`** | 'doNotDisturb' | Do Not Disturb settings. | -| **`TouchIdPasscode`** | 'touchIdPasscode' | Touch id passcode settings. | -| **`ScreenTime`** | 'screenTime' | Screen Time settings. | -| **`Accessibility`** | 'accessibility' | Accessibility settings. | +| Members | Value | Description | +| ------------------------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| **`About`** | 'about' | Settings > About page | +| **`App`** | 'app' | Opens your app-specific settings screen. Note that this is the only officially supported settings screen by Apple. | +| **`AppNotification`** | 'appNotification' | Opens app-specific notification settings screen for iOS 15.4+; opens general app-specific settings for earlier versions." | +| **`AutoLock`** | 'autoLock' | Used to set if and when the screen should be automatically locked. | +| **`Bluetooth`** | 'bluetooth' | Bluetooth settings. Allows the users to enable/disable bluetooth and to search for devices. | +| **`DateTime`** | 'dateTime' | Date and time settings. | +| **`FaceTime`** | 'facetime' | FaceTime settings. | +| **`General`** | 'general' | Opens iOS general settings screen. | +| **`Keyboard`** | 'keyboard' | Keyboard settings. | +| **`ICloud`** | 'iCloud' | iCloud settings. | +| **`ICloudStorageBackup`** | 'iCloudStorageBackup' | iCloud Storage and Backup settings. | +| **`International`** | 'international' | Language and region settings. | +| **`LocationServices`** | 'locationServices' | Show settings to allow configuration of current location sources | +| **`Music`** | 'music' | Music settings. | +| **`Notes`** | 'notes' | Notes settings. | +| **`Notifications`** | 'notifications' | Notifications settings. | +| **`Phone`** | 'phone' | Phone settings. | +| **`Photos`** | 'photos' | Photos settings. | +| **`ManagedConfigurationList`** | 'managedConfigurationList' | Allows the user to manage configuration profiles that are installed on the phone. | +| **`Reset`** | 'reset' | Screen where the user can reset the phone to factory settings. | +| **`Ringtone`** | 'ringtone' | Ringtone settings. | +| **`Sounds`** | 'sounds' | Used to set phone volume, vibration settings, etc. | +| **`SoftwareUpdate`** | 'softwareUpdate' | Software update screen. | +| **`Store`** | 'store' | Store settings. | +| **`Tracking`** | 'tracking' | Tracking settings. | +| **`Wallpaper`** | 'wallpaper' | Wallpaper settings. | +| **`WiFi`** | 'wifi' | WiFi settings. | +| **`Tethering`** | 'tethering' | Tethering settings (used to create a hotspot with mobile data). | +| **`DoNotDisturb`** | 'doNotDisturb' | Do Not Disturb settings. | +| **`TouchIdPasscode`** | 'touchIdPasscode' | Touch id passcode settings. | +| **`ScreenTime`** | 'screenTime' | Screen Time settings. | +| **`Accessibility`** | 'accessibility' | Accessibility settings. | diff --git a/ios/Plugin/NativeSettingsPlugin.swift b/ios/Plugin/NativeSettingsPlugin.swift index 72115c7..2af12e4 100644 --- a/ios/Plugin/NativeSettingsPlugin.swift +++ b/ios/Plugin/NativeSettingsPlugin.swift @@ -53,20 +53,29 @@ public class NativeSettingsPlugin: CAPPlugin { settingsUrl = URL(string: settingsPaths[option]!) } else if option == "app" { settingsUrl = URL(string: UIApplication.openSettingsURLString) + } else if option == "appNotification" { + if #available(iOS 16.0, *) { + settingsUrl = URL(string: UIApplication.openNotificationSettingsURLString) + } else { + settingsUrl = URL(string: UIApplication.openSettingsURLString) + } } else { call.reject("Requested setting \"" + option + "\" is not available on iOS.") return } DispatchQueue.main.async { - if UIApplication.shared.canOpenURL(settingsUrl) { - UIApplication.shared.open(settingsUrl, completionHandler: { (success) in - call.resolve([ - "status": success - ]) - }) - } else { + guard UIApplication.shared.canOpenURL(settingsUrl) else { call.reject("Cannot open settings") + return + } + + UIApplication.shared.open(settingsUrl) { success in + if success { + call.resolve(["status": success]) + } else { + call.reject("Failed to open settings") + } } } } diff --git a/src/definitions.ts b/src/definitions.ts index 5491b92..35f562e 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -279,6 +279,11 @@ export enum IOSSettings { */ App = 'app', + /** + * Opens app-specific notification settings screen for iOS 15.4+; opens general app-specific settings for earlier versions." + */ + AppNotification = 'appNotification', + /** * Used to set if and when the screen should be automatically locked. */