diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ef9d29..3de5891 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Features + +- Users now receive an event when the navigation occurs (for openInWebView option only) (https://outsystemsrd.atlassian.net/browse/RMET-4122). + +### Fixes + +- **BREAKING:** Fix an issue where the application freezes when 'OpenInExternalBrowser' is called + ## 1.0.0 ### Features diff --git a/OSInAppBrowserLib.podspec b/OSInAppBrowserLib.podspec index 6928ff0..34e2747 100644 --- a/OSInAppBrowserLib.podspec +++ b/OSInAppBrowserLib.podspec @@ -22,8 +22,9 @@ Pod::Spec.new do |spec| spec.author = { 'OutSystems Mobile Ecosystem' => 'rd.mobileecosystem.team@outsystems.com' } spec.source = { :http => "https://github.com/OutSystems/OSInAppBrowserLib-iOS/releases/download/#{spec.version}/OSInAppBrowserLib.zip", :type => "zip" } + spec.source_files = "OSInAppBrowserLib/**/*" spec.vendored_frameworks = "OSInAppBrowserLib.xcframework" spec.ios.deployment_target = '13.0' spec.swift_versions = ['5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7', '5.8', '5.9'] -end \ No newline at end of file +end diff --git a/OSInAppBrowserLib.xcodeproj/project.pbxproj b/OSInAppBrowserLib.xcodeproj/project.pbxproj index 4a7cd51..aba9b40 100644 --- a/OSInAppBrowserLib.xcodeproj/project.pbxproj +++ b/OSInAppBrowserLib.xcodeproj/project.pbxproj @@ -26,9 +26,7 @@ 754451F62C04AB69003D7361 /* OSIABViewStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754451F52C04AB69003D7361 /* OSIABViewStyle.swift */; }; 754451FB2C04C76C003D7361 /* OSIABAnimationEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754451FA2C04C76C003D7361 /* OSIABAnimationEffect.swift */; }; 754451FD2C04D38D003D7361 /* OSIABSystemBrowserOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754451FC2C04D38D003D7361 /* OSIABSystemBrowserOptions.swift */; }; - 756346462C00D6DD00685AA3 /* OSApplicationStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756346452C00D6DD00685AA3 /* OSApplicationStub.swift */; }; 756346482C00DD4700685AA3 /* OSIABSafariViewControllerRouterAdapterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756346472C00DD4600685AA3 /* OSIABSafariViewControllerRouterAdapterTests.swift */; }; - 7563464A2C00DE1300685AA3 /* OSIABApplicationRouterAdapterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756346492C00DE1300685AA3 /* OSIABApplicationRouterAdapterTests.swift */; }; 756346622C00F21000685AA3 /* OSIABRouter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7563465D2C00F21000685AA3 /* OSIABRouter.swift */; }; 756346632C00F21000685AA3 /* OSIABSafariViewControllerRouterAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7563465F2C00F21000685AA3 /* OSIABSafariViewControllerRouterAdapter.swift */; }; 756346642C00F21000685AA3 /* OSIABApplicationRouterAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 756346602C00F21000685AA3 /* OSIABApplicationRouterAdapter.swift */; }; @@ -74,9 +72,7 @@ 754451F52C04AB69003D7361 /* OSIABViewStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIABViewStyle.swift; sourceTree = ""; }; 754451FA2C04C76C003D7361 /* OSIABAnimationEffect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIABAnimationEffect.swift; sourceTree = ""; }; 754451FC2C04D38D003D7361 /* OSIABSystemBrowserOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIABSystemBrowserOptions.swift; sourceTree = ""; }; - 756346452C00D6DD00685AA3 /* OSApplicationStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSApplicationStub.swift; sourceTree = ""; }; 756346472C00DD4600685AA3 /* OSIABSafariViewControllerRouterAdapterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIABSafariViewControllerRouterAdapterTests.swift; sourceTree = ""; }; - 756346492C00DE1300685AA3 /* OSIABApplicationRouterAdapterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSIABApplicationRouterAdapterTests.swift; sourceTree = ""; }; 7563465D2C00F21000685AA3 /* OSIABRouter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSIABRouter.swift; sourceTree = ""; }; 7563465F2C00F21000685AA3 /* OSIABSafariViewControllerRouterAdapter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSIABSafariViewControllerRouterAdapter.swift; sourceTree = ""; }; 756346602C00F21000685AA3 /* OSIABApplicationRouterAdapter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OSIABApplicationRouterAdapter.swift; sourceTree = ""; }; @@ -213,7 +209,6 @@ isa = PBXGroup; children = ( 7575CF7E2BFCEEEA008F3FD0 /* Helper Files */, - 756346492C00DE1300685AA3 /* OSIABApplicationRouterAdapterTests.swift */, 75EF1AFC2C1306B1005D7164 /* OSIABCacheManagerTests.swift */, 7575CF7D2BFCEEEA008F3FD0 /* OSIABEngineTests.swift */, 756346472C00DD4600685AA3 /* OSIABSafariViewControllerRouterAdapterTests.swift */, @@ -227,7 +222,6 @@ isa = PBXGroup; children = ( 7575CF7F2BFCEEEA008F3FD0 /* OSIABRouterSpy.swift */, - 756346452C00D6DD00685AA3 /* OSApplicationStub.swift */, 75094A062C121BD9006843E1 /* OSIABCacheManagerStub.swift */, 75EF1B002C134878005D7164 /* OSIABWebViewStub.swift */, ); @@ -399,10 +393,8 @@ files = ( 756346482C00DD4700685AA3 /* OSIABSafariViewControllerRouterAdapterTests.swift in Sources */, 75EF1AFB2C13069E005D7164 /* OSIABViewModelTests.swift in Sources */, - 7563464A2C00DE1300685AA3 /* OSIABApplicationRouterAdapterTests.swift in Sources */, 7575CF812BFCEEEA008F3FD0 /* OSIABRouterSpy.swift in Sources */, 75094A072C121BD9006843E1 /* OSIABCacheManagerStub.swift in Sources */, - 756346462C00D6DD00685AA3 /* OSApplicationStub.swift in Sources */, 75EF1AFD2C1306B1005D7164 /* OSIABCacheManagerTests.swift in Sources */, 7575CF802BFCEEEA008F3FD0 /* OSIABEngineTests.swift in Sources */, 75EF1B012C134878005D7164 /* OSIABWebViewStub.swift in Sources */, diff --git a/OSInAppBrowserLib/RouterAdapters/OSIABApplicationRouterAdapter.swift b/OSInAppBrowserLib/RouterAdapters/OSIABApplicationRouterAdapter.swift index c28ce3a..2c54194 100644 --- a/OSInAppBrowserLib/RouterAdapters/OSIABApplicationRouterAdapter.swift +++ b/OSInAppBrowserLib/RouterAdapters/OSIABApplicationRouterAdapter.swift @@ -1,37 +1,14 @@ import UIKit -/// Protocol to be implemented by the objects that can handle opening URLs. -/// This is implemented by the `UIApplication` object that can be used as an External Browser. -public protocol OSIABApplicationDelegate: AnyObject { - func canOpenURL(_ url: URL) -> Bool - func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey: Any], completionHandler completion: ((Bool) -> Void)?) -} - -/// Provide a default implementations that abstracts the options parameter. -extension OSIABApplicationDelegate { - public func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey: Any] = [:], completionHandler completion: ((Bool) -> Void)?) { - self.open(url, options: options, completionHandler: completion) - } -} - -/// Make `UIApplication` conform to the `OSIABApplicationDelegate` protocol. -extension UIApplication: OSIABApplicationDelegate {} - -/// Adapter that makes the required calls so that an `OSIABApplicationDelegate` implementation can perform the External Browser routing. +/// Adapter that makes the required calls so that can perform the External Browser routing. public class OSIABApplicationRouterAdapter: OSIABRouter { public typealias ReturnType = Bool - - /// The object that will performing the URL opening. - private let application: OSIABApplicationDelegate - + /// Constructor method. - /// - Parameter application: The object that will performing the URL opening. - public init(_ application: OSIABApplicationDelegate) { - self.application = application - } + public init() {} public func handleOpen(_ url: URL, _ completionHandler: @escaping (ReturnType) -> Void) { - guard self.application.canOpenURL(url) else { return completionHandler(false) } - self.application.open(url, completionHandler: completionHandler) + guard UIApplication.shared.canOpenURL(url) else { return completionHandler(false) } + UIApplication.shared.open(url, completionHandler: completionHandler) } } diff --git a/OSInAppBrowserLibTests/Helper Files/OSApplicationStub.swift b/OSInAppBrowserLibTests/Helper Files/OSApplicationStub.swift deleted file mode 100644 index 6478875..0000000 --- a/OSInAppBrowserLibTests/Helper Files/OSApplicationStub.swift +++ /dev/null @@ -1,20 +0,0 @@ -import OSInAppBrowserLib -import UIKit - -class OSApplicationStub: NSObject, OSIABApplicationDelegate { - private let useValidURL: Bool - private let ableToOpenURL: Bool - - init(_ useValidURL: Bool, _ ableToOpenURL: Bool) { - self.useValidURL = useValidURL - self.ableToOpenURL = ableToOpenURL - } - - func canOpenURL(_ url: URL) -> Bool { - return useValidURL - } - - func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey: Any], completionHandler completion: ((Bool) -> Void)?) { - completion?(ableToOpenURL) - } -} diff --git a/OSInAppBrowserLibTests/OSIABApplicationRouterAdapterTests.swift b/OSInAppBrowserLibTests/OSIABApplicationRouterAdapterTests.swift deleted file mode 100644 index ed1ba09..0000000 --- a/OSInAppBrowserLibTests/OSIABApplicationRouterAdapterTests.swift +++ /dev/null @@ -1,27 +0,0 @@ -import OSInAppBrowserLib -import XCTest - -final class OSIABApplicationRouterAdapterTests: XCTestCase { - let url = URL(string: "https://www.outsystems.com/")! - - func test_handleOpen_withInvalidURL_returnsFalse() { - let sut = makeSUT(useValidURL: false) - sut.handleOpen(url) { XCTAssertFalse($0) } - } - - func test_handleOpen_withValidButNotAbleToOpenItL_returnsFalse() { - let sut = makeSUT(useValidURL: true, ableToOpenURL: false) - sut.handleOpen(url) { XCTAssertFalse($0) } - } - - func test_handleOpen_withValidAndAbleToOpenItL_returnsTrue() { - let sut = makeSUT(useValidURL: true, ableToOpenURL: true) - sut.handleOpen(url) { XCTAssertTrue($0) } - } -} - -private extension OSIABApplicationRouterAdapterTests { - func makeSUT(useValidURL: Bool, ableToOpenURL: Bool = false) -> OSIABApplicationRouterAdapter { - return .init(OSApplicationStub(useValidURL, ableToOpenURL)) - } -} diff --git a/README.md b/README.md index 198b3bb..d833e94 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ func openExternalBrowser(_ url: URL, routerDelegate: ExternalBrowser, _ completi Uses the parameter `routerDelegate` - an object that offers an External Browser interface - to open the parameter `url`. The method is composed of the following input parameters: - **url**: the URL for the web page to be opened. -- **routerDelegate**: The External Browser interface that will open the URL. Its return type should be `Bool`. The library provides an `OSIABApplicationRouterAdapter` class that allows a class that implements `OSIABApplicationDelegate` (like `UIApplication`, that uses the device's default browser) to open it. +- **routerDelegate**: The External Browser interface that will open the URL. Its return type should be `Bool`. - **completionHandler**: The callback with the result of opening the URL with the External Browser interface. ### Open a URL in a System Browser @@ -84,4 +84,4 @@ func openWebView(_ url: URL, routerDelegate: WebView, _ completionHandler: @esca Uses the parameter `routerDelegate` - an object that offers a Web View interface - to open the parameter `url`. The method is composed of the following input parameters: - **url**: the URL for the web page to be opened. - **routerDelegate**: The Web View interface that will open the URL. Its return type should be `UIViewController` or a subclass. The library provides an `OSIABWebViewRouterAdapter` class that uses `WKWebView` to open it. -- **completionHandler**: The callback with the result of opening the URL with the Web View interface. \ No newline at end of file +- **completionHandler**: The callback with the result of opening the URL with the Web View interface.