From cc362df8212db56131e15ff976d7871d17c52787 Mon Sep 17 00:00:00 2001 From: Daniele Perucca Date: Wed, 6 Sep 2023 10:14:43 +0200 Subject: [PATCH] core/v1.5.6 + showScreesent no modal --- GigyaSwift.xcodeproj/project.pbxproj | 4 ++-- GigyaSwift/Gigya/GigyaCore.swift | 4 ++-- .../Global/Api/BusinessApiService.swift | 3 ++- .../Global/Plugins/GigyaWebBridge.swift | 8 ++++--- .../Global/Plugins/PluginViewWrapper.swift | 23 +++++++++++++++---- GigyaSwift/Models/Config/InternalConfig.swift | 2 +- .../Network/Service/NetworkProvider.swift | 3 +++ 7 files changed, 33 insertions(+), 14 deletions(-) diff --git a/GigyaSwift.xcodeproj/project.pbxproj b/GigyaSwift.xcodeproj/project.pbxproj index 34f23b74..d4650fba 100644 --- a/GigyaSwift.xcodeproj/project.pbxproj +++ b/GigyaSwift.xcodeproj/project.pbxproj @@ -2590,7 +2590,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.5.5; + MARKETING_VERSION = 1.5.6; MODULEMAP_FILE = ""; MODULEMAP_PRIVATE_FILE = ""; ONLY_ACTIVE_ARCH = NO; @@ -2651,7 +2651,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 1.5.5; + MARKETING_VERSION = 1.5.6; MODULEMAP_FILE = ""; MODULEMAP_PRIVATE_FILE = ""; ONLY_ACTIVE_ARCH = NO; diff --git a/GigyaSwift/Gigya/GigyaCore.swift b/GigyaSwift/Gigya/GigyaCore.swift index 122745b9..c77f4ef2 100644 --- a/GigyaSwift/Gigya/GigyaCore.swift +++ b/GigyaSwift/Gigya/GigyaCore.swift @@ -444,11 +444,11 @@ public final class GigyaCore: GigyaInstanceProtocol { - Parameter completion: Plugin completion `GigyaPluginEvent`. */ - public func showScreenSet(with name: String, viewController: UIViewController, params: [String: Any] = [:], completion: @escaping (GigyaPluginEvent) -> Void) { + public func showScreenSet(with name: String, viewController: UIViewController, params: [String: Any] = [:], isModal: Bool = true, completion: @escaping (GigyaPluginEvent) -> Void) { let webBridge = createWebBridge() pluginViewWrapper = PluginViewWrapper(config: config, persistenceService: persistenceService, sessionService: sessionService, businessApiService: businessApiService, webBridge: webBridge, plugin: "accounts.screenSet", params: params, completion: completion) - pluginViewWrapper?.presentPluginController(viewController: viewController, dataType: T.self, screenSet: name) + pluginViewWrapper?.presentPluginController(viewController: viewController, dataType: T.self, screenSet: name, isModal: isModal) } // MARK: - Interruptions diff --git a/GigyaSwift/Global/Api/BusinessApiService.swift b/GigyaSwift/Global/Api/BusinessApiService.swift index 1525527e..383fc7e1 100644 --- a/GigyaSwift/Global/Api/BusinessApiService.swift +++ b/GigyaSwift/Global/Api/BusinessApiService.swift @@ -311,9 +311,10 @@ class BusinessApiService: NSObject, BusinessApiServiceProtocol { GigyaLogger.log(with: self, message: "[finalizeRegistration] - params: \(params)") - send(dataType: T.self, api: GigyaDefinitions.API.finalizeRegistration, params: params) { result in + send(dataType: T.self, api: GigyaDefinitions.API.finalizeRegistration, params: params) { [weak accountService] result in switch result { case .success(let data): + accountService?.account = data completion(.success(data: data)) GigyaLogger.log(with: BusinessApiService.self, message: "[finalizeRegistration] - success") diff --git a/GigyaSwift/Global/Plugins/GigyaWebBridge.swift b/GigyaSwift/Global/Plugins/GigyaWebBridge.swift index f265ca58..32711899 100644 --- a/GigyaSwift/Global/Plugins/GigyaWebBridge.swift +++ b/GigyaSwift/Global/Plugins/GigyaWebBridge.swift @@ -85,9 +85,11 @@ final public class GigyaWebBridge: NSObject, WKScriptMe GigyaLogger.log(with: self, message: "JS Interface:\n\(JSInterface)") - if #available(iOS 16.4, *), GigyaLogger.isDebug() { - self.webView?.isInspectable = true - } + #if compiler(>=5.8) && DEBUG + if #available(iOS 16.4, *), GigyaLogger.isDebug() { + self.webView?.isInspectable = true + } + #endif } diff --git a/GigyaSwift/Global/Plugins/PluginViewWrapper.swift b/GigyaSwift/Global/Plugins/PluginViewWrapper.swift index 76ef6a8c..2cbecd6d 100644 --- a/GigyaSwift/Global/Plugins/PluginViewWrapper.swift +++ b/GigyaSwift/Global/Plugins/PluginViewWrapper.swift @@ -9,7 +9,7 @@ import UIKit protocol PluginViewWrapperProtocol { - func presentPluginController(viewController: UIViewController, dataType: T.Type, screenSet: String?) + func presentPluginController(viewController: UIViewController, dataType: T.Type, screenSet: String?, isModal: Bool) } class PluginViewWrapper: PluginViewWrapperProtocol { @@ -51,7 +51,7 @@ class PluginViewWrapper: PluginViewWrapperProtocol { - Parameter dataType: Account schema. - Parameter screenSet: Requested screen set. */ - func presentPluginController(viewController: UIViewController, dataType: C.Type, screenSet: String? = nil) { + func presentPluginController(viewController: UIViewController, dataType: C.Type, screenSet: String? = nil, isModal: Bool) { if let screenSet = screenSet { params["screenSet"] = screenSet } @@ -85,9 +85,22 @@ class PluginViewWrapper: PluginViewWrapperProtocol { pluginViewController = PluginViewController(webBridge: webBridge, pluginEvent: eventHandler!) - let navigationController = UINavigationController(rootViewController: pluginViewController!) - - viewController.present(navigationController, animated: true) { + if(isModal) { + let navigationController = UINavigationController(rootViewController: pluginViewController!) + viewController.present(navigationController, animated: true) { + self.webBridge?.load(html: html) + } + } + else { + viewController.addChild(pluginViewController!); + viewController.view.addSubview(pluginViewController!.view); + + pluginViewController!.view.translatesAutoresizingMaskIntoConstraints = false; + pluginViewController!.view.topAnchor.constraint(equalTo:viewController.view.topAnchor, constant: 0).isActive = true + pluginViewController!.view.bottomAnchor.constraint(equalTo:viewController.view.bottomAnchor, constant: 0).isActive = true + pluginViewController!.view.leadingAnchor.constraint(equalTo:viewController.view.leadingAnchor, constant: 0).isActive = true + pluginViewController!.view.trailingAnchor.constraint(equalTo:viewController.view.trailingAnchor, constant: 0).isActive = true + self.webBridge?.load(html: html) } } diff --git a/GigyaSwift/Models/Config/InternalConfig.swift b/GigyaSwift/Models/Config/InternalConfig.swift index cd2c65b6..446548f0 100644 --- a/GigyaSwift/Models/Config/InternalConfig.swift +++ b/GigyaSwift/Models/Config/InternalConfig.swift @@ -10,7 +10,7 @@ import Foundation struct InternalConfig { struct General { - internal static let version = "\(GigyaDefinitions.versionPrefix ?? "")ios_swift_1.5.5" + internal static let version = "\(GigyaDefinitions.versionPrefix ?? "")ios_swift_1.5.6" internal static let sdkDomain = "com.gigya.GigyaSDK" internal static let defaultLang = "en" } diff --git a/GigyaSwift/Network/Service/NetworkProvider.swift b/GigyaSwift/Network/Service/NetworkProvider.swift index db2c9e53..b972f68c 100644 --- a/GigyaSwift/Network/Service/NetworkProvider.swift +++ b/GigyaSwift/Network/Service/NetworkProvider.swift @@ -56,6 +56,9 @@ final class NetworkProvider { } } + // Add apikey to header + request.setValue(config?.apiKey, forHTTPHeaderField: "apikey") + request.timeoutInterval = TimeInterval(config?.requestTimeout ?? InternalConfig.Network.requestTimeoutDefult) // Encode body request to params