Skip to content

Commit

Permalink
Implemented iOS (#1)
Browse files Browse the repository at this point in the history
* Implement iOS
  • Loading branch information
dennisameling authored Mar 17, 2021
1 parent 085db68 commit 2edf038
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 304 deletions.
54 changes: 4 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,55 +128,9 @@ Opens the specified option in android.

#### IOSSettings

| Members | Value | Description |
| ------------------------ | ---------------------------------- | -------------------------------------------------------------------------------------- |
| **`About`** | <code>'about'</code> | Settings &gt; General &gt; About |
| **`Accessibility`** | <code>'accessibility'</code> | Settings &gt; General &gt; Accessibility |
| **`Account`** | <code>'account'</code> | Settings &gt; Your name |
| **`AirplaneMode`** | <code>'airplane_mode'</code> | Settings &gt; Airplane Mode |
| **`ApplicationDetails`** | <code>'application_details'</code> | Settings |
| **`AutoLock`** | <code>'autolock'</code> | Settings &gt; General &gt; Auto-Lock (before iOS 10) |
| **`Battery`** | <code>'battery'</code> | Settings &gt; Battery |
| **`Bluetooth`** | <code>'bluetooth'</code> | Settings &gt; General &gt; Bluetooth (&lt; iOS 9) Settings &gt; Bluetooth (&gt; iOS 9) |
| **`Browser`** | <code>'browser'</code> | Settings &gt; Safari |
| **`Castle`** | <code>'castle'</code> | Settings &gt; iCloud |
| **`Cellularusage`** | <code>'cellular_usage'</code> | Settings &gt; General &gt; Cellular Usage |
| **`ConfigurationList`** | <code>'configuration_list'</code> | Settings &gt; General &gt; Profile |
| **`Date`** | <code>'date'</code> | Settings &gt; General &gt; Date & Time |
| **`Display`** | <code>'display'</code> | Settings &gt; Display & Brightness |
| **`DoNotDisturb`** | <code>'do_not_disturb'</code> | Settings &gt; Do Not Disturb |
| **`Facetime`** | <code>'facetime'</code> | Settings &gt; Facetime |
| **`Keyboard`** | <code>'keyboard'</code> | Settings &gt; General &gt; Keyboard |
| **`Keyboards`** | <code>'keyboards'</code> | Settings &gt; General &gt; Keyboard &gt; Keyboards |
| **`Locale`** | <code>'locale'</code> | Settings &gt; General &gt; Language & Region |
| **`Location`** | <code>'location'</code> | Settings &gt; Location Services (in older versions of iOS) |
| **`Locations`** | <code>'locations'</code> | Settings &gt; Privacy &gt; Location Services (in newer versions of iOS) |
| **`MobileData`** | <code>'mobile_data'</code> | Settings &gt; Mobile Data (after iOS 10) |
| **`Music`** | <code>'music'</code> | Settings &gt; iTunes |
| **`MusicEqualizer`** | <code>'music_equalizer'</code> | Settings &gt; Music &gt; EQ |
| **`MusicVolume`** | <code>'music_volume'</code> | Settings &gt; Music &gt; Volume Limit |
| **`Network`** | <code>'network'</code> | Settings &gt; General &gt; Network |
| **`NikeIpod`** | <code>'nike_ipod'</code> | Settings &gt; Nike + iPod |
| **`Notes`** | <code>'notes'</code> | Settings &gt; Notes |
| **`Passbook`** | <code>'passbook'</code> | Settings &gt; Passbook & Apple Pay |
| **`Phone`** | <code>'phone'</code> | Settings &gt; Phone |
| **`Photos`** | <code>'photos'</code> | Settings &gt; Photo & Camera |
| **`Privacy`** | <code>'privacy'</code> | Settings &gt; Privacy |
| **`Reset`** | <code>'reset'</code> | Settings &gt; General &gt; Reset |
| **`Ringtone`** | <code>'ringtone'</code> | Settings &gt; Sounds &gt; Ringtone |
| **`Search`** | <code>'search'</code> | Settings &gt; General &gt; Assistant (&lt; iOS 10) Settings &gt; Siri (&gt; iOS 10) |
| **`Settings`** | <code>'settings'</code> | Settings &gt; General |
| **`Sound`** | <code>'sound'</code> | Settings &gt; Sounds |
| **`SoftwareUpdate`** | <code>'software_update'</code> | Settings &gt; General &gt; Software Update |
| **`Storage`** | <code>'storage'</code> | Settings &gt; iCloud &gt; Storage & Backup |
| **`Store`** | <code>'store'</code> | Settings &gt; iTunes & App Store |
| **`Tethering`** | <code>'tethering'</code> | Settings &gt; Personal Hotspot |
| **`Touch`** | <code>'touch'</code> | Settings &gt; Touch ID & Passcode |
| **`Twitter`** | <code>'twitter'</code> | Settings &gt; Twitter |
| **`Usage`** | <code>'usage'</code> | Settings &gt; General &gt; Storage & iCloud Usage |
| **`Video`** | <code>'video'</code> | Settings &gt; Video |
| **`VPN`** | <code>'vpn'</code> | Settings &gt; General &gt; VPN |
| **`Wallpaper`** | <code>'wallpaper'</code> | Settings &gt; Wallpaper |
| **`Wifi`** | <code>'wifi'</code> | Settings &gt; WIFI |
| Members | Value | Description |
| ------------- | ---------------------- | ---------------------------------------- |
| **`General`** | <code>'general'</code> | Opens iOS general settings screen. |
| **`App`** | <code>'app'</code> | Opens your app-specific settings screen. |

</docgen-api>
4 changes: 0 additions & 4 deletions ios/Plugin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
03FC29A292ACC40490383A1F /* Pods_Plugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B2A61DA5A1F2DD4F959604D /* Pods_Plugin.framework */; };
20C0B05DCFC8E3958A738AF2 /* Pods_PluginTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6753A823D3815DB436415E3 /* Pods_PluginTests.framework */; };
2F98D68224C9AAE500613A4C /* NativeSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F98D68124C9AAE400613A4C /* NativeSettings.swift */; };
50ADFF92201F53D600D50D53 /* Plugin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFF88201F53D600D50D53 /* Plugin.framework */; };
50ADFF97201F53D600D50D53 /* NativeSettingsPluginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFF96201F53D600D50D53 /* NativeSettingsPluginTests.swift */; };
50ADFF99201F53D600D50D53 /* NativeSettingsPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ADFF8B201F53D600D50D53 /* NativeSettingsPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -29,7 +28,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
2F98D68124C9AAE400613A4C /* NativeSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativeSettings.swift; sourceTree = "<group>"; };
3B2A61DA5A1F2DD4F959604D /* Pods_Plugin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Plugin.framework; sourceTree = BUILT_PRODUCTS_DIR; };
50ADFF88201F53D600D50D53 /* Plugin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Plugin.framework; sourceTree = BUILT_PRODUCTS_DIR; };
50ADFF8B201F53D600D50D53 /* NativeSettingsPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NativeSettingsPlugin.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -93,7 +91,6 @@
isa = PBXGroup;
children = (
50E1A94720377CB70090CE1A /* NativeSettingsPlugin.swift */,
2F98D68124C9AAE400613A4C /* NativeSettings.swift */,
50ADFF8B201F53D600D50D53 /* NativeSettingsPlugin.h */,
50ADFFA72020EE4F00D50D53 /* NativeSettingsPlugin.m */,
50ADFF8C201F53D600D50D53 /* Info.plist */,
Expand Down Expand Up @@ -307,7 +304,6 @@
buildActionMask = 2147483647;
files = (
50E1A94820377CB70090CE1A /* NativeSettingsPlugin.swift in Sources */,
2F98D68224C9AAE500613A4C /* NativeSettings.swift in Sources */,
50ADFFA82020EE4F00D50D53 /* NativeSettingsPlugin.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
10 changes: 10 additions & 0 deletions ios/Plugin.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions ios/Plugin/NativeSettings.swift

This file was deleted.

2 changes: 1 addition & 1 deletion ios/Plugin/NativeSettingsPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
// Define the plugin using the CAP_PLUGIN Macro, and
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
CAP_PLUGIN(NativeSettingsPlugin, "NativeSettings",
CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(openIOS, CAPPluginReturnPromise);
)
27 changes: 21 additions & 6 deletions ios/Plugin/NativeSettingsPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@ import Capacitor
*/
@objc(NativeSettingsPlugin)
public class NativeSettingsPlugin: CAPPlugin {
private let implementation = NativeSettings()
@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") {
settingsUrl = URL(string: UIApplication.openSettingsURLString)
} else {
call.reject("Requested setting \"" + value + "\" is not available on iOS.");
return
}

@objc func echo(_ call: CAPPluginCall) {
let value = call.getString("value") ?? ""
call.resolve([
"value": implementation.echo(value)
])
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
call.resolve([
"status": success
])
})
} else {
call.reject("Cannot open settings")
}
}
}
Loading

0 comments on commit 2edf038

Please sign in to comment.