@aigens/aigens-sdk-core 5.0.1 → 5.0.3

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.
@@ -141,12 +141,20 @@ public class WebContainerActivity extends BridgeActivity {
141
141
 
142
142
 
143
143
 
144
- private String getRedirectUrl(Intent intent) {
144
+ private String getRedirectUrl(Intent intent, String url_) {
145
145
  try {
146
146
  // Intent intent = getIntent();
147
- Uri uri = intent.getData();
148
- if (uri != null) {
149
- String totalUrl = uri.toString();
147
+
148
+ Uri uri = null;
149
+ if (intent != null) uri = intent.getData();
150
+ if (uri != null || url_ != null) {
151
+
152
+ String totalUrl = null;
153
+ if (uri != null) {
154
+ totalUrl = uri.toString();
155
+ }else if (url_ != null && !url_.isEmpty()) {
156
+ totalUrl = url_;
157
+ }
150
158
  // Log.i("Jason totalUrl", totalUrl);
151
159
  String redirectUrl = null;
152
160
  String universalLink = null;
@@ -224,7 +232,7 @@ public class WebContainerActivity extends BridgeActivity {
224
232
  protected void onNewIntent(Intent intent) {
225
233
  super.onNewIntent(intent);
226
234
  // System.out.println("OPEN URL: onNewIntent" + intent.toString());
227
- String redirectUrl = getRedirectUrl(intent);
235
+ String redirectUrl = getRedirectUrl(intent, null);
228
236
  if (redirectUrl != null) {
229
237
  if (this.bridge != null && this.bridge.getWebView() != null) {
230
238
  initLayout(false, true, false);
@@ -243,6 +251,10 @@ public class WebContainerActivity extends BridgeActivity {
243
251
  String sign = url.contains("?") ? "&" : "?";
244
252
  getIntent().putExtra("url", url + sign + "channel=app");
245
253
  }
254
+ String url2 = getIntent().getStringExtra("url");
255
+ String sign2 = url2.contains("?") ? "&" : "?";
256
+ getIntent().putExtra("url", url2 + sign2 + "ts=" + String.valueOf(System.currentTimeMillis()));
257
+
246
258
  }
247
259
  }
248
260
 
@@ -260,7 +272,7 @@ public class WebContainerActivity extends BridgeActivity {
260
272
 
261
273
  Intent intent = getIntent();
262
274
 
263
- String redirectUrl = getRedirectUrl(intent);
275
+ String redirectUrl = getRedirectUrl(intent, null);
264
276
  if (redirectUrl != null && !redirectUrl.equals("") && WebContainerActivity.perviousIntent != null) {
265
277
  WebContainerActivity.perviousIntent.putExtra("url", redirectUrl);
266
278
  intent = WebContainerActivity.perviousIntent;
@@ -380,7 +392,8 @@ public class WebContainerActivity extends BridgeActivity {
380
392
  "com.aigens.sdk.alipay.AlipayPlugin",
381
393
  "com.aigens.sdk.wechat.WechatPlugin",
382
394
  "com.aigens.sdk.utils.AigensUtilsPlugin",
383
- "com.aigens.sdk.preferences.AigensPreferencesPlugin"
395
+ "com.aigens.sdk.preferences.AigensPreferencesPlugin",
396
+ "com.aigens.sdk.adyen.payments.AigensAdyenPaymentsPlugin"
384
397
  }, allPlugins);
385
398
  addExtraPlugins(intent.getStringArrayExtra("extraClasspaths"), allPlugins);
386
399
 
@@ -794,6 +807,15 @@ public class WebContainerActivity extends BridgeActivity {
794
807
  return false;
795
808
  }
796
809
 
810
+ private String decodeURIComponent(String encodedStr) {
811
+ String decodedStr = encodedStr;
812
+ try {
813
+ decodedStr = URLDecoder.decode(encodedStr, "UTF-8");
814
+ } catch (UnsupportedEncodingException e) {
815
+ decodedStr = encodedStr;
816
+ }
817
+ return decodedStr;
818
+ }
797
819
  public boolean shouldOverrideUrl(WebView view, String url) {
798
820
  if (url.startsWith(WebView.SCHEME_TEL)) {
799
821
  try {
@@ -847,6 +869,17 @@ public class WebContainerActivity extends BridgeActivity {
847
869
  }
848
870
  }else if (CorePlugin.coreListener != null && CorePlugin.coreListener.isInterceptedUrl(url, view, activity)) {
849
871
  return true;
872
+ }else {
873
+ String url_ = this.decodeURIComponent(url);
874
+ if (url_.contains("alwayscheck=true") || url_.contains("alwayscheck/true")) {
875
+ String redirectUrl = getRedirectUrl(null, url);
876
+ if (redirectUrl != null) {
877
+ initLayout(false, true, false);
878
+ view.loadUrl(redirectUrl);
879
+ return true;
880
+ }
881
+ }
882
+
850
883
  }
851
884
  return false;
852
885
  }
@@ -378,6 +378,7 @@ public class CorePlugin extends Plugin {
378
378
  }
379
379
 
380
380
  private static PluginCall dismissCall;
381
+
381
382
  @PluginMethod
382
383
  public void getFinishData(PluginCall call) {
383
384
  dismissCall = call;
@@ -232,6 +232,8 @@ public class CorePlugin: CAPPlugin {
232
232
  let r = ["closedData": data]
233
233
  WebContainerViewController.closeCB?(r)
234
234
  CorePlugin.dismissCall?.resolve(r)
235
+ }else {
236
+ WebContainerViewController.closeCB?(["closedData": [:]])
235
237
  }
236
238
 
237
239
  //let value = call.getString("value") ?? ""
@@ -343,6 +345,8 @@ public class CorePlugin: CAPPlugin {
343
345
  let r = ["closedData": data]
344
346
  WebContainerViewController.closeCB?(r)
345
347
  CorePlugin.dismissCall?.resolve(r)
348
+ }else {
349
+ WebContainerViewController.closeCB?(["closedData": [:]])
346
350
  }
347
351
 
348
352
  //let value = call.getString("value") ?? ""
@@ -89,12 +89,20 @@ import Capacitor
89
89
  }
90
90
  private func addChannel() {
91
91
  if let urlString = self.options?["url"] as? String {
92
-
93
92
  if !urlString.contains("&channel=app") && !urlString.contains("?channel=app") {
94
93
  let sign = urlString.contains("?") ? "&" : "?"
95
94
  self.options?["url"] = urlString + sign + "channel=app"
96
95
  }
96
+
97
+ }
98
+
99
+ if let urlString = self.options?["url"] as? String {
100
+ let sign = urlString.contains("?") ? "&" : "?"
101
+ let timestamp = Int(Date().timeIntervalSince1970 * 1000)
102
+ self.options?["url"] = urlString + sign + "ts=\(timestamp)"
97
103
  }
104
+
105
+
98
106
  }
99
107
 
100
108
  private func clearCache() {
@@ -177,7 +185,7 @@ import Capacitor
177
185
  return false
178
186
  }
179
187
 
180
- if url.contains("aigens=true") || url.contains("aigens/true") {
188
+ if url.contains("aigens=true") || url.contains("aigens/true") || url.contains("aigensRedirect/") {
181
189
  return true;
182
190
  }
183
191
  if !universalLink.isEmpty && url.contains(universalLink) {
@@ -189,12 +197,25 @@ import Capacitor
189
197
  return false;
190
198
  }
191
199
 
192
- private func fromAppUrl(_ url_: URL) {
200
+ private func isParseUrl2(_ url: String) -> Bool {
201
+
202
+ if isExcludedUniversalLink(url) {
203
+ return false
204
+ }
205
+ let contain = url.contains("alwayscheck=true") || url.contains("alwayscheck/true");
206
+ return contain
207
+ }
208
+
209
+ private func fromAppUrl(_ url_: URL, _ alwayscheck: Bool = false) -> Bool {
193
210
  let url = decodeURIComponent(url_);
194
211
 
195
212
 
196
- if !isParseUrl(url.absoluteString) {
197
- return;
213
+ if !alwayscheck && !isParseUrl(url.absoluteString) {
214
+ return false;
215
+ }
216
+
217
+ if alwayscheck && !isParseUrl2(url.absoluteString) {
218
+ return false;
198
219
  }
199
220
 
200
221
  let rUrl = URLRequest(url: url)
@@ -221,12 +242,13 @@ import Capacitor
221
242
  webContainerView.showError(false)
222
243
  let rUrl = URLRequest(url: redirectUrl)
223
244
  webView?.load(rUrl)
224
- return;
245
+ return true;
225
246
  }
226
247
 
227
248
  webContainerView.showLoading(true)
228
249
  webContainerView.showError(false)
229
250
  webView?.load(rUrl)
251
+ return true;
230
252
  }
231
253
 
232
254
  @objc func handleUrlOpened(notification: NSNotification) {
@@ -484,6 +506,11 @@ extension WebContainerViewController: WKNavigationDelegate {
484
506
  return;
485
507
  }
486
508
 
509
+ if (fromAppUrl(navURL, true)) {
510
+ decisionHandler(.cancel)
511
+ return;
512
+ }
513
+
487
514
  // if isParseUrl(navURL.absoluteString) {
488
515
  //
489
516
  // if navURL.absoluteString.range(of: "redirect=") != nil, var redirect = navURL.absoluteString.components(separatedBy:"redirect=").last{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigens/aigens-sdk-core",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "Aigens Order.Place Core Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",