@capacitor/ios 9.0.0-alpha.5 → 9.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Capacitor.podspec +10 -4
- package/CapacitorCordova.podspec +6 -5
- package/{Capacitor → Sources}/Capacitor/CAPApplicationDelegateProxy.swift +1 -1
- package/{Capacitor → Sources}/Capacitor/CAPBridgeProtocol.swift +0 -57
- package/{Capacitor → Sources}/Capacitor/CAPInstanceConfiguration.swift +0 -15
- package/{Capacitor → Sources}/Capacitor/CAPNotifications.swift +8 -36
- package/Sources/Capacitor/CAPPlugin+Bridge.swift +108 -0
- package/{Capacitor → Sources}/Capacitor/CAPPluginCall.swift +0 -13
- package/Sources/Capacitor/CAPSceneDelegateProxy.swift +204 -0
- package/{Capacitor → Sources}/Capacitor/CapacitorBridge.swift +37 -78
- package/Sources/Capacitor/CapacitorObjCExports.swift +11 -0
- package/{Capacitor → Sources}/Capacitor/JS.swift +9 -20
- package/{Capacitor → Sources}/Capacitor/JSExport.swift +6 -2
- package/Sources/Capacitor/JSResultSerialization.swift +56 -0
- package/{Capacitor → Sources}/Capacitor/NotificationRouter.swift +9 -0
- package/Sources/Capacitor/PluginCallResult.swift +17 -0
- package/{Capacitor → Sources}/Capacitor/Plugins/CapacitorUrlRequest.swift +2 -11
- package/{Capacitor → Sources}/Capacitor/WebViewAssetHandler.swift +17 -5
- package/{Capacitor → Sources}/Capacitor/WebViewDelegationHandler.swift +7 -1
- package/{Capacitor → Sources}/Capacitor/assets/native-bridge.js +0 -6
- package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/CapacitorCordova}/Plugin.swift +5 -0
- package/{Capacitor/Capacitor → Sources/CapacitorObjC}/CAPInstanceConfiguration.m +9 -1
- package/{Capacitor/Capacitor → Sources/CapacitorObjC}/CAPInstanceDescriptor.m +0 -1
- package/Sources/CapacitorObjC/CAPPlugin.m +100 -0
- package/Sources/CapacitorObjC/CAPPluginCallResult.m +29 -0
- package/{Capacitor/Capacitor → Sources/CapacitorObjC}/CAPPluginMethod.m +0 -1
- package/{Capacitor → Sources/CapacitorObjC/include}/Capacitor/CAPPlugin.h +3 -20
- package/{Capacitor → Sources/CapacitorObjC/include}/Capacitor/CAPPluginCall.h +1 -2
- package/Sources/CapacitorObjC/include/Capacitor/CAPPluginCallResult.h +28 -0
- package/Sources/CapacitorObjCShims/include/Capacitor/Capacitor-Swift.h +9 -0
- package/{Capacitor → Sources/CapacitorObjCShims/include}/Capacitor/Capacitor.h +8 -0
- package/package.json +6 -7
- package/Capacitor/Capacitor/CAPBridge.swift +0 -25
- package/Capacitor/Capacitor/CAPFile.swift +0 -14
- package/Capacitor/Capacitor/CAPPlugin.m +0 -180
- package/Capacitor/Capacitor/Info.plist +0 -24
- package/Capacitor/Capacitor/PluginCallResult.swift +0 -106
- package/CapacitorCordova/CapacitorCordova/Info.plist +0 -26
- /package/{Capacitor → Sources}/Capacitor/AppUUID.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Array+Capacitor.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/CAPBridgeDelegate.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/CAPBridgeViewController.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/CAPBridgedPlugin+getMethod.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/CAPInstanceDescriptor.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/CAPInstancePlugin.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/CAPLog.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/CAPPlugin+LoadInstance.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/CAPPluginMethod.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/CapacitorExtension.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Codable/JSValueDecoder.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Codable/JSValueEncoder.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Data+Capacitor.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/DocLinks.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/JSTypes.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/KeyPath.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/KeyValueStore.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/NotificationHandlerProtocol.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/PluginConfig.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Plugins/CapacitorCookieManager.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Plugins/CapacitorCookies.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Plugins/CapacitorHttp.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Plugins/Console.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Plugins/HttpRequestHandler.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Plugins/SystemBars.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/Plugins/WebView.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/PrivacyInfo.xcprivacy +0 -0
- /package/{Capacitor → Sources}/Capacitor/Router.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/UIColor.swift +0 -0
- /package/{Capacitor → Sources}/Capacitor/WKWebView+Capacitor.swift +0 -0
- /package/{Capacitor/Capacitor → Sources/CapacitorObjC}/CAPPluginCall.m +0 -0
- /package/{Capacitor → Sources/CapacitorObjC/include}/Capacitor/CAPBridgedPlugin.h +0 -0
- /package/{Capacitor → Sources/CapacitorObjC/include}/Capacitor/CAPInstanceConfiguration.h +0 -0
- /package/{Capacitor → Sources/CapacitorObjC/include}/Capacitor/CAPInstanceDescriptor.h +0 -0
- /package/{Capacitor → Sources/CapacitorObjC/include}/Capacitor/CAPPluginMethod.h +0 -0
- /package/{Capacitor/Capacitor → Sources/CapacitorObjCShims}/CAPBridgedJSTypes.m +0 -0
- /package/{Capacitor/Capacitor → Sources/CapacitorObjCShims}/Capacitor.modulemap +0 -0
- /package/{Capacitor/Capacitor → Sources/CapacitorObjCShims}/UIStatusBarManager+CAPHandleTapAction.m +0 -0
- /package/{Capacitor/Capacitor → Sources/CapacitorObjCShims}/WKWebView+Capacitor.m +0 -0
- /package/{Capacitor → Sources/CapacitorObjCShims/include}/Capacitor/CAPBridgedJSTypes.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/AppDelegate.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/CDVCommandDelegateImpl.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/CDVConfigParser.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/CDVInvokedUrlCommand.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/CDVPlugin+Resources.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/CDVPlugin.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/CDVPluginManager.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/CDVPluginResult.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/CDVURLProtocol.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/CDVViewController.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/CDVWebViewProcessPoolFactory.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova → Sources/Cordova}/CapacitorCordova.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova → Sources/Cordova}/CapacitorCordova.modulemap +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova}/NSDictionary+CordovaPreferences.m +0 -0
- /package/{CapacitorCordova/CapacitorCordova → Sources/Cordova}/PrivacyInfo.xcprivacy +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/AppDelegate.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDV.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVAvailability.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVAvailabilityDeprecated.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVCommandDelegate.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVCommandDelegateImpl.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVConfigParser.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVInvokedUrlCommand.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVPlugin+Resources.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVPlugin.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVPluginManager.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVPluginResult.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVScreenOrientationDelegate.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVURLProtocol.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVViewController.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/CDVWebViewProcessPoolFactory.h +0 -0
- /package/{CapacitorCordova/CapacitorCordova/Classes/Public → Sources/Cordova/include/Cordova}/NSDictionary+CordovaPreferences.h +0 -0
package/Capacitor.podspec
CHANGED
|
@@ -15,9 +15,15 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.ios.deployment_target = '16.0'
|
|
16
16
|
s.authors = { 'Ionic Team' => 'hi@ionicframework.com' }
|
|
17
17
|
s.source = { git: 'https://github.com/ionic-team/capacitor.git', tag: package['version'] }
|
|
18
|
-
s.source_files =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
s.source_files = [
|
|
19
|
+
"#{prefix}Sources/Capacitor/**/*.swift",
|
|
20
|
+
"#{prefix}Sources/CapacitorObjC/**/*.{h,m}",
|
|
21
|
+
"#{prefix}Sources/CapacitorObjCShims/**/*.{h,m}"
|
|
22
|
+
]
|
|
23
|
+
# SPM-only shim; CocoaPods generates the real Capacitor-Swift.h for the mixed-language module.
|
|
24
|
+
s.exclude_files = ["#{prefix}Sources/CapacitorObjCShims/include/Capacitor/Capacitor-Swift.h"]
|
|
25
|
+
s.module_map = "#{prefix}Sources/CapacitorObjCShims/Capacitor.modulemap"
|
|
26
|
+
s.resources = ["#{prefix}Sources/Capacitor/assets/native-bridge.js"]
|
|
27
|
+
s.resource_bundles = { 'Capacitor' => ["#{prefix}Sources/Capacitor/PrivacyInfo.xcprivacy"] }
|
|
22
28
|
s.swift_version = '5.1'
|
|
23
29
|
end
|
package/CapacitorCordova.podspec
CHANGED
|
@@ -16,11 +16,12 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
s.authors = { 'Ionic Team' => 'hi@ionicframework.com' }
|
|
17
17
|
s.source = { git: 'https://github.com/ionic-team/capacitor', tag: s.version.to_s }
|
|
18
18
|
s.platform = :ios, 16.0
|
|
19
|
-
s.source_files = "#{prefix}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
s.
|
|
19
|
+
s.source_files = "#{prefix}Sources/Cordova/**/*.{h,m}",
|
|
20
|
+
"#{prefix}Sources/CapacitorCordova/**/*.swift"
|
|
21
|
+
s.public_header_files = "#{prefix}Sources/Cordova/include/Cordova/*.h",
|
|
22
|
+
"#{prefix}Sources/Cordova/CapacitorCordova.h"
|
|
23
|
+
s.module_map = "#{prefix}Sources/Cordova/CapacitorCordova.modulemap"
|
|
24
|
+
s.resource_bundles = { 'CapacitorCordova' => ["#{prefix}Sources/Cordova/PrivacyInfo.xcprivacy"] }
|
|
24
25
|
s.requires_arc = true
|
|
25
26
|
s.dependency 'Capacitor', s.version.to_s
|
|
26
27
|
s.framework = 'WebKit'
|
|
@@ -4,7 +4,7 @@ import Foundation
|
|
|
4
4
|
public class ApplicationDelegateProxy: NSObject, UIApplicationDelegate {
|
|
5
5
|
public static let shared = ApplicationDelegateProxy()
|
|
6
6
|
|
|
7
|
-
public
|
|
7
|
+
public internal(set) var lastURL: URL?
|
|
8
8
|
|
|
9
9
|
public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
|
|
10
10
|
NotificationCenter.default.post(name: .capacitorOpenURL, object: [
|
|
@@ -15,34 +15,6 @@ import WebKit
|
|
|
15
15
|
var statusBarStyle: UIStatusBarStyle { get set }
|
|
16
16
|
var statusBarAnimation: UIStatusBarAnimation { get set }
|
|
17
17
|
|
|
18
|
-
// MARK: - Deprecated
|
|
19
|
-
@available(*, deprecated, renamed: "webView")
|
|
20
|
-
func getWebView() -> WKWebView?
|
|
21
|
-
|
|
22
|
-
@available(*, deprecated, renamed: "isSimEnvironment")
|
|
23
|
-
func isSimulator() -> Bool
|
|
24
|
-
|
|
25
|
-
@available(*, deprecated, renamed: "isDevEnvironment")
|
|
26
|
-
func isDevMode() -> Bool
|
|
27
|
-
|
|
28
|
-
@available(*, deprecated, renamed: "statusBarVisible")
|
|
29
|
-
func getStatusBarVisible() -> Bool
|
|
30
|
-
|
|
31
|
-
@available(*, deprecated, renamed: "statusBarStyle")
|
|
32
|
-
func getStatusBarStyle() -> UIStatusBarStyle
|
|
33
|
-
|
|
34
|
-
@available(*, deprecated, renamed: "userInterfaceStyle")
|
|
35
|
-
func getUserInterfaceStyle() -> UIUserInterfaceStyle
|
|
36
|
-
|
|
37
|
-
@available(*, deprecated, message: "Moved - equivalent is found on config.localURL")
|
|
38
|
-
func getLocalUrl() -> String
|
|
39
|
-
|
|
40
|
-
@available(*, deprecated, renamed: "savedCall(withID:)")
|
|
41
|
-
func getSavedCall(_ callbackId: String) -> CAPPluginCall?
|
|
42
|
-
|
|
43
|
-
@available(*, deprecated, renamed: "releaseCall(withID:)")
|
|
44
|
-
func releaseCall(callbackId: String)
|
|
45
|
-
|
|
46
18
|
// MARK: - Plugin Access
|
|
47
19
|
func plugin(withName: String) -> CAPPlugin?
|
|
48
20
|
|
|
@@ -84,46 +56,17 @@ import WebKit
|
|
|
84
56
|
|
|
85
57
|
// MARK: - View Presentation
|
|
86
58
|
func showAlertWith(title: String, message: String, buttonTitle: String)
|
|
87
|
-
@available(*, deprecated, message: "Use self?.bridge?.viewController?.present")
|
|
88
|
-
func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?)
|
|
89
|
-
@available(*, deprecated, message: "Use self?.bridge?.viewController?.dismiss")
|
|
90
|
-
func dismissVC(animated flag: Bool, completion: (() -> Void)?)
|
|
91
59
|
}
|
|
92
60
|
|
|
93
61
|
/*
|
|
94
62
|
Extensions to Obj-C protocols are not exposed to Obj-C code because of limitations in the runtime.
|
|
95
63
|
Therefore these methods are implicitly Swift-only.
|
|
96
|
-
|
|
97
|
-
The deprecated methods are declared here because they can be defined without colliding with the synthesized Obj-C setters
|
|
98
|
-
for the respective properties (e.g. `setStatusBarVisible:` for 'statusBarVisible`).
|
|
99
64
|
*/
|
|
100
65
|
extension CAPBridgeProtocol {
|
|
101
|
-
// variadic parameters cannot be exposed to Obj-C
|
|
102
|
-
@available(*, deprecated, message: "Use CAPLog directly")
|
|
103
|
-
public func modulePrint(_ plugin: CAPPlugin, _ items: Any...) {
|
|
104
|
-
let output = items.map { String(describing: $0) }.joined(separator: " ")
|
|
105
|
-
CAPLog.print("⚡️ ", plugin.pluginId, "-", output)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
66
|
// default arguments are not permitted in protocol declarations
|
|
109
67
|
public func alert(_ title: String, _ message: String, _ buttonTitle: String = "OK") {
|
|
110
68
|
showAlertWith(title: title, message: message, buttonTitle: buttonTitle)
|
|
111
69
|
}
|
|
112
|
-
|
|
113
|
-
@available(*, deprecated, renamed: "statusBarVisible")
|
|
114
|
-
public func setStatusBarVisible(_ visible: Bool) {
|
|
115
|
-
statusBarVisible = visible
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
@available(*, deprecated, renamed: "statusBarStyle")
|
|
119
|
-
public func setStatusBarStyle(_ style: UIStatusBarStyle) {
|
|
120
|
-
statusBarStyle = style
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@available(*, deprecated, renamed: "statusBarAnimation")
|
|
124
|
-
public func setStatusBarAnimation(_ animation: UIStatusBarAnimation) {
|
|
125
|
-
statusBarAnimation = animation
|
|
126
|
-
}
|
|
127
70
|
}
|
|
128
71
|
|
|
129
72
|
/*
|
|
@@ -23,11 +23,6 @@ extension InstanceConfiguration {
|
|
|
23
23
|
return localURL.appendingPathComponent(errorPath)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
@available(*, deprecated, message: "Use getPluginConfig")
|
|
27
|
-
@objc public func getPluginConfigValue(_ pluginId: String, _ configKey: String) -> Any? {
|
|
28
|
-
return (pluginConfigurations as? JSObject)?[keyPath: KeyPath("\(pluginId).\(configKey)")]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
26
|
@objc public func getPluginConfig(_ pluginId: String) -> PluginConfig {
|
|
32
27
|
if let cfg = (pluginConfigurations as? JSObject)?[keyPath: KeyPath("\(pluginId)")] as? JSObject {
|
|
33
28
|
return PluginConfig(config: cfg)
|
|
@@ -44,16 +39,6 @@ extension InstanceConfiguration {
|
|
|
44
39
|
return false
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
@available(*, deprecated, message: "Use direct property accessors")
|
|
48
|
-
@objc public func getValue(_ key: String) -> Any? {
|
|
49
|
-
return (legacyConfig as? JSObject)?[keyPath: KeyPath(key)]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@available(*, deprecated, message: "Use direct property accessors")
|
|
53
|
-
@objc public func getString(_ key: String) -> String? {
|
|
54
|
-
return (legacyConfig as? JSObject)?[keyPath: KeyPath(key)] as? String
|
|
55
|
-
}
|
|
56
|
-
|
|
57
42
|
// MARK: - Private
|
|
58
43
|
|
|
59
44
|
private func doesHost(_ host: String, match pattern: String) -> Bool {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
Notificaton types for NotificationCenter and NSNotificationCenter
|
|
3
3
|
|
|
4
|
-
We want to include `capacitor` in the name(s) to uniquely identify these even though it can make the names long
|
|
5
|
-
and the deprecated notifications are only here for backwards compatibility.
|
|
4
|
+
We want to include `capacitor` in the name(s) to uniquely identify these even though it can make the names long.
|
|
6
5
|
*/
|
|
7
6
|
// swiftlint:disable identifier_name
|
|
8
7
|
extension Notification.Name {
|
|
@@ -18,6 +17,10 @@ extension Notification.Name {
|
|
|
18
17
|
public static let capacitorStatusBarTapped = Notification.Name(rawValue: "CapacitorStatusBarTappedNotification")
|
|
19
18
|
public static let capacitorViewDidAppear = Notification.Name(rawValue: "CapacitorViewDidAppear")
|
|
20
19
|
public static let capacitorViewWillTransition = Notification.Name(rawValue: "CapacitorViewWillTransition")
|
|
20
|
+
public static let capacitorSceneWillConnect = Notification.Name(rawValue: "CapacitorSceneWillConnect")
|
|
21
|
+
public static let capacitorSceneOpenURL = Notification.Name(rawValue: "CapacitorSceneOpenURLNotification")
|
|
22
|
+
public static let capacitorSceneOpenUniversalLink =
|
|
23
|
+
Notification.Name(rawValue: "CapacitorSceneOpenUniversalLinkNotification")
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
@objc extension NSNotification {
|
|
@@ -30,40 +33,9 @@ extension Notification.Name {
|
|
|
30
33
|
public static let capacitorStatusBarTapped = Notification.Name.capacitorStatusBarTapped
|
|
31
34
|
public static let capacitorViewDidAppear = Notification.Name.capacitorViewDidAppear
|
|
32
35
|
public static let capacitorViewWillTransition = Notification.Name.capacitorViewWillTransition
|
|
36
|
+
public static let capacitorSceneWillConnect = Notification.Name.capacitorSceneWillConnect
|
|
37
|
+
public static let capacitorSceneOpenURL = Notification.Name.capacitorSceneOpenURL
|
|
38
|
+
public static let capacitorSceneOpenUniversalLink = Notification.Name.capacitorSceneOpenUniversalLink
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
/**
|
|
36
|
-
Deprecated, will be removed
|
|
37
|
-
*/
|
|
38
|
-
@objc public enum CAPNotifications: Int {
|
|
39
|
-
@available(*, deprecated, message: "renamed to 'Notification.Name.capacitorOpenURL'")
|
|
40
|
-
case URLOpen
|
|
41
|
-
@available(*, deprecated, message: "renamed to 'Notification.Name.capacitorOpenUniversalLink'")
|
|
42
|
-
case UniversalLinkOpen
|
|
43
|
-
@available(*, deprecated, message: "Notification.Name.capacitorContinueActivity'")
|
|
44
|
-
case ContinueActivity
|
|
45
|
-
@available(*, deprecated, message: "renamed to 'Notification.Name.capacitorDidRegisterForRemoteNotifications'")
|
|
46
|
-
case DidRegisterForRemoteNotificationsWithDeviceToken
|
|
47
|
-
@available(*, deprecated, message: "renamed to 'Notification.Name.capacitorDidFailToRegisterForRemoteNotifications'")
|
|
48
|
-
case DidFailToRegisterForRemoteNotificationsWithError
|
|
49
|
-
@available(*, deprecated, message: "renamed to 'Notification.Name.capacitorDecidePolicyForNavigationAction'")
|
|
50
|
-
case DecidePolicyForNavigationAction
|
|
51
|
-
|
|
52
|
-
public func name() -> String {
|
|
53
|
-
switch self {
|
|
54
|
-
case .URLOpen:
|
|
55
|
-
return Notification.Name.capacitorOpenURL.rawValue
|
|
56
|
-
case .UniversalLinkOpen:
|
|
57
|
-
return Notification.Name.capacitorOpenUniversalLink.rawValue
|
|
58
|
-
case .ContinueActivity:
|
|
59
|
-
return Notification.Name.capacitorContinueActivity.rawValue
|
|
60
|
-
case .DidRegisterForRemoteNotificationsWithDeviceToken:
|
|
61
|
-
return Notification.Name.capacitorDidRegisterForRemoteNotifications.rawValue
|
|
62
|
-
case .DidFailToRegisterForRemoteNotificationsWithError:
|
|
63
|
-
return Notification.Name.capacitorDidFailToRegisterForRemoteNotifications.rawValue
|
|
64
|
-
case .DecidePolicyForNavigationAction:
|
|
65
|
-
return Notification.Name.capacitorDecidePolicyForNavigationAction.rawValue
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
41
|
// swiftlint:enable identifier_name
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
import WebKit
|
|
4
|
+
|
|
5
|
+
@objc public extension CAPPlugin {
|
|
6
|
+
var bridge: CAPBridgeProtocol? {
|
|
7
|
+
get { return bridgeRef as? CAPBridgeProtocol }
|
|
8
|
+
set { bridgeRef = newValue as? NSObject }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@available(*, deprecated, message: "This initializer is deprecated and is not suggested for use. Any data set through this init method will be overridden when it is loaded on the bridge.")
|
|
12
|
+
@objc(initWithBridge:pluginId:pluginName:)
|
|
13
|
+
convenience init(bridge: CAPBridgeProtocol, pluginId: String, pluginName: String) {
|
|
14
|
+
self.init()
|
|
15
|
+
self.bridge = bridge
|
|
16
|
+
self.webView = bridge.webView
|
|
17
|
+
self.pluginId = pluginId
|
|
18
|
+
self.pluginName = pluginName
|
|
19
|
+
self.eventListeners = [:]
|
|
20
|
+
self.retainedEventArguments = [:]
|
|
21
|
+
self.shouldStringifyDatesInCalls = true
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@available(*, deprecated, message: "Use accessors on CAPPluginCall instead. See CAPBridgedJSTypes.h for Obj-C implementations.")
|
|
25
|
+
func getBool(_ call: CAPPluginCall, field: String, defaultValue: Bool) -> Bool {
|
|
26
|
+
guard let value = call.options[field] as? NSNumber else { return defaultValue }
|
|
27
|
+
return value.boolValue
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@available(*, deprecated, message: "Use accessors on CAPPluginCall instead. See CAPBridgedJSTypes.h for Obj-C implementations.")
|
|
31
|
+
func getString(_ call: CAPPluginCall, field: String, defaultValue: String) -> String? {
|
|
32
|
+
return call.options[field] as? String ?? defaultValue
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
func getConfig() -> PluginConfig {
|
|
36
|
+
return bridge?.config.getPluginConfig(pluginName) ?? PluginConfig(config: JSObject())
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
func notifyListeners(_ eventName: String, data: [String: Any]?) {
|
|
40
|
+
notifyListeners(eventName, data: data, retainUntilConsumed: false)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
func notifyListeners(_ eventName: String, data: [String: Any]?, retainUntilConsumed retain: Bool) {
|
|
44
|
+
guard let listenersForEvent = eventListeners?.object(forKey: eventName) as? NSArray,
|
|
45
|
+
listenersForEvent.count > 0 else {
|
|
46
|
+
if retain, let data = data {
|
|
47
|
+
let bucket: NSMutableArray
|
|
48
|
+
if let existing = retainedEventArguments?.object(forKey: eventName) as? NSMutableArray {
|
|
49
|
+
bucket = existing
|
|
50
|
+
} else {
|
|
51
|
+
bucket = NSMutableArray()
|
|
52
|
+
retainedEventArguments?.setObject(bucket, forKey: eventName as NSString)
|
|
53
|
+
}
|
|
54
|
+
bucket.add(data)
|
|
55
|
+
}
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for case let call as CAPPluginCall in listenersForEvent {
|
|
60
|
+
call.successHandler(CAPPluginCallResult(data), call)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
func removeListener(_ call: CAPPluginCall) {
|
|
65
|
+
guard let eventName = call.options["eventName"] as? String,
|
|
66
|
+
let callbackId = call.options["callbackId"] as? String else { return }
|
|
67
|
+
if let storedCall = bridge?.savedCall(withID: callbackId) {
|
|
68
|
+
removeEventListener(eventName, listener: storedCall)
|
|
69
|
+
}
|
|
70
|
+
bridge?.releaseCall(withID: callbackId)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
func removeAllListeners(_ call: CAPPluginCall) {
|
|
74
|
+
eventListeners?.removeAllObjects()
|
|
75
|
+
call.resolve()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Configure popover sourceRect, sourceView and permittedArrowDirections to show it centered
|
|
80
|
+
*/
|
|
81
|
+
func setCenteredPopover(_ viewController: UIViewController) {
|
|
82
|
+
guard let hostView = bridge?.viewController?.view else { return }
|
|
83
|
+
viewController.popoverPresentationController?.sourceRect = CGRect(x: hostView.center.x, y: hostView.center.y, width: 0, height: 0)
|
|
84
|
+
viewController.popoverPresentationController?.sourceView = hostView
|
|
85
|
+
viewController.popoverPresentationController?.permittedArrowDirections = []
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
func setCenteredPopover(_ viewController: UIViewController, size: CGSize) {
|
|
89
|
+
guard let hostView = bridge?.viewController?.view else { return }
|
|
90
|
+
viewController.popoverPresentationController?.sourceRect = CGRect(x: hostView.center.x, y: hostView.center.y, width: 0, height: 0)
|
|
91
|
+
viewController.preferredContentSize = size
|
|
92
|
+
viewController.popoverPresentationController?.sourceView = hostView
|
|
93
|
+
viewController.popoverPresentationController?.permittedArrowDirections = []
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@objc extension CAPPlugin {
|
|
98
|
+
/**
|
|
99
|
+
* Default implementation of the capacitor 3.0 permission pattern
|
|
100
|
+
*/
|
|
101
|
+
open func checkPermissions(_ call: CAPPluginCall) {
|
|
102
|
+
call.resolve()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
open func requestPermissions(_ call: CAPPluginCall) {
|
|
106
|
+
call.resolve()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
|
|
3
|
-
@available(*, deprecated, renamed: "PluginCallResultData")
|
|
4
|
-
public typealias PluginCallErrorData = [String: Any]
|
|
5
|
-
@available(*, deprecated, renamed: "PluginCallResultData")
|
|
6
|
-
public typealias PluginResultData = [String: Any]
|
|
7
|
-
|
|
8
3
|
/**
|
|
9
4
|
* Swift niceties for CAPPluginCall
|
|
10
5
|
*/
|
|
@@ -26,14 +21,6 @@ extension CAPPluginCall: JSValueContainer {
|
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
@objc public extension CAPPluginCall {
|
|
29
|
-
@available(*, deprecated, message: "Presence of a key should not be considered significant. Use typed accessors to check the value instead.")
|
|
30
|
-
func hasOption(_ key: String) -> Bool {
|
|
31
|
-
guard let value = options[key] else {
|
|
32
|
-
return false
|
|
33
|
-
}
|
|
34
|
-
return !(value is NSNull)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
24
|
func resolve() {
|
|
38
25
|
successHandler(CAPPluginCallResult(nil), self)
|
|
39
26
|
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CAPSceneDelegateProxy.swift
|
|
3
|
+
// Capacitor
|
|
4
|
+
//
|
|
5
|
+
// Created by Joseph Orlando Pender on 6/10/26.
|
|
6
|
+
// Copyright © 2026 Drifty Co. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
|
|
11
|
+
@objc(CAPSceneDelegateProxy)
|
|
12
|
+
public class SceneDelegateProxy: NSObject, UISceneDelegate {
|
|
13
|
+
public static let shared = SceneDelegateProxy()
|
|
14
|
+
|
|
15
|
+
public private(set) var lastURL: URL?
|
|
16
|
+
|
|
17
|
+
public func scene(
|
|
18
|
+
_ scene: UIScene, willConnectTo session: UISceneSession,
|
|
19
|
+
options connectionOptions: UIScene.ConnectionOptions
|
|
20
|
+
) {
|
|
21
|
+
NotificationCenter.default.post(name: .capacitorSceneWillConnect, object: scene)
|
|
22
|
+
|
|
23
|
+
// Plugins haven't loaded yet on a cold start, so notifications posted here are
|
|
24
|
+
// missed. Deliver them on the first capacitorViewDidAppear, once plugins are
|
|
25
|
+
// registered.
|
|
26
|
+
var token: NSObjectProtocol?
|
|
27
|
+
token = NotificationCenter.default.addObserver(forName: .capacitorViewDidAppear, object: nil, queue: .main) { _ in
|
|
28
|
+
if let token {
|
|
29
|
+
NotificationCenter.default.removeObserver(token)
|
|
30
|
+
}
|
|
31
|
+
if !connectionOptions.urlContexts.isEmpty {
|
|
32
|
+
self.scene(scene, openURLContexts: connectionOptions.urlContexts)
|
|
33
|
+
}
|
|
34
|
+
for userActivity in connectionOptions.userActivities {
|
|
35
|
+
self.scene(scene, continue: userActivity)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
|
|
41
|
+
for context in URLContexts {
|
|
42
|
+
lastURL = context.url
|
|
43
|
+
ApplicationDelegateProxy.shared.lastURL = context.url
|
|
44
|
+
let options = Self.openURLOptions(from: context.options)
|
|
45
|
+
|
|
46
|
+
// Capacitor 8 backwards compat
|
|
47
|
+
NotificationCenter.default.post(
|
|
48
|
+
name: .capacitorOpenURL,
|
|
49
|
+
object: [
|
|
50
|
+
"url": context.url,
|
|
51
|
+
"options": options
|
|
52
|
+
])
|
|
53
|
+
|
|
54
|
+
NotificationCenter.default.post(
|
|
55
|
+
name: .capacitorSceneOpenURL, object: scene,
|
|
56
|
+
userInfo: [
|
|
57
|
+
"url": context.url,
|
|
58
|
+
"options": options
|
|
59
|
+
])
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
|
64
|
+
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
|
|
65
|
+
let url = userActivity.webpageURL
|
|
66
|
+
else {
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
lastURL = url
|
|
70
|
+
ApplicationDelegateProxy.shared.lastURL = url
|
|
71
|
+
|
|
72
|
+
// Capacitor 8 backwards compat
|
|
73
|
+
NotificationCenter.default.post(
|
|
74
|
+
name: .capacitorOpenUniversalLink,
|
|
75
|
+
object: [
|
|
76
|
+
"url": url
|
|
77
|
+
])
|
|
78
|
+
|
|
79
|
+
NotificationCenter.default.post(
|
|
80
|
+
name: .capacitorSceneOpenUniversalLink, object: scene,
|
|
81
|
+
userInfo: [
|
|
82
|
+
"url": url
|
|
83
|
+
])
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/// Routes a URL into Capacitor's open-URL handlers from a SwiftUI App-struct app.
|
|
87
|
+
///
|
|
88
|
+
/// This is the recommended integration point for apps whose root is a `SwiftUI.App`
|
|
89
|
+
/// and which therefore do not declare an explicit `UISceneDelegate` subclass.
|
|
90
|
+
/// Call it from the `.onOpenURL` modifier inside the scene body:
|
|
91
|
+
///
|
|
92
|
+
/// ```swift
|
|
93
|
+
/// WindowGroup {
|
|
94
|
+
/// CapacitorView()
|
|
95
|
+
/// .onOpenURL { url in
|
|
96
|
+
/// SceneDelegateProxy.shared.handle(openURL: url)
|
|
97
|
+
/// }
|
|
98
|
+
/// }
|
|
99
|
+
/// ```
|
|
100
|
+
///
|
|
101
|
+
/// Posts the same notifications as the `scene(_:openURLContexts:)` protocol path —
|
|
102
|
+
/// both `.capacitorOpenURL` (Capacitor 8 back-compat payload) and
|
|
103
|
+
/// `.capacitorSceneOpenURL` (scene-aware, with the resolved scene as the notification
|
|
104
|
+
/// object and the URL in `userInfo`).
|
|
105
|
+
///
|
|
106
|
+
/// - Parameters:
|
|
107
|
+
/// - openURL: The URL to route.
|
|
108
|
+
/// - scene: The scene that received the URL. SwiftUI's `.onOpenURL` does not
|
|
109
|
+
/// surface a scene reference, so this defaults to `nil`; when `nil`, the active
|
|
110
|
+
/// foreground `UIWindowScene` is resolved from
|
|
111
|
+
/// `UIApplication.shared.connectedScenes`. For single-scene apps (the Phase 1
|
|
112
|
+
/// default) this is unambiguous; multi-scene URL routing is Phase 2.
|
|
113
|
+
public func handle(openURL: URL, scene: UIScene? = nil) {
|
|
114
|
+
let targetScene = scene ?? Self.activeForegroundScene()
|
|
115
|
+
lastURL = openURL
|
|
116
|
+
let options: [UIApplication.OpenURLOptionsKey: Any] = [:]
|
|
117
|
+
|
|
118
|
+
// Capacitor 8 backwards compat
|
|
119
|
+
NotificationCenter.default.post(
|
|
120
|
+
name: .capacitorOpenURL,
|
|
121
|
+
object: [
|
|
122
|
+
"url": openURL,
|
|
123
|
+
"options": options
|
|
124
|
+
])
|
|
125
|
+
|
|
126
|
+
NotificationCenter.default.post(
|
|
127
|
+
name: .capacitorSceneOpenURL, object: targetScene,
|
|
128
|
+
userInfo: [
|
|
129
|
+
"url": openURL,
|
|
130
|
+
"options": options
|
|
131
|
+
])
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// Routes a browsing-web `NSUserActivity` into Capacitor's universal-link handlers
|
|
135
|
+
/// from a SwiftUI App-struct app.
|
|
136
|
+
///
|
|
137
|
+
/// This is the recommended integration point for SwiftUI App-struct apps. Call it
|
|
138
|
+
/// from the `.onContinueUserActivity` modifier inside the scene body:
|
|
139
|
+
///
|
|
140
|
+
/// ```swift
|
|
141
|
+
/// WindowGroup {
|
|
142
|
+
/// CapacitorView()
|
|
143
|
+
/// .onContinueUserActivity(NSUserActivityTypeBrowsingWeb) { activity in
|
|
144
|
+
/// SceneDelegateProxy.shared.handle(userActivity: activity)
|
|
145
|
+
/// }
|
|
146
|
+
/// }
|
|
147
|
+
/// ```
|
|
148
|
+
///
|
|
149
|
+
/// Only activities with `activityType == NSUserActivityTypeBrowsingWeb` and a
|
|
150
|
+
/// non-nil `webpageURL` produce notifications; other activity types are silently
|
|
151
|
+
/// ignored, matching the `scene(_:continue:)` protocol path. When a notification is
|
|
152
|
+
/// produced, both `.capacitorOpenUniversalLink` (Capacitor 8 back-compat payload)
|
|
153
|
+
/// and `.capacitorSceneOpenUniversalLink` (scene-aware) are posted.
|
|
154
|
+
///
|
|
155
|
+
/// - Parameters:
|
|
156
|
+
/// - userActivity: The activity to inspect.
|
|
157
|
+
/// - scene: The scene that received the activity. SwiftUI does not surface a
|
|
158
|
+
/// scene reference here either, so this defaults to `nil`; when `nil`, the
|
|
159
|
+
/// active foreground `UIWindowScene` is resolved from
|
|
160
|
+
/// `UIApplication.shared.connectedScenes`.
|
|
161
|
+
public func handle(userActivity: NSUserActivity, scene: UIScene? = nil) {
|
|
162
|
+
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
|
|
163
|
+
let url = userActivity.webpageURL
|
|
164
|
+
else {
|
|
165
|
+
return
|
|
166
|
+
}
|
|
167
|
+
let targetScene = scene ?? Self.activeForegroundScene()
|
|
168
|
+
lastURL = url
|
|
169
|
+
|
|
170
|
+
// Capacitor 8 backwards compat
|
|
171
|
+
NotificationCenter.default.post(
|
|
172
|
+
name: .capacitorOpenUniversalLink,
|
|
173
|
+
object: [
|
|
174
|
+
"url": url
|
|
175
|
+
])
|
|
176
|
+
|
|
177
|
+
NotificationCenter.default.post(
|
|
178
|
+
name: .capacitorSceneOpenUniversalLink, object: targetScene,
|
|
179
|
+
userInfo: [
|
|
180
|
+
"url": url
|
|
181
|
+
])
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private static func activeForegroundScene() -> UIWindowScene? {
|
|
185
|
+
let scenes = UIApplication.shared.connectedScenes
|
|
186
|
+
if let active = scenes.first(where: { $0.activationState == .foregroundActive })
|
|
187
|
+
as? UIWindowScene {
|
|
188
|
+
return active
|
|
189
|
+
}
|
|
190
|
+
return scenes.first(where: { $0.activationState == .foregroundInactive }) as? UIWindowScene
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private static func openURLOptions(from sceneOptions: UIScene.OpenURLOptions) -> [UIApplication.OpenURLOptionsKey: Any] {
|
|
194
|
+
var options: [UIApplication.OpenURLOptionsKey: Any] = [:]
|
|
195
|
+
if let sourceApplication = sceneOptions.sourceApplication {
|
|
196
|
+
options[.sourceApplication] = sourceApplication
|
|
197
|
+
}
|
|
198
|
+
if let annotation = sceneOptions.annotation {
|
|
199
|
+
options[.annotation] = annotation
|
|
200
|
+
}
|
|
201
|
+
options[.openInPlace] = sceneOptions.openInPlace
|
|
202
|
+
return options
|
|
203
|
+
}
|
|
204
|
+
}
|