@aigens/aigens-sdk-core 5.0.2 → 5.0.4

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);
@@ -235,18 +243,27 @@ public class WebContainerActivity extends BridgeActivity {
235
243
 
236
244
  }
237
245
 
238
- private void addChannel() {
246
+ private void addChannelAndTs() {
247
+
239
248
  if (getIntent() == null) return;
240
249
  String url = getIntent().getStringExtra("url");
250
+
251
+ Map m = (Map) getIntent().getSerializableExtra("member");
252
+ boolean withoutAddChannel = false;
253
+ boolean disableAddTs = false;
254
+ if (m != null) {
255
+ withoutAddChannel = (boolean) m.getOrDefault("withoutAddChannel", false);
256
+ disableAddTs = (boolean) m.getOrDefault("disableAddTs", false);
257
+ }
258
+
241
259
  if (url != null) {
242
- if (!url.contains("&channel=app") && !url.contains("?channel=app")) {
260
+ if (!url.contains("&channel=app") && !url.contains("?channel=app") && !withoutAddChannel) {
243
261
  String sign = url.contains("?") ? "&" : "?";
244
262
  getIntent().putExtra("url", url + sign + "channel=app");
245
263
  }
246
264
  String url2 = getIntent().getStringExtra("url");
247
265
  String sign2 = url2.contains("?") ? "&" : "?";
248
- getIntent().putExtra("url", url2 + sign2 + "ts=" + String.valueOf(System.currentTimeMillis()));
249
-
266
+ if (!disableAddTs) getIntent().putExtra("url", url2 + sign2 + "ts=" + String.valueOf(System.currentTimeMillis()));
250
267
  }
251
268
  }
252
269
 
@@ -259,12 +276,12 @@ public class WebContainerActivity extends BridgeActivity {
259
276
 
260
277
  setContentView(com.aigens.sdk.R.layout.sdk_layout_main);
261
278
 
262
- addChannel();
279
+
263
280
 
264
281
 
265
282
  Intent intent = getIntent();
266
283
 
267
- String redirectUrl = getRedirectUrl(intent);
284
+ String redirectUrl = getRedirectUrl(intent, null);
268
285
  if (redirectUrl != null && !redirectUrl.equals("") && WebContainerActivity.perviousIntent != null) {
269
286
  WebContainerActivity.perviousIntent.putExtra("url", redirectUrl);
270
287
  intent = WebContainerActivity.perviousIntent;
@@ -273,6 +290,7 @@ public class WebContainerActivity extends BridgeActivity {
273
290
  WebContainerActivity.perviousIntent = intent;
274
291
  WebContainerActivity.perviousInstanceState = currentInstanceState;
275
292
 
293
+ addChannelAndTs();
276
294
 
277
295
  this.url = intent.getStringExtra("url");
278
296
 
@@ -384,7 +402,8 @@ public class WebContainerActivity extends BridgeActivity {
384
402
  "com.aigens.sdk.alipay.AlipayPlugin",
385
403
  "com.aigens.sdk.wechat.WechatPlugin",
386
404
  "com.aigens.sdk.utils.AigensUtilsPlugin",
387
- "com.aigens.sdk.preferences.AigensPreferencesPlugin"
405
+ "com.aigens.sdk.preferences.AigensPreferencesPlugin",
406
+ "com.aigens.sdk.adyen.payments.AigensAdyenPaymentsPlugin"
388
407
  }, allPlugins);
389
408
  addExtraPlugins(intent.getStringArrayExtra("extraClasspaths"), allPlugins);
390
409
 
@@ -798,6 +817,15 @@ public class WebContainerActivity extends BridgeActivity {
798
817
  return false;
799
818
  }
800
819
 
820
+ private String decodeURIComponent(String encodedStr) {
821
+ String decodedStr = encodedStr;
822
+ try {
823
+ decodedStr = URLDecoder.decode(encodedStr, "UTF-8");
824
+ } catch (UnsupportedEncodingException e) {
825
+ decodedStr = encodedStr;
826
+ }
827
+ return decodedStr;
828
+ }
801
829
  public boolean shouldOverrideUrl(WebView view, String url) {
802
830
  if (url.startsWith(WebView.SCHEME_TEL)) {
803
831
  try {
@@ -851,6 +879,17 @@ public class WebContainerActivity extends BridgeActivity {
851
879
  }
852
880
  }else if (CorePlugin.coreListener != null && CorePlugin.coreListener.isInterceptedUrl(url, view, activity)) {
853
881
  return true;
882
+ }else {
883
+ String url_ = this.decodeURIComponent(url);
884
+ if (url_.contains("alwayscheck=true") || url_.contains("alwayscheck/true")) {
885
+ String redirectUrl = getRedirectUrl(null, url);
886
+ if (redirectUrl != null) {
887
+ initLayout(false, true, false);
888
+ view.loadUrl(redirectUrl);
889
+ return true;
890
+ }
891
+ }
892
+
854
893
  }
855
894
  return false;
856
895
  }
@@ -58,7 +58,7 @@ import Capacitor
58
58
 
59
59
  self.becomeFirstResponder()
60
60
 
61
- addChannel()
61
+ addChannelAndTs()
62
62
  loadWebViewCustom()
63
63
  initView()
64
64
 
@@ -87,16 +87,21 @@ import Capacitor
87
87
  }
88
88
  return result
89
89
  }
90
- private func addChannel() {
90
+ private func addChannelAndTs() {
91
+
92
+ let member = self.options?["member"] as? Dictionary<String, Any>
93
+ let withoutAddChannel = member?["withoutAddChannel"] as? Bool ?? false
94
+ let disableAddTs = member?["disableAddTs"] as? Bool ?? false
95
+
91
96
  if let urlString = self.options?["url"] as? String {
92
- if !urlString.contains("&channel=app") && !urlString.contains("?channel=app") {
97
+ if !urlString.contains("&channel=app") && !urlString.contains("?channel=app") && !withoutAddChannel {
93
98
  let sign = urlString.contains("?") ? "&" : "?"
94
99
  self.options?["url"] = urlString + sign + "channel=app"
95
100
  }
96
101
 
97
102
  }
98
103
 
99
- if let urlString = self.options?["url"] as? String {
104
+ if let urlString = self.options?["url"] as? String, !disableAddTs {
100
105
  let sign = urlString.contains("?") ? "&" : "?"
101
106
  let timestamp = Int(Date().timeIntervalSince1970 * 1000)
102
107
  self.options?["url"] = urlString + sign + "ts=\(timestamp)"
@@ -185,7 +190,7 @@ import Capacitor
185
190
  return false
186
191
  }
187
192
 
188
- if url.contains("aigens=true") || url.contains("aigens/true") {
193
+ if url.contains("aigens=true") || url.contains("aigens/true") || url.contains("aigensRedirect/") {
189
194
  return true;
190
195
  }
191
196
  if !universalLink.isEmpty && url.contains(universalLink) {
@@ -197,12 +202,25 @@ import Capacitor
197
202
  return false;
198
203
  }
199
204
 
200
- private func fromAppUrl(_ url_: URL) {
205
+ private func isParseUrl2(_ url: String) -> Bool {
206
+
207
+ if isExcludedUniversalLink(url) {
208
+ return false
209
+ }
210
+ let contain = url.contains("alwayscheck=true") || url.contains("alwayscheck/true");
211
+ return contain
212
+ }
213
+
214
+ private func fromAppUrl(_ url_: URL, _ alwayscheck: Bool = false) -> Bool {
201
215
  let url = decodeURIComponent(url_);
202
216
 
203
217
 
204
- if !isParseUrl(url.absoluteString) {
205
- return;
218
+ if !alwayscheck && !isParseUrl(url.absoluteString) {
219
+ return false;
220
+ }
221
+
222
+ if alwayscheck && !isParseUrl2(url.absoluteString) {
223
+ return false;
206
224
  }
207
225
 
208
226
  let rUrl = URLRequest(url: url)
@@ -229,12 +247,13 @@ import Capacitor
229
247
  webContainerView.showError(false)
230
248
  let rUrl = URLRequest(url: redirectUrl)
231
249
  webView?.load(rUrl)
232
- return;
250
+ return true;
233
251
  }
234
252
 
235
253
  webContainerView.showLoading(true)
236
254
  webContainerView.showError(false)
237
255
  webView?.load(rUrl)
256
+ return true;
238
257
  }
239
258
 
240
259
  @objc func handleUrlOpened(notification: NSNotification) {
@@ -492,6 +511,11 @@ extension WebContainerViewController: WKNavigationDelegate {
492
511
  return;
493
512
  }
494
513
 
514
+ if (fromAppUrl(navURL, true)) {
515
+ decisionHandler(.cancel)
516
+ return;
517
+ }
518
+
495
519
  // if isParseUrl(navURL.absoluteString) {
496
520
  //
497
521
  // 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.2",
3
+ "version": "5.0.4",
4
4
  "description": "Aigens Order.Place Core Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",