@capacitor-plus/ios 8.3.12 → 8.5.1
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/Capacitor/CAPApplicationDelegateProxy.swift +1 -1
- package/Capacitor/Capacitor/CAPNotifications.swift +7 -0
- package/Capacitor/Capacitor/CAPSceneDelegateProxy.swift +125 -0
- package/Capacitor/Capacitor/CapacitorBridge.swift +15 -9
- package/Capacitor/Capacitor/PluginConfig.swift +7 -0
- package/Capacitor/Capacitor/WebViewDelegationHandler.swift +1 -1
- package/package.json +3 -3
- package/Capacitor/Capacitor/TmpViewController.swift +0 -8
|
@@ -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: [
|
|
@@ -18,6 +18,10 @@ extension Notification.Name {
|
|
|
18
18
|
public static let capacitorStatusBarTapped = Notification.Name(rawValue: "CapacitorStatusBarTappedNotification")
|
|
19
19
|
public static let capacitorViewDidAppear = Notification.Name(rawValue: "CapacitorViewDidAppear")
|
|
20
20
|
public static let capacitorViewWillTransition = Notification.Name(rawValue: "CapacitorViewWillTransition")
|
|
21
|
+
public static let capacitorSceneWillConnect = Notification.Name(rawValue: "CapacitorSceneWillConnect")
|
|
22
|
+
public static let capacitorSceneOpenURL = Notification.Name(rawValue: "CapacitorSceneOpenURLNotification")
|
|
23
|
+
public static let capacitorSceneOpenUniversalLink =
|
|
24
|
+
Notification.Name(rawValue: "CapacitorSceneOpenUniversalLinkNotification")
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
@objc extension NSNotification {
|
|
@@ -30,6 +34,9 @@ extension Notification.Name {
|
|
|
30
34
|
public static let capacitorStatusBarTapped = Notification.Name.capacitorStatusBarTapped
|
|
31
35
|
public static let capacitorViewDidAppear = Notification.Name.capacitorViewDidAppear
|
|
32
36
|
public static let capacitorViewWillTransition = Notification.Name.capacitorViewWillTransition
|
|
37
|
+
public static let capacitorSceneWillConnect = Notification.Name.capacitorSceneWillConnect
|
|
38
|
+
public static let capacitorSceneOpenURL = Notification.Name.capacitorSceneOpenURL
|
|
39
|
+
public static let capacitorSceneOpenUniversalLink = Notification.Name.capacitorSceneOpenUniversalLink
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
/**
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
import UIKit
|
|
11
|
+
|
|
12
|
+
@objc(CAPSceneDelegateProxy)
|
|
13
|
+
public class SceneDelegateProxy: NSObject, UISceneDelegate {
|
|
14
|
+
public static let shared = SceneDelegateProxy()
|
|
15
|
+
|
|
16
|
+
public private(set) var lastURL: URL?
|
|
17
|
+
|
|
18
|
+
public func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
|
19
|
+
NotificationCenter.default.post(name: .capacitorSceneWillConnect, object: scene)
|
|
20
|
+
|
|
21
|
+
// Plugins haven't loaded yet on a cold start, so notifications posted here are
|
|
22
|
+
// missed. Deliver them on the first capacitorViewDidAppear, once plugins are
|
|
23
|
+
// registered.
|
|
24
|
+
var token: NSObjectProtocol?
|
|
25
|
+
token = NotificationCenter.default.addObserver(forName: .capacitorViewDidAppear, object: nil, queue: .main) { [weak self] _ in
|
|
26
|
+
guard let self, Self.isBridgeReady(for: scene) else { return }
|
|
27
|
+
if let token {
|
|
28
|
+
NotificationCenter.default.removeObserver(token)
|
|
29
|
+
}
|
|
30
|
+
token = nil
|
|
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
|
+
private static func isBridgeReady(for scene: UIScene) -> Bool {
|
|
41
|
+
guard let windowScene = scene as? UIWindowScene else {
|
|
42
|
+
return false
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for window in windowScene.windows {
|
|
46
|
+
guard let bridge = findBridge(in: window.rootViewController) else {
|
|
47
|
+
continue
|
|
48
|
+
}
|
|
49
|
+
if bridge.isViewLoaded && bridge.view.window != nil {
|
|
50
|
+
return true
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private static func findBridge(in viewController: UIViewController?) -> CAPBridgeViewController? {
|
|
58
|
+
if let bridge = viewController as? CAPBridgeViewController {
|
|
59
|
+
return bridge
|
|
60
|
+
}
|
|
61
|
+
if let navigationController = viewController as? UINavigationController {
|
|
62
|
+
return findBridge(in: navigationController.visibleViewController)
|
|
63
|
+
}
|
|
64
|
+
if let tabBarController = viewController as? UITabBarController {
|
|
65
|
+
return findBridge(in: tabBarController.selectedViewController)
|
|
66
|
+
}
|
|
67
|
+
for child in viewController?.children ?? [] {
|
|
68
|
+
if let bridge = findBridge(in: child) {
|
|
69
|
+
return bridge
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return nil
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
|
|
76
|
+
for context in URLContexts {
|
|
77
|
+
lastURL = context.url
|
|
78
|
+
ApplicationDelegateProxy.shared.lastURL = context.url
|
|
79
|
+
let options = Self.openURLOptions(from: context.options)
|
|
80
|
+
|
|
81
|
+
// Capacitor 8 backwards compat
|
|
82
|
+
NotificationCenter.default.post(name: .capacitorOpenURL, object: [
|
|
83
|
+
"url": context.url,
|
|
84
|
+
"options": options
|
|
85
|
+
])
|
|
86
|
+
|
|
87
|
+
NotificationCenter.default.post(name: NSNotification.Name.CDVPluginHandleOpenURL, object: context.url)
|
|
88
|
+
|
|
89
|
+
NotificationCenter.default.post(name: .capacitorSceneOpenURL, object: scene, userInfo: [
|
|
90
|
+
"url": context.url,
|
|
91
|
+
"options": options
|
|
92
|
+
])
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
|
97
|
+
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
|
|
98
|
+
let url = userActivity.webpageURL else {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
lastURL = url
|
|
102
|
+
ApplicationDelegateProxy.shared.lastURL = url
|
|
103
|
+
|
|
104
|
+
// Capacitor 8 backwards compat
|
|
105
|
+
NotificationCenter.default.post(name: .capacitorOpenUniversalLink, object: [
|
|
106
|
+
"url": url
|
|
107
|
+
])
|
|
108
|
+
|
|
109
|
+
NotificationCenter.default.post(name: .capacitorSceneOpenUniversalLink, object: scene, userInfo: [
|
|
110
|
+
"url": url
|
|
111
|
+
])
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private static func openURLOptions(from sceneOptions: UIScene.OpenURLOptions) -> [UIApplication.OpenURLOptionsKey: Any] {
|
|
115
|
+
var options: [UIApplication.OpenURLOptionsKey: Any] = [:]
|
|
116
|
+
if let sourceApplication = sceneOptions.sourceApplication {
|
|
117
|
+
options[.sourceApplication] = sourceApplication
|
|
118
|
+
}
|
|
119
|
+
if let annotation = sceneOptions.annotation {
|
|
120
|
+
options[.annotation] = annotation
|
|
121
|
+
}
|
|
122
|
+
options[.openInPlace] = sceneOptions.openInPlace
|
|
123
|
+
return options
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -93,10 +93,6 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
@available(*, deprecated, message: "obsolete")
|
|
97
|
-
var tmpWindow: UIWindow?
|
|
98
|
-
@available(*, deprecated, message: "obsolete")
|
|
99
|
-
static let tmpVCAppeared = Notification(name: Notification.Name(rawValue: "tmpViewControllerAppeared"))
|
|
100
96
|
public static let capacitorSite = "https://capacitorjs.com/"
|
|
101
97
|
public static let fileStartIdentifier = "/_capacitor_file_"
|
|
102
98
|
public static let httpInterceptorStartIdentifier = "/_capacitor_http_interceptor_"
|
|
@@ -223,9 +219,6 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
|
|
|
223
219
|
setupCordovaCompatibility()
|
|
224
220
|
exportMiscJS()
|
|
225
221
|
canInjectJS = false
|
|
226
|
-
observers.append(NotificationCenter.default.addObserver(forName: type(of: self).tmpVCAppeared.name, object: .none, queue: .none) { [weak self] _ in
|
|
227
|
-
self?.tmpWindow = nil
|
|
228
|
-
})
|
|
229
222
|
|
|
230
223
|
self.setupWebDebugging(configuration: configuration)
|
|
231
224
|
}
|
|
@@ -270,12 +263,25 @@ open class CapacitorBridge: NSObject, CAPBridgeProtocol {
|
|
|
270
263
|
exportCordovaJS()
|
|
271
264
|
registerCordovaPlugins()
|
|
272
265
|
} else {
|
|
273
|
-
observers.append(NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: OperationQueue.main) { [weak self]
|
|
266
|
+
observers.append(NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: OperationQueue.main) { [weak self] _ in
|
|
267
|
+
guard self?.viewController?.view.window?.windowScene == nil else { return }
|
|
274
268
|
self?.triggerDocumentJSEvent(eventName: "resume")
|
|
275
269
|
})
|
|
276
|
-
observers.append(NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: OperationQueue.main) { [weak self]
|
|
270
|
+
observers.append(NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: OperationQueue.main) { [weak self] _ in
|
|
271
|
+
guard self?.viewController?.view.window?.windowScene == nil else { return }
|
|
277
272
|
self?.triggerDocumentJSEvent(eventName: "pause")
|
|
278
273
|
})
|
|
274
|
+
observers.append(NotificationCenter.default.addObserver(forName: UIScene.willEnterForegroundNotification, object: nil, queue: OperationQueue.main) { [weak self] notification in
|
|
275
|
+
if let scene = notification.object as? UIWindowScene, scene === self?.viewController?.view.window?.windowScene {
|
|
276
|
+
self?.triggerDocumentJSEvent(eventName: "resume")
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
})
|
|
280
|
+
observers.append(NotificationCenter.default.addObserver(forName: UIScene.didEnterBackgroundNotification, object: nil, queue: OperationQueue.main) { [weak self] notification in
|
|
281
|
+
if let scene = notification.object as? UIWindowScene, scene === self?.viewController?.view.window?.windowScene {
|
|
282
|
+
self?.triggerDocumentJSEvent(eventName: "pause")
|
|
283
|
+
}
|
|
284
|
+
})
|
|
279
285
|
}
|
|
280
286
|
}
|
|
281
287
|
|
|
@@ -30,6 +30,13 @@ import Foundation
|
|
|
30
30
|
return defaultValue
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
@objc public func getDouble(_ configKey: String, _ defaultValue: Double) -> Double {
|
|
34
|
+
if let val = (self.config)[keyPath: KeyPath(configKey)] as? Double {
|
|
35
|
+
return val
|
|
36
|
+
}
|
|
37
|
+
return defaultValue
|
|
38
|
+
}
|
|
39
|
+
|
|
33
40
|
public func getArray(_ configKey: String, _ defaultValue: JSArray? = nil) -> JSArray? {
|
|
34
41
|
if let val = (self.config)[keyPath: KeyPath(configKey)] as? JSArray {
|
|
35
42
|
return val
|
|
@@ -107,7 +107,7 @@ open class WebViewDelegationHandler: NSObject, WKNavigationDelegate, WKUIDelegat
|
|
|
107
107
|
|
|
108
108
|
if !isApplicationNavigation, toplevelNavigation {
|
|
109
109
|
// disallow and let the system handle it
|
|
110
|
-
if
|
|
110
|
+
if webView.window?.windowScene?.activationState == .foregroundActive {
|
|
111
111
|
UIApplication.shared.open(navURL, options: [:], completionHandler: nil)
|
|
112
112
|
}
|
|
113
113
|
decisionHandler(.cancel)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-plus/ios",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.1",
|
|
4
4
|
"description": "Capacitor+: Enhanced Capacitor with automated upstream sync - Cross-platform apps with JavaScript and the web",
|
|
5
5
|
"homepage": "https://capgo.app/docs/plugins/capacitor-plus/",
|
|
6
6
|
"author": "Capgo Team <support@capgo.app> (https://capgo.app)",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"xc:build:CapacitorCordova": "cd CapacitorCordova && xcodebuild && cd .."
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@capacitor-plus/core": "^8.
|
|
29
|
-
"@capacitor/core": "^8.
|
|
28
|
+
"@capacitor-plus/core": "^8.5.0",
|
|
29
|
+
"@capacitor/core": "^8.5.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|