Skip to content

Commit

Permalink
Merge branch 'main' into migrateSPM, fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiomartino committed Jan 8, 2025
2 parents c46dbf8 + d37a0dc commit 7afb9e7
Show file tree
Hide file tree
Showing 8 changed files with 920 additions and 523 deletions.
67 changes: 34 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,38 +202,39 @@ might break in future iOS versions or have your app rejected in the App Store.

#### IOSSettings

| Members | Value | Description |
| ------------------------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **`About`** | <code>'about'</code> | Settings &gt; About page |
| **`App`** | <code>'app'</code> | Opens your app-specific settings screen. Note that this is the only officially supported settings screen by Apple. |
| **`AutoLock`** | <code>'autoLock'</code> | Used to set if and when the screen should be automatically locked. |
| **`Bluetooth`** | <code>'bluetooth'</code> | Bluetooth settings. Allows the users to enable/disable bluetooth and to search for devices. |
| **`DateTime`** | <code>'dateTime'</code> | Date and time settings. |
| **`FaceTime`** | <code>'facetime'</code> | FaceTime settings. |
| **`General`** | <code>'general'</code> | Opens iOS general settings screen. |
| **`Keyboard`** | <code>'keyboard'</code> | Keyboard settings. |
| **`ICloud`** | <code>'iCloud'</code> | iCloud settings. |
| **`ICloudStorageBackup`** | <code>'iCloudStorageBackup'</code> | iCloud Storage and Backup settings. |
| **`International`** | <code>'international'</code> | Language and region settings. |
| **`LocationServices`** | <code>'locationServices'</code> | Show settings to allow configuration of current location sources |
| **`Music`** | <code>'music'</code> | Music settings. |
| **`Notes`** | <code>'notes'</code> | Notes settings. |
| **`Notifications`** | <code>'notifications'</code> | Notifications settings. |
| **`Phone`** | <code>'phone'</code> | Phone settings. |
| **`Photos`** | <code>'photos'</code> | Photos settings. |
| **`ManagedConfigurationList`** | <code>'managedConfigurationList'</code> | Allows the user to manage configuration profiles that are installed on the phone. |
| **`Reset`** | <code>'reset'</code> | Screen where the user can reset the phone to factory settings. |
| **`Ringtone`** | <code>'ringtone'</code> | Ringtone settings. |
| **`Sounds`** | <code>'sounds'</code> | Used to set phone volume, vibration settings, etc. |
| **`SoftwareUpdate`** | <code>'softwareUpdate'</code> | Software update screen. |
| **`Store`** | <code>'store'</code> | Store settings. |
| **`Tracking`** | <code>'tracking'</code> | Tracking settings. |
| **`Wallpaper`** | <code>'wallpaper'</code> | Wallpaper settings. |
| **`WiFi`** | <code>'wifi'</code> | WiFi settings. |
| **`Tethering`** | <code>'tethering'</code> | Tethering settings (used to create a hotspot with mobile data). |
| **`DoNotDisturb`** | <code>'doNotDisturb'</code> | Do Not Disturb settings. |
| **`TouchIdPasscode`** | <code>'touchIdPasscode'</code> | Touch id passcode settings. |
| **`ScreenTime`** | <code>'screenTime'</code> | Screen Time settings. |
| **`Accessibility`** | <code>'accessibility'</code> | Accessibility settings. |
| Members | Value | Description |
| ------------------------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| **`About`** | <code>'about'</code> | Settings &gt; About page |
| **`App`** | <code>'app'</code> | Opens your app-specific settings screen. Note that this is the only officially supported settings screen by Apple. |
| **`AppNotification`** | <code>'appNotification'</code> | Opens app-specific notification settings screen for iOS 15.4+; opens general app-specific settings for earlier versions." |
| **`AutoLock`** | <code>'autoLock'</code> | Used to set if and when the screen should be automatically locked. |
| **`Bluetooth`** | <code>'bluetooth'</code> | Bluetooth settings. Allows the users to enable/disable bluetooth and to search for devices. |
| **`DateTime`** | <code>'dateTime'</code> | Date and time settings. |
| **`FaceTime`** | <code>'facetime'</code> | FaceTime settings. |
| **`General`** | <code>'general'</code> | Opens iOS general settings screen. |
| **`Keyboard`** | <code>'keyboard'</code> | Keyboard settings. |
| **`ICloud`** | <code>'iCloud'</code> | iCloud settings. |
| **`ICloudStorageBackup`** | <code>'iCloudStorageBackup'</code> | iCloud Storage and Backup settings. |
| **`International`** | <code>'international'</code> | Language and region settings. |
| **`LocationServices`** | <code>'locationServices'</code> | Show settings to allow configuration of current location sources |
| **`Music`** | <code>'music'</code> | Music settings. |
| **`Notes`** | <code>'notes'</code> | Notes settings. |
| **`Notifications`** | <code>'notifications'</code> | Notifications settings. |
| **`Phone`** | <code>'phone'</code> | Phone settings. |
| **`Photos`** | <code>'photos'</code> | Photos settings. |
| **`ManagedConfigurationList`** | <code>'managedConfigurationList'</code> | Allows the user to manage configuration profiles that are installed on the phone. |
| **`Reset`** | <code>'reset'</code> | Screen where the user can reset the phone to factory settings. |
| **`Ringtone`** | <code>'ringtone'</code> | Ringtone settings. |
| **`Sounds`** | <code>'sounds'</code> | Used to set phone volume, vibration settings, etc. |
| **`SoftwareUpdate`** | <code>'softwareUpdate'</code> | Software update screen. |
| **`Store`** | <code>'store'</code> | Store settings. |
| **`Tracking`** | <code>'tracking'</code> | Tracking settings. |
| **`Wallpaper`** | <code>'wallpaper'</code> | Wallpaper settings. |
| **`WiFi`** | <code>'wifi'</code> | WiFi settings. |
| **`Tethering`** | <code>'tethering'</code> | Tethering settings (used to create a hotspot with mobile data). |
| **`DoNotDisturb`** | <code>'doNotDisturb'</code> | Do Not Disturb settings. |
| **`TouchIdPasscode`** | <code>'touchIdPasscode'</code> | Touch id passcode settings. |
| **`ScreenTime`** | <code>'screenTime'</code> | Screen Time settings. |
| **`Accessibility`** | <code>'accessibility'</code> | Accessibility settings. |

</docgen-api>
33 changes: 21 additions & 12 deletions ios/Sources/NativeSettingsPlugin/NativeSettingsPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,37 @@ public class NativeSettingsPlugin: CAPPlugin, CAPBridgedPlugin {
let option = call.getString("option") ?? ""
handleOpen(call: call, option: option)
}

@objc private func handleOpen(call: CAPPluginCall, option: String) {
var settingsUrl: URL!
var settingsUrl: URL?

if settingsPaths[option] != nil {
settingsUrl = URL(string: settingsPaths[option]!)
if let path = settingsPaths[option], let url = URL(string: path) {
settingsUrl = url
} 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
}

guard let validUrl = settingsUrl, UIApplication.shared.canOpenURL(validUrl) else {
call.reject("Cannot open settings or invalid URL")
return
}

DispatchQueue.main.async {
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
call.resolve([
"status": success
])
})
} else {
call.reject("Cannot open settings")
UIApplication.shared.open(validUrl) { success in
if success {
call.resolve(["status": success])
} else {
call.reject("Failed to open settings")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ import XCTest
@testable import NativeSettingsPlugin

class NativeSettingsTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}

func testEcho() {
// This is an example of a functional test case for a plugin.
Expand Down
Loading

0 comments on commit 7afb9e7

Please sign in to comment.