-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS: add new options, fix dependencies, bump version to 0.1.0 (#12)
* Add new iOS options, open settings async * Fix dependencies + lint * Bump Gradle to v7
- Loading branch information
1 parent
5c3658a
commit dd611ab
Showing
7 changed files
with
225 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,59 @@ | ||
import Foundation | ||
import Capacitor | ||
|
||
/** | ||
* Please read the Capacitor iOS Plugin Development Guide | ||
* here: https://capacitorjs.com/docs/plugins/ios | ||
*/ | ||
@objc(NativeSettingsPlugin) | ||
public class NativeSettingsPlugin: CAPPlugin { | ||
@objc func openIOS(_ call: CAPPluginCall) { | ||
let value = call.getString("option") ?? "" | ||
var settingsUrl:URL! | ||
|
||
if (value == "general") { | ||
settingsUrl = URL(string: "App-Prefs:root=General") | ||
} else if (value == "app") { | ||
var settingsUrl: URL! | ||
|
||
let settingsPaths = [ | ||
"about": "App-prefs:General&path=About", | ||
"autoLock": "App-prefs:General&path=AUTOLOCK", | ||
"bluetooth": "App-prefs:Bluetooth", | ||
"dateTime": "App-prefs:General&path=DATE_AND_TIME", | ||
"facetime": "App-prefs:FACETIME", | ||
"general": "App-prefs:General", | ||
"keyboard": "App-prefs:General&path=Keyboard", | ||
"iCloud": "App-prefs:CASTLE", | ||
"iCloudStorageBackup": "App-prefs:CASTLE&path=STORAGE_AND_BACKUP", | ||
"international": "App-prefs:General&path=INTERNATIONAL", | ||
"music": "App-prefs:MUSIC", | ||
"notes": "App-prefs:NOTES", | ||
"notifications": "App-prefs:NOTIFICATIONS_ID", | ||
"phone": "App-prefs:Phone", | ||
"photos": "App-prefs:Photos", | ||
"managedConfigurationList": "App-prefs:General&path=ManagedConfigurationList", | ||
"reset": "App-prefs:General&path=Reset", | ||
"ringtone": "App-prefs:Sounds&path=Ringtone", | ||
"sounds": "App-prefs:Sounds", | ||
"softwareUpdate": "App-prefs:General&path=SOFTWARE_UPDATE_LINK", | ||
"store": "App-prefs:STORE", | ||
"wallpaper": "App-prefs:Wallpaper", | ||
"wifi": "App-prefs:WIFI", | ||
"tethering": "App-prefs:INTERNET_TETHERING", | ||
"doNotDisturb": "App-prefs:DO_NOT_DISTURB" | ||
] | ||
|
||
if settingsPaths[value] != nil { | ||
settingsUrl = URL(string: settingsPaths[value]!) | ||
} else if value == "app" { | ||
settingsUrl = URL(string: UIApplication.openSettingsURLString) | ||
} else { | ||
call.reject("Requested setting \"" + value + "\" is not available on iOS."); | ||
call.reject("Requested setting \"" + value + "\" is not available on iOS.") | ||
return | ||
} | ||
|
||
if UIApplication.shared.canOpenURL(settingsUrl) { | ||
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in | ||
call.resolve([ | ||
"status": success | ||
]) | ||
}) | ||
} else { | ||
call.reject("Cannot open settings") | ||
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") | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters