diff --git a/Example/CreativeUITest/CreativeUITest.swift b/Example/CreativeUITest/CreativeUITest.swift index 12bc7d3..52536b3 100644 --- a/Example/CreativeUITest/CreativeUITest.swift +++ b/Example/CreativeUITest/CreativeUITest.swift @@ -67,7 +67,7 @@ final class CreativeUITest: XCTestCase, BaseXCTestCase { HomePage.tapOnPushMeToCreative() CreativePage - .addDelay(seconds: 1) + .addDelay(seconds: 3) .tapOnPrivacyLink() guard canLaunchExternalApps else { return } diff --git a/Example/CreativeUITest/Pages/CreativePage.swift b/Example/CreativeUITest/Pages/CreativePage.swift index 1c545f5..761e653 100644 --- a/Example/CreativeUITest/Pages/CreativePage.swift +++ b/Example/CreativeUITest/Pages/CreativePage.swift @@ -78,7 +78,7 @@ fileprivate extension CreativePage { } static var privacyLink: XCUIElement { - app.webViews.links["Privacy"] + app.webViews.links["Privacy link will open in a new tab"] } static var debugStaticText: XCUIElement { diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index e6f9499..2b5c99c 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -451,7 +451,7 @@ INFOPLIST_KEY_UIStatusBarStyle = ""; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -482,7 +482,7 @@ INFOPLIST_KEY_UIStatusBarStyle = ""; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -626,7 +626,7 @@ INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -661,7 +661,7 @@ INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Example/Podfile b/Example/Podfile index 5ae872b..941d6e7 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,4 +1,4 @@ -platform :ios, '10.0' +platform :ios, '14.0' target 'Example - Pod' do # The 'use_frameworks!' option builds the pods as dynamic frameworks instead of static libs. diff --git a/ExampleSwift/ExampleSwift.xcodeproj/project.pbxproj b/ExampleSwift/ExampleSwift.xcodeproj/project.pbxproj index 992980c..95b6ecb 100644 --- a/ExampleSwift/ExampleSwift.xcodeproj/project.pbxproj +++ b/ExampleSwift/ExampleSwift.xcodeproj/project.pbxproj @@ -417,7 +417,7 @@ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 12.6; @@ -460,7 +460,7 @@ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 12.6; @@ -503,7 +503,7 @@ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 12.6; @@ -548,7 +548,7 @@ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 12.6; @@ -604,8 +604,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/attentive-mobile/attentive-ios-sdk"; requirement = { - branch = main; - kind = branch; + kind = upToNextMajorVersion; + minimumVersion = 1.0.0; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/Sources/Public/SDK/ATTNSDK.swift b/Sources/Public/SDK/ATTNSDK.swift index c572175..fea0754 100644 --- a/Sources/Public/SDK/ATTNSDK.swift +++ b/Sources/Public/SDK/ATTNSDK.swift @@ -12,7 +12,16 @@ public typealias ATTNCreativeTriggerCompletionHandler = (String) -> Void @objc(ATTNSDK) public final class ATTNSDK: NSObject { - var isCreativeOpen = false + static var _isCreativeOpen: Bool = false + + var isCreativeOpen: Bool { + get { + ATTNSDK._isCreativeOpen + } + set { + ATTNSDK._isCreativeOpen = newValue + } + } // MARK: Instance Properties var parentView: UIView? diff --git a/Tests/TestCases/ATTNSDKTests.swift b/Tests/TestCases/ATTNSDKTests.swift index 0e3c6b2..d34c60f 100644 --- a/Tests/TestCases/ATTNSDKTests.swift +++ b/Tests/TestCases/ATTNSDKTests.swift @@ -108,5 +108,22 @@ final class ATTNSDKTests: XCTestCase { XCTAssertTrue(creativeUrlProviderSpy.buildCompanyCreativeUrlWasCalled) XCTAssertEqual(creativeUrlProviderSpy.usedCreativeId, creativeId) } + + func testIsCreativeOpen_whenThereAreTwoSDKInstancesAndBothTriggersCreative_ShouldNotLaunchASecondCreative() { + ATTNSDK._isCreativeOpen = false + let secondCreativeUrlProviderSpy = ATTNCreativeUrlProviderSpy() + let secondSdk = ATTNSDK(api: apiSpy, urlBuilder: secondCreativeUrlProviderSpy) + + XCTAssertFalse(ATTNSDK._isCreativeOpen, "The value should be false") + sut.trigger(UIView()) + XCTAssertTrue(creativeUrlProviderSpy.buildCompanyCreativeUrlWasCalled, "Creative url should be built") + + secondSdk.trigger(UIView()) + XCTAssertTrue(secondCreativeUrlProviderSpy.buildCompanyCreativeUrlWasCalled, "Creative url should not be built") + + addTeardownBlock { + ATTNSDK._isCreativeOpen = false + } + } } diff --git a/attentive-ios-sdk.xcworkspace/xcshareddata/swiftpm/Package.resolved b/attentive-ios-sdk.xcworkspace/xcshareddata/swiftpm/Package.resolved index 893c9fc..854b81e 100644 --- a/attentive-ios-sdk.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/attentive-ios-sdk.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,8 +6,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/attentive-mobile/attentive-ios-sdk", "state" : { - "branch" : "main", - "revision" : "16ea6c5924b6431d996f38d057b9a55e6639ed03" + "revision" : "6f6d281e63eee0e7a894524d5d461a74ab8837f0", + "version" : "1.0.0" } } ],