@aigens/aigens-sdk-core 0.0.23 → 0.0.24

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.
@@ -147,6 +147,7 @@ public class WebContainerActivity extends BridgeActivity {
147
147
  this.deeplink = (Map) intent.getSerializableExtra("deeplink");
148
148
  boolean ENVIRONMENT_PRODUCTION = intent.getBooleanExtra("ENVIRONMENT_PRODUCTION", true);
149
149
  CorePlugin.setENVIRONMENT_PRODUCTION(ENVIRONMENT_PRODUCTION);
150
+ boolean clearCache = intent.getBooleanExtra("clearCache", false);
150
151
 
151
152
  List<String> externalProtocols_ = (List<String>) intent.getSerializableExtra("externalProtocols");
152
153
  if (externalProtocols_ != null) {
@@ -237,6 +238,10 @@ public class WebContainerActivity extends BridgeActivity {
237
238
  this.bridge.getWebView().getSettings().setUseWideViewPort(true);
238
239
  this.bridge.getWebView().getSettings().setLoadWithOverviewMode(true);
239
240
 
241
+ if (clearCache) {
242
+ this.bridge.getWebView().clearCache(true);
243
+ }
244
+
240
245
  // this.bridge.getWebView().getSettings().setAppCacheEnabled(false);
241
246
  // this.bridge.getWebView().clearCache(true);
242
247
  // this.bridge.getWebView().clearHistory();
@@ -130,6 +130,7 @@ public class CorePlugin extends Plugin {
130
130
  JSObject options = call.getObject("options", null);
131
131
  JSObject member = call.getObject("member", null);
132
132
  JSObject deeplink = call.getObject("deeplink", null);
133
+ boolean clearCache = call.getBoolean("clearCache", false);
133
134
  boolean ENVIRONMENT_PRODUCTION = call.getBoolean("ENVIRONMENT_PRODUCTION", true);
134
135
  CorePlugin.setENVIRONMENT_PRODUCTION(ENVIRONMENT_PRODUCTION);
135
136
 
@@ -177,6 +178,7 @@ public class CorePlugin extends Plugin {
177
178
  }
178
179
 
179
180
  intent.putExtra("url", url);
181
+ intent.putExtra("clearCache", clearCache);
180
182
  intent.putExtra("member", (Serializable) memMap);
181
183
  intent.putExtra("deeplink", (Serializable) deeplinkMap);
182
184
  intent.putExtra("ENVIRONMENT_PRODUCTION", ENVIRONMENT_PRODUCTION);
@@ -35,6 +35,42 @@ public class CorePlugin: CAPPlugin {
35
35
  return true
36
36
  }
37
37
 
38
+ private func clearCache() {
39
+ if #available(iOS 9.0, *) {
40
+ /*
41
+ 在磁盘缓存上。
42
+ WKWebsiteDataTypeDiskCache,
43
+ html离线Web应用程序缓存。
44
+ WKWebsiteDataTypeOfflineWebApplicationCache,
45
+ 内存缓存。
46
+ WKWebsiteDataTypeMemoryCache,
47
+ 本地存储。
48
+ WKWebsiteDataTypeLocalStorage,
49
+ Cookies
50
+ WKWebsiteDataTypeCookies,
51
+ 会话存储
52
+ WKWebsiteDataTypeSessionStorage,
53
+ IndexedDB数据库。
54
+ WKWebsiteDataTypeIndexedDBDatabases,
55
+ 查询数据库。
56
+ WKWebsiteDataTypeWebSQLDatabases
57
+ */
58
+ let types = [WKWebsiteDataTypeMemoryCache, WKWebsiteDataTypeDiskCache]
59
+ let websiteDataTypes = Set<AnyHashable>(types)
60
+ let dateFrom = Date(timeIntervalSince1970: 0)
61
+ if let websiteDataTypes = websiteDataTypes as? Set<String> {
62
+ WKWebsiteDataStore.default().removeData(ofTypes: websiteDataTypes, modifiedSince: dateFrom, completionHandler: {
63
+ print("removeData completionHandler");
64
+ })
65
+ }
66
+ } else {
67
+ // let libraryPath = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true)[0]
68
+ // let cookiesFolderPath = libraryPath + ("/Cookies")
69
+ // JJPrint("\(cookiesFolderPath)")
70
+ // try? FileManager.default.removeItem(atPath: cookiesFolderPath)
71
+ }
72
+ }
73
+
38
74
  @objc func echo(_ call: CAPPluginCall) {
39
75
 
40
76
  print("CorePlugin echo")
@@ -109,9 +145,13 @@ public class CorePlugin: CAPPlugin {
109
145
  let member = call.getObject("member")
110
146
  let deeplink = call.getObject("deeplink")
111
147
  let externalProtocols = call.getArray("externalProtocols")
148
+ let clearCache = call.getBool("clearCache") ?? false
112
149
 
113
150
  DispatchQueue.main.async {
114
151
 
152
+ if clearCache {
153
+ self.clearCache()
154
+ }
115
155
  let bridgeVC = WebContainerViewController()
116
156
 
117
157
  var options = [String: AnyObject]()
@@ -162,19 +202,22 @@ public class CorePlugin: CAPPlugin {
162
202
 
163
203
  @objc func openExternalUrl(_ call: CAPPluginCall) {
164
204
  if let url = call.getString("url"), let URL_ = URL(string: url) {
165
- let can = UIApplication.shared.canOpenURL(URL_)
166
- if !can {
167
- call.reject("cannot open the url:\(url)")
168
- return;
169
- }
170
- if #available(iOS 10.0, *) {
171
- UIApplication.shared.open(URL_, options: [:], completionHandler: nil)
172
- } else {
173
- UIApplication.shared.openURL(URL_)
205
+ DispatchQueue.main.async {
206
+ let can = UIApplication.shared.canOpenURL(URL_)
207
+ if !can {
208
+ call.reject("cannot open the url:\(url)")
209
+ return;
210
+ }
211
+ if #available(iOS 10.0, *) {
212
+ UIApplication.shared.open(URL_, options: [:], completionHandler: nil)
213
+ } else {
214
+ UIApplication.shared.openURL(URL_)
215
+ }
216
+ call.resolve([
217
+ "open": true
218
+ ])
219
+
174
220
  }
175
- call.resolve([
176
- "open": true
177
- ])
178
221
 
179
222
  }else {
180
223
  call.reject("url is missing or is invaild url")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigens/aigens-sdk-core",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "Aigens Order.Place Core Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",