@aigens/aigens-sdk-core 0.0.30 → 0.0.31
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/ios/Plugin/CorePlugin.m
CHANGED
@@ -14,4 +14,6 @@ CAP_PLUGIN(CorePlugin, "Core",
|
|
14
14
|
CAP_PLUGIN_METHOD(openExternalUrl, CAPPluginReturnPromise);
|
15
15
|
CAP_PLUGIN_METHOD(getIsProductionEnvironment, CAPPluginReturnPromise);
|
16
16
|
CAP_PLUGIN_METHOD(checkNotificationPermissions, CAPPluginReturnPromise);
|
17
|
+
CAP_PLUGIN_METHOD(getFinishData, CAPPluginReturnPromise);
|
18
|
+
|
17
19
|
)
|
@@ -94,6 +94,12 @@ public class CorePlugin: CAPPlugin {
|
|
94
94
|
}
|
95
95
|
|
96
96
|
|
97
|
+
if let data = call.getObject("closedData") {
|
98
|
+
let r = ["closedData": data]
|
99
|
+
WebContainerViewController.closeCB?(r)
|
100
|
+
CorePlugin.dismissCall?.resolve(r)
|
101
|
+
}
|
102
|
+
|
97
103
|
//let value = call.getString("value") ?? ""
|
98
104
|
call.resolve([
|
99
105
|
"success": true
|
@@ -124,6 +130,11 @@ public class CorePlugin: CAPPlugin {
|
|
124
130
|
self.bridge?.viewController?.dismiss(animated: true);
|
125
131
|
}
|
126
132
|
|
133
|
+
if let data = call.getObject("closedData") {
|
134
|
+
let r = ["closedData": data]
|
135
|
+
WebContainerViewController.closeCB?(r)
|
136
|
+
CorePlugin.dismissCall?.resolve(r)
|
137
|
+
}
|
127
138
|
|
128
139
|
//let value = call.getString("value") ?? ""
|
129
140
|
call.resolve([
|
@@ -132,6 +143,12 @@ public class CorePlugin: CAPPlugin {
|
|
132
143
|
])
|
133
144
|
}
|
134
145
|
|
146
|
+
private static var dismissCall: CAPPluginCall?
|
147
|
+
@objc func getFinishData(_ call: CAPPluginCall) {
|
148
|
+
call.keepAlive = true
|
149
|
+
CorePlugin.dismissCall = call
|
150
|
+
}
|
151
|
+
|
135
152
|
|
136
153
|
@objc func openBrowser(_ call: CAPPluginCall) {
|
137
154
|
|
@@ -11,6 +11,7 @@ import Capacitor
|
|
11
11
|
|
12
12
|
@objc open class WebContainerViewController: CAPBridgeViewController {
|
13
13
|
|
14
|
+
public static var closeCB: ((Any?) -> Void)? = nil;
|
14
15
|
// {themeColor: "#xxxxxx"}
|
15
16
|
public var options: Dictionary<String, Any>?
|
16
17
|
private var isFirstError = true
|
@@ -47,6 +48,43 @@ import Capacitor
|
|
47
48
|
|
48
49
|
}
|
49
50
|
|
51
|
+
private func clearCache() {
|
52
|
+
if #available(iOS 9.0, *) {
|
53
|
+
/*
|
54
|
+
在磁盘缓存上。
|
55
|
+
WKWebsiteDataTypeDiskCache,
|
56
|
+
html离线Web应用程序缓存。
|
57
|
+
WKWebsiteDataTypeOfflineWebApplicationCache,
|
58
|
+
内存缓存。
|
59
|
+
WKWebsiteDataTypeMemoryCache,
|
60
|
+
本地存储。
|
61
|
+
WKWebsiteDataTypeLocalStorage,
|
62
|
+
Cookies
|
63
|
+
WKWebsiteDataTypeCookies,
|
64
|
+
会话存储
|
65
|
+
WKWebsiteDataTypeSessionStorage,
|
66
|
+
IndexedDB数据库。
|
67
|
+
WKWebsiteDataTypeIndexedDBDatabases,
|
68
|
+
查询数据库。
|
69
|
+
WKWebsiteDataTypeWebSQLDatabases
|
70
|
+
*/
|
71
|
+
let types = [WKWebsiteDataTypeMemoryCache, WKWebsiteDataTypeDiskCache]
|
72
|
+
let websiteDataTypes = Set<AnyHashable>(types)
|
73
|
+
let dateFrom = Date(timeIntervalSince1970: 0)
|
74
|
+
if let websiteDataTypes = websiteDataTypes as? Set<String> {
|
75
|
+
WKWebsiteDataStore.default().removeData(ofTypes: websiteDataTypes, modifiedSince: dateFrom, completionHandler: {
|
76
|
+
aigensprint("removeData completionHandler");
|
77
|
+
})
|
78
|
+
}
|
79
|
+
} else {
|
80
|
+
// let libraryPath = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true)[0]
|
81
|
+
// let cookiesFolderPath = libraryPath + ("/Cookies")
|
82
|
+
// JJPrint("\(cookiesFolderPath)")
|
83
|
+
// try? FileManager.default.removeItem(atPath: cookiesFolderPath)
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
|
50
88
|
private func handleOpenUrl() {
|
51
89
|
NotificationCenter.default.addObserver(self, selector: #selector(self.handleUniversalLink(notification:)), name: Notification.Name.capacitorOpenUniversalLink, object: nil)
|
52
90
|
|
@@ -162,6 +200,14 @@ import Capacitor
|
|
162
200
|
let deeplink = self.options?["deeplink"] as? Dictionary<String, Any>
|
163
201
|
CorePlugin.deeplink = deeplink
|
164
202
|
|
203
|
+
if let debug = self.options?["debug"] as? Bool, debug == true {
|
204
|
+
aigensDebug = debug
|
205
|
+
}
|
206
|
+
|
207
|
+
if let clearCache = self.options?["clearCache"] as? Bool, clearCache == true {
|
208
|
+
self.clearCache()
|
209
|
+
}
|
210
|
+
|
165
211
|
//bridge.webViewDelegationHandler.willLoadWebview(webView)
|
166
212
|
_ = webView?.load(URLRequest(url: url!))
|
167
213
|
webView?.navigationDelegate = self
|