From c478d3c82ae2f553fca660e362975c2d411df7b3 Mon Sep 17 00:00:00 2001 From: Marcos Rivereto Date: Mon, 28 Oct 2024 15:25:09 -0300 Subject: [PATCH 1/3] Change where notifications are created and destroyed. --- Sources/TrustlySDK/TrustlyView.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/TrustlySDK/TrustlyView.swift b/Sources/TrustlySDK/TrustlyView.swift index 206f7bc..ab1a777 100644 --- a/Sources/TrustlySDK/TrustlyView.swift +++ b/Sources/TrustlySDK/TrustlyView.swift @@ -85,7 +85,6 @@ public class TrustlyView : UIView, TrustlyProtocol, WKNavigationDelegate, WKScri } func initView() { - self.createNotifications() if let tempCid = generateCid() { cid = tempCid @@ -181,6 +180,8 @@ public class TrustlyView : UIView, TrustlyProtocol, WKNavigationDelegate, WKScri public func establish(establishData eD: [AnyHashable : Any], onReturn: TrustlyCallback?, onCancel: TrustlyCallback?) -> UIView? { establishData = eD + self.createNotifications() + self.addSessionCid() let deviceType = establishData?["deviceType"] ?? "mobile" + ":ios:native" @@ -643,6 +644,9 @@ extension TrustlyView { } @objc func closeWebview(notification: Notification){ + + NotificationCenter.default.removeObserver(self, name: .trustlyCloseWebview, object: nil) + if webSession != nil { webSession.cancel() } From 9ead2a1ad8d9f4f9bc2c4e8292d6f4834f3b0e79 Mon Sep 17 00:00:00 2001 From: Marcos Rivereto Date: Mon, 28 Oct 2024 15:32:05 -0300 Subject: [PATCH 2/3] Add sleep in the process to proceed to choose account. --- Sources/TrustlySDK/TrustlyView.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/TrustlySDK/TrustlyView.swift b/Sources/TrustlySDK/TrustlyView.swift index ab1a777..8c35aa7 100644 --- a/Sources/TrustlySDK/TrustlyView.swift +++ b/Sources/TrustlySDK/TrustlyView.swift @@ -635,7 +635,9 @@ extension TrustlyView { } private func proceedToChooseAccount(){ - self.mainWebView.evaluateJavaScript("window.Trustly.proceedToChooseAccount();", completionHandler: nil) + DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { + self.mainWebView.evaluateJavaScript("window.Trustly.proceedToChooseAccount();", completionHandler: nil) + } } // MARK: - Utility Functions From 0bba538e58e7d3c3c1c42381da78b53e64ff5092 Mon Sep 17 00:00:00 2001 From: Marcos Rivereto Date: Mon, 28 Oct 2024 15:37:54 -0300 Subject: [PATCH 3/3] Add hard coded port for local environment. --- Sources/TrustlySDK/TrustlyView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/TrustlySDK/TrustlyView.swift b/Sources/TrustlySDK/TrustlyView.swift index 8c35aa7..0592d6f 100644 --- a/Sources/TrustlySDK/TrustlyView.swift +++ b/Sources/TrustlySDK/TrustlyView.swift @@ -504,7 +504,7 @@ public class TrustlyView : UIView, TrustlyProtocol, WKNavigationDelegate, WKScri } if ("local" == env), let urlLocal = localUrl { - url = "http://"+urlLocal+"/start/selectBank/"+fn+"?v="+build+"-ios-sdk" + url = "http://"+urlLocal+":8000/start/selectBank/"+fn+"?v="+build+"-ios-sdk" isLocalEnvironment = true } else {