From df3eade93ebe568c2ad6e96afc5f6e261f75816e Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 8 Aug 2022 20:32:50 -0500 Subject: [PATCH] Update iOS 4.10.0 (and add AdServices) (#194) * Update iOS to 4.10.0 with AdServices * Make public and add API test * Fix tests * Allow warning on pod lib lint because use of deprecated automaticAppleSearchAdsAttributionCollection * Using setValue to set automaticAppleSearchAdsAttributionCollection * Unused stuff * ugh * How did this happen --- DEVELOPMENT.md | 2 +- PurchasesHybridCommon.podspec | 2 +- .../ObjCAPITester/RCHybridCommonAPITest.m | 1 + ios/PurchasesHybridCommon/Podfile | 4 ++-- ios/PurchasesHybridCommon/Podfile.lock | 8 ++++---- .../PurchasesHybridCommon/CommonFunctionality.swift | 10 +++++++++- .../Mocks/MockPurchases.swift | 8 +++++--- .../PurchasesHybridCommonTests.swift | 10 ++++++++++ 8 files changed, 33 insertions(+), 12 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 90b682a7..c16690b9 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -5,7 +5,7 @@ In `ios/PurchasesHybridCommon/Podfile` replace: ``` - pod 'RevenueCat', '4.9.0' + pod 'RevenueCat', '4.10.0' ``` with: diff --git a/PurchasesHybridCommon.podspec b/PurchasesHybridCommon.podspec index de3941ca..031c4747 100644 --- a/PurchasesHybridCommon.podspec +++ b/PurchasesHybridCommon.podspec @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.framework = 'StoreKit' - s.dependency 'RevenueCat', '4.9.1' + s.dependency 'RevenueCat', '4.10.0' s.swift_version = '5.0' s.ios.deployment_target = '11.0' diff --git a/ios/PurchasesHybridCommon/ObjCAPITester/RCHybridCommonAPITest.m b/ios/PurchasesHybridCommon/ObjCAPITester/RCHybridCommonAPITest.m index d58f436a..4391cbbe 100644 --- a/ios/PurchasesHybridCommon/ObjCAPITester/RCHybridCommonAPITest.m +++ b/ios/PurchasesHybridCommon/ObjCAPITester/RCHybridCommonAPITest.m @@ -51,6 +51,7 @@ - (void)testAPI { }]; [RCCommonFunctionality setAutomaticAppleSearchAdsAttributionCollection:YES]; + [RCCommonFunctionality enableAdServicesAttributionTokenCollection]; [RCCommonFunctionality getOfferingsWithCompletionBlock:^(NSDictionary * _Nullable offerings, RCErrorContainer * _Nullable error) { }]; diff --git a/ios/PurchasesHybridCommon/Podfile b/ios/PurchasesHybridCommon/Podfile index 91ae3eff..673b2a2b 100644 --- a/ios/PurchasesHybridCommon/Podfile +++ b/ios/PurchasesHybridCommon/Podfile @@ -5,7 +5,7 @@ target 'PurchasesHybridCommon' do use_frameworks! # Pods for PurchasesHybridCommon - pod 'RevenueCat', '4.9.1' + pod 'RevenueCat', '4.10.0' target 'PurchasesHybridCommonTests' do # Pods for testing @@ -28,5 +28,5 @@ target 'ObjCAPITester' do platform :ios, '11.0' use_frameworks! - pod 'RevenueCat', '4.9.1' + pod 'RevenueCat', '4.10.0' end \ No newline at end of file diff --git a/ios/PurchasesHybridCommon/Podfile.lock b/ios/PurchasesHybridCommon/Podfile.lock index 1f93a5c2..d2426946 100644 --- a/ios/PurchasesHybridCommon/Podfile.lock +++ b/ios/PurchasesHybridCommon/Podfile.lock @@ -1,13 +1,13 @@ PODS: - Nimble (10.0.0) - Quick (5.0.1) - - RevenueCat (4.9.0) + - RevenueCat (4.10.0) - SnapshotTesting (1.9.0) DEPENDENCIES: - Nimble - Quick - - RevenueCat (= 4.9.0) + - RevenueCat (= 4.10.0) - "SnapshotTesting (from `git@github.com:pointfreeco/swift-snapshot-testing.git`, branch `main`)" SPEC REPOS: @@ -29,9 +29,9 @@ CHECKOUT OPTIONS: SPEC CHECKSUMS: Nimble: 5316ef81a170ce87baf72dd961f22f89a602ff84 Quick: 749aa754fd1e7d984f2000fe051e18a3a9809179 - RevenueCat: d5ec5e2944eedce83497218f0dc01eda546dd7a7 + RevenueCat: 1fd18820548e7c38677055a8ffc4aac530fa1851 SnapshotTesting: 6141c48b6aa76ead61431ca665c14ab9a066c53b -PODFILE CHECKSUM: 1e06780152d2843b1ed121c20897565b8bc24975 +PODFILE CHECKSUM: c5e40eb73d0ccddfd47781909856edc6f8f80dea COCOAPODS: 1.11.3 diff --git a/ios/PurchasesHybridCommon/PurchasesHybridCommon/CommonFunctionality.swift b/ios/PurchasesHybridCommon/PurchasesHybridCommon/CommonFunctionality.swift index 2c9d8007..fbb8a2ce 100644 --- a/ios/PurchasesHybridCommon/PurchasesHybridCommon/CommonFunctionality.swift +++ b/ios/PurchasesHybridCommon/PurchasesHybridCommon/CommonFunctionality.swift @@ -63,7 +63,15 @@ import RevenueCat } @objc public static func setAutomaticAppleSearchAdsAttributionCollection(_ enabled: Bool) { - Purchases.automaticAppleSearchAdsAttributionCollection = enabled + // Using `setValue` because `automaticAppleSearchAdsAttributionCollection` is now deprecated and we get a warning + Purchases.setValue(enabled, forKey: "automaticAppleSearchAdsAttributionCollection") + } + + @available(iOS 14.3, macOS 11.1, macCatalyst 14.3, *) + @available(tvOS, unavailable) + @available(watchOS, unavailable) + @objc public static func enableAdServicesAttributionTokenCollection() { + Purchases.shared.attribution.enableAdServicesAttributionTokenCollection() } @objc public static func setFinishTransactions(_ finishTransactions: Bool) { diff --git a/ios/PurchasesHybridCommon/PurchasesHybridCommonTests/Mocks/MockPurchases.swift b/ios/PurchasesHybridCommon/PurchasesHybridCommonTests/Mocks/MockPurchases.swift index 6a4436ed..aacdf66f 100644 --- a/ios/PurchasesHybridCommon/PurchasesHybridCommonTests/Mocks/MockPurchases.swift +++ b/ios/PurchasesHybridCommon/PurchasesHybridCommonTests/Mocks/MockPurchases.swift @@ -48,9 +48,6 @@ class MockPurchases: Purchases { appUserID: nil ) - let subscriberAttributes = Attribution(subscriberAttributesManager: subscriberAttributesManager, - currentUserProvider: identityManager) - let attributionPoster: AttributionPoster = AttributionPoster( deviceCache: deviceCache, currentUserProvider: identityManager, @@ -58,6 +55,11 @@ class MockPurchases: Purchases { attributionFetcher: attributionFetcher, subscriberAttributesManager: subscriberAttributesManager) + let subscriberAttributes = Attribution( + subscriberAttributesManager: subscriberAttributesManager, + currentUserProvider: identityManager, + attributionPoster: attributionPoster) + let storeKitWrapper: StoreKitWrapper = StoreKitWrapper() let notificationCenter: NotificationCenter = NotificationCenter.default diff --git a/ios/PurchasesHybridCommon/PurchasesHybridCommonTests/PurchasesHybridCommonTests.swift b/ios/PurchasesHybridCommon/PurchasesHybridCommonTests/PurchasesHybridCommonTests.swift index 384dc9a8..11202da8 100644 --- a/ios/PurchasesHybridCommon/PurchasesHybridCommonTests/PurchasesHybridCommonTests.swift +++ b/ios/PurchasesHybridCommon/PurchasesHybridCommonTests/PurchasesHybridCommonTests.swift @@ -30,6 +30,16 @@ class PurchasesHybridCommonTests: QuickSpec { override func spec() { + context("automaticAppleSearchAdsAttributionCollection") { + it("sets automaticAppleSearchAdsAttributionCollection using setValue") { + // sets Purchases.automaticAppleSearchAdsAttributionCollection dynamically + // through setValue + expect(Purchases.automaticAppleSearchAdsAttributionCollection) == false + CommonFunctionality.setAutomaticAppleSearchAdsAttributionCollection(true) + expect(Purchases.automaticAppleSearchAdsAttributionCollection) == true + } + } + context("proxy url string") { it("parses the string and sets the url if valid") { let urlString = "https://revenuecat.com"