@aigens/aigens-sdk-core 0.4.3 → 0.4.5

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.
@@ -124,11 +124,12 @@ public class WebContainerActivity extends BridgeActivity {
124
124
  // Log.i("getRedirectUrl", totalUrl);
125
125
  if (redirectUrl != null) {
126
126
  redirectUrl = this.decodeURIComponent(redirectUrl);
127
+ Log.i("Jason redirectUrl", redirectUrl);
127
128
  }
128
- if (!redirectUrl.startsWith("http://") && !redirectUrl.startsWith("https://")) {
129
+ if (redirectUrl != null && !redirectUrl.startsWith("http://") && !redirectUrl.startsWith("https://")) {
129
130
  redirectUrl = "https://" + redirectUrl;
130
131
  }
131
- Log.i("Jason redirectUrl", redirectUrl);
132
+
132
133
  return redirectUrl;
133
134
  } else {
134
135
  // Log.i("getRedirectUrl", "null");
@@ -146,17 +146,8 @@ import Capacitor
146
146
  return false;
147
147
  }
148
148
 
149
- @objc func handleUrlOpened(notification: NSNotification) {
150
- guard let object = notification.object as? [String: Any?] else {
151
- return
152
- }
153
-
154
- aigensprint("handleUrlOpened url:\(object)")
155
- guard var url = object["url"] as? URL else {
156
- return
157
- }
158
-
159
- url = decodeURIComponent(url);
149
+ private func fromAppUrl(_ url_: URL) {
150
+ let url = decodeURIComponent(url_);
160
151
 
161
152
 
162
153
  if !isParseUrl(url.absoluteString) {
@@ -166,51 +157,59 @@ import Capacitor
166
157
  let rUrl = URLRequest(url: url)
167
158
 
168
159
  let newUrl = url;
169
- if newUrl.absoluteString.range(of: "redirect=") != nil, let redirect = newUrl.absoluteString.components(separatedBy:"redirect=").last, !redirect.isEmpty {
170
- aigensprint("handleUniversalLink has -- redirect:\(redirect)")
171
- webContainerView.showLoading(true)
172
- webContainerView.showError(false)
173
- }else if newUrl.absoluteString.range(of: "aigensRedirect/") != nil, let redirect = newUrl.absoluteString.components(separatedBy:"aigensRedirect/").last, !redirect.isEmpty {
174
- aigensprint("handleUniversalLink has -- aigensRedirect:\(redirect)")
160
+ var redirectUrl: String? = nil;
161
+ if newUrl.absoluteString.range(of: "redirect=") != nil, var redirect = newUrl.absoluteString.components(separatedBy:"redirect=").last, !redirect.isEmpty {
162
+ if !redirect.starts(with: "http://") && !redirect.starts(with: "https://") {
163
+ redirect = "https://" + redirect
164
+ }
165
+ redirectUrl = redirect;
166
+ aigensprint("handleUniversalLink has -- redirect:\(redirect)");
167
+ }else if newUrl.absoluteString.range(of: "aigensRedirect/") != nil, var redirect = newUrl.absoluteString.components(separatedBy:"aigensRedirect/").last, !redirect.isEmpty {
168
+ if !redirect.starts(with: "http://") && !redirect.starts(with: "https://") {
169
+ redirect = "https://" + redirect
170
+ }
171
+ redirectUrl = redirect;
172
+ aigensprint("handleUniversalLink has -- aigensRedirect:\(redirect)");
173
+ }
174
+
175
+ if let redirect = redirectUrl, let redirectUrl = URL(string: redirect) {
176
+ self.redirectLink = redirect
175
177
  webContainerView.showLoading(true)
176
178
  webContainerView.showError(false)
179
+ let rUrl = URLRequest(url: redirectUrl)
180
+ webView?.load(rUrl)
181
+ return;
177
182
  }
178
183
 
184
+ webContainerView.showLoading(true)
185
+ webContainerView.showError(false)
179
186
  webView?.load(rUrl)
180
187
  }
181
188
 
182
- @objc func handleUniversalLink(notification: NSNotification) {
189
+ @objc func handleUrlOpened(notification: NSNotification) {
183
190
  guard let object = notification.object as? [String: Any?] else {
184
191
  return
185
192
  }
186
193
 
187
- aigensprint("handleUniversalLink url:\(object)")
194
+ aigensprint("handleUrlOpened url:\(object)")
188
195
  guard var url = object["url"] as? URL else {
189
196
  return
190
197
  }
191
198
 
192
- url = decodeURIComponent(url);
199
+ fromAppUrl(url);
200
+ }
193
201
 
194
- if !isParseUrl(url.absoluteString) {
195
- return;
202
+ @objc func handleUniversalLink(notification: NSNotification) {
203
+ guard let object = notification.object as? [String: Any?] else {
204
+ return
196
205
  }
197
206
 
198
-
199
- let rUrl = URLRequest(url: url)
200
-
201
- let newUrl = url;
202
- if newUrl.absoluteString.range(of: "redirect=") != nil, let redirect = newUrl.absoluteString.components(separatedBy:"redirect=").last, !redirect.isEmpty {
203
- aigensprint("handleUniversalLink has -- redirect:\(redirect)")
204
- webContainerView.showLoading(true)
205
- webContainerView.showError(false)
206
- }else if newUrl.absoluteString.range(of: "aigensRedirect/") != nil, let redirect = newUrl.absoluteString.components(separatedBy:"aigensRedirect/").last, !redirect.isEmpty {
207
- aigensprint("handleUniversalLink has -- aigensRedirect:\(redirect)")
208
- webContainerView.showLoading(true)
209
- webContainerView.showError(false)
207
+ aigensprint("handleUniversalLink url:\(object)")
208
+ guard var url = object["url"] as? URL else {
209
+ return
210
210
  }
211
211
 
212
-
213
- webView?.load(rUrl)
212
+ fromAppUrl(url);
214
213
 
215
214
  }
216
215
  private func initView(){
@@ -397,41 +396,6 @@ extension WebContainerViewController: WKNavigationDelegate {
397
396
  }
398
397
 
399
398
  aigensprint("navURL--:\(navURL)")
400
- if isParseUrl(navURL.absoluteString) {
401
-
402
- if navURL.absoluteString.range(of: "redirect=") != nil, var redirect = navURL.absoluteString.components(separatedBy:"redirect=").last{
403
- if !redirect.starts(with: "http://") && !redirect.starts(with: "https://") {
404
- redirect = "https://" + redirect
405
- }
406
- if let redirectUrl = URL(string: redirect) {
407
- self.redirectLink = redirect
408
- aigensprint("navURL-- redirect:\(redirect)")
409
- webContainerView.showLoading(true)
410
- webContainerView.showError(false)
411
- let rUrl = URLRequest(url: redirectUrl)
412
- webView.load(rUrl)
413
- decisionHandler(.cancel)
414
- return;
415
- }
416
- }
417
-
418
- if navURL.absoluteString.range(of: "aigensRedirect/") != nil, var redirect = navURL.absoluteString.components(separatedBy:"aigensRedirect/").last, !redirect.isEmpty{
419
- if !redirect.starts(with: "http://") && !redirect.starts(with: "https://") {
420
- redirect = "https://" + redirect
421
- }
422
- if let redirectUrl = URL(string: redirect) {
423
- self.redirectLink = redirect
424
- aigensprint("navURL-- aigensRedirect:\(redirect)")
425
- webContainerView.showLoading(true)
426
- webContainerView.showError(false)
427
- let rUrl = URLRequest(url: redirectUrl)
428
- webView.load(rUrl)
429
- decisionHandler(.cancel)
430
- return;
431
- }
432
- }
433
-
434
- }
435
399
 
436
400
  var isCanOpen = false
437
401
  if externalProtocols.count > 0 {
@@ -453,6 +417,43 @@ extension WebContainerViewController: WKNavigationDelegate {
453
417
  return;
454
418
  }
455
419
 
420
+ // if isParseUrl(navURL.absoluteString) {
421
+ //
422
+ // if navURL.absoluteString.range(of: "redirect=") != nil, var redirect = navURL.absoluteString.components(separatedBy:"redirect=").last{
423
+ // if !redirect.starts(with: "http://") && !redirect.starts(with: "https://") {
424
+ // redirect = "https://" + redirect
425
+ // }
426
+ // if let redirectUrl = URL(string: redirect) {
427
+ // self.redirectLink = redirect
428
+ // aigensprint("navURL-- redirect:\(redirect)")
429
+ // webContainerView.showLoading(true)
430
+ // webContainerView.showError(false)
431
+ // let rUrl = URLRequest(url: redirectUrl)
432
+ // webView.load(rUrl)
433
+ // decisionHandler(.cancel)
434
+ // return;
435
+ // }
436
+ // }
437
+ //
438
+ // if navURL.absoluteString.range(of: "aigensRedirect/") != nil, var redirect = navURL.absoluteString.components(separatedBy:"aigensRedirect/").last, !redirect.isEmpty{
439
+ // if !redirect.starts(with: "http://") && !redirect.starts(with: "https://") {
440
+ // redirect = "https://" + redirect
441
+ // }
442
+ // if let redirectUrl = URL(string: redirect) {
443
+ // self.redirectLink = redirect
444
+ // aigensprint("navURL-- aigensRedirect:\(redirect)")
445
+ // webContainerView.showLoading(true)
446
+ // webContainerView.showError(false)
447
+ // let rUrl = URLRequest(url: redirectUrl)
448
+ // webView.load(rUrl)
449
+ // decisionHandler(.cancel)
450
+ // return;
451
+ // }
452
+ // }
453
+ //
454
+ // }
455
+
456
+
456
457
 
457
458
  // first, give plugins the chance to handle the decision
458
459
  // for pluginObject in bridge.plugins {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigens/aigens-sdk-core",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Aigens Order.Place Core Plugin",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",