From 7d1348e3efb0b6576ab4c3793dcb123ef7e9d779 Mon Sep 17 00:00:00 2001 From: Joshua Liebowitz Date: Wed, 25 Aug 2021 09:33:35 -0700 Subject: [PATCH] Move TODOs into GitHub (#778) * Move TODOs into GitHub part of #597 * Remove extra space * add @testable import to two test suites * Update for RCPurchaserInfo -init being unavailable --- PublicSDKAPITester/RCPurchasesAPI.m | 11 +---------- .../Attribution/AttributionPoster.swift | 2 -- PurchasesCoreSwift/Networking/Backend.swift | 2 -- PurchasesCoreSwift/Public/EntitlementInfo.swift | 2 -- PurchasesCoreSwift/Public/Offering.swift | 1 - PurchasesCoreSwift/Public/PurchaserInfo.swift | 12 ++++-------- .../Purchasing/ProductsRequestFactory.swift | 1 - .../Purchasing/PurchasesOrchestrator.swift | 5 ----- PurchasesCoreSwift/Purchasing/StoreKitWrapper.swift | 2 +- .../Purchasing/EntitlementInfosTests.swift | 2 +- .../Purchasing/OfferingsManagerTests.swift | 1 - .../Purchasing/PurchaserInfoTests.swift | 4 ++-- RCPurchaserInfoAPI.m | 3 ++- 13 files changed, 11 insertions(+), 37 deletions(-) diff --git a/PublicSDKAPITester/RCPurchasesAPI.m b/PublicSDKAPITester/RCPurchasesAPI.m index b74cee4a18..8c51b41baf 100644 --- a/PublicSDKAPITester/RCPurchasesAPI.m +++ b/PublicSDKAPITester/RCPurchasesAPI.m @@ -30,15 +30,6 @@ @implementation RCPurchasesAPI BOOL isAnonymous; + (void)checkAPI { - // TODO: Addresses these blocks - // typedef void (^RCReceivePurchaserInfoBlock)(RCPurchaserInfo * _Nullable, NSError * _Nullable) NS_SWIFT_NAME(Purchases.ReceivePurchaserInfoBlock); - // typedef void (^RCReceiveIntroEligibilityBlock)(NSDictionary *) NS_SWIFT_NAME(Purchases.ReceiveIntroEligibilityBlock); - // typedef void (^RCReceiveOfferingsBlock)(RCOfferings * _Nullable, NSError * _Nullable) NS_SWIFT_NAME(Purchases.ReceiveOfferingsBlock); - // typedef void (^RCReceiveProductsBlock)(NSArray *) NS_SWIFT_NAME(Purchases.ReceiveProductsBlock); - // typedef void (^RCPurchaseCompletedBlock)(SKPaymentTransaction * _Nullable, RCPurchaserInfo * _Nullable, NSError * _Nullable, BOOL userCancelled) NS_SWIFT_NAME(Purchases.PurchaseCompletedBlock); - // typedef void (^RCDeferredPromotionalPurchaseBlock)(RCPurchaseCompletedBlock); - // typedef void (^RCPaymentDiscountBlock)(SKPaymentDiscount * _Nullable, NSError * _Nullable) NS_SWIFT_NAME(Purchases.PaymentDiscountBlock); - // TODO: iOS ONLY, TEST FOR THIS API BY LOOKING UP SELECTOR // [p presentCodeRedemptionSheet]; RCPurchases *p = [RCPurchases configureWithAPIKey:@""]; @@ -66,7 +57,7 @@ + (void)checkAPI { appUserID = [p appUserID]; isAnonymous = [p isAnonymous]; - RCPurchaserInfo *pi = [[RCPurchaserInfo alloc] initWithData: [[NSDictionary alloc] init]]; + RCPurchaserInfo *pi = nil; SKProduct *skp = [[SKProduct alloc] init]; SKProductDiscount *skpd = [[SKProductDiscount alloc] init]; SKPaymentDiscount *skmd = [[SKPaymentDiscount alloc] init]; diff --git a/PurchasesCoreSwift/Attribution/AttributionPoster.swift b/PurchasesCoreSwift/Attribution/AttributionPoster.swift index f921725c22..7150db3a8e 100644 --- a/PurchasesCoreSwift/Attribution/AttributionPoster.swift +++ b/PurchasesCoreSwift/Attribution/AttributionPoster.swift @@ -58,8 +58,6 @@ class AttributionPoster { deviceCache.latestNetworkAndAdvertisingIdsSent(appUserID: currentAppUserID) let latestSentToNetwork = latestNetworkIdsAndAdvertisingIdsSentByNetwork[networkKey] - // TODO: `(null)` is true to the ObjC code here, maybe we should reject this and not post? - // Post-migration: early return here. let newValueForNetwork = "\(maybeIdentifierForAdvertisers ?? "(null)")_\(networkUserId ?? "(null)")" guard latestSentToNetwork != newValueForNetwork else { Logger.debug(Strings.attribution.skip_same_attributes) diff --git a/PurchasesCoreSwift/Networking/Backend.swift b/PurchasesCoreSwift/Networking/Backend.swift index 3c99b6a0c1..1844219ddc 100644 --- a/PurchasesCoreSwift/Networking/Backend.swift +++ b/PurchasesCoreSwift/Networking/Backend.swift @@ -636,7 +636,6 @@ private extension Backend { func getOfferingsCallbacksAndClearCache(forKey key: String) -> [OfferingsResponseHandler] { return callbackQueue.sync { [self] in let callbacks = offeringsCallbacksCache.removeValue(forKey: key) - // TODO: Should we throw instead of NSParameterAssert? assert(callbacks != nil) return callbacks ?? [] } @@ -645,7 +644,6 @@ private extension Backend { func getPurchaserInfoCallbacksAndClearCache(forKey key: String) -> [BackendPurchaserInfoResponseHandler] { return callbackQueue.sync { [self] in let callbacks = purchaserInfoCallbacksCache.removeValue(forKey: key) - // TODO: Should we throw instead of NSParameterAssert? assert(callbacks != nil) return callbacks ?? [] } diff --git a/PurchasesCoreSwift/Public/EntitlementInfo.swift b/PurchasesCoreSwift/Public/EntitlementInfo.swift index 1cae96822c..ea5fa7e1b1 100644 --- a/PurchasesCoreSwift/Public/EntitlementInfo.swift +++ b/PurchasesCoreSwift/Public/EntitlementInfo.swift @@ -134,7 +134,6 @@ import Foundation dateFormatter: .iso8601SecondsDateFormatter) } - // TODO(cleanup): Codable init(entitlementId: String, entitlementData: [String: Any], productData: [String: Any], @@ -285,7 +284,6 @@ private extension EntitlementInfo { class func parseOwnershipType(ownershipType: String?) -> PurchaseOwnershipType { guard let ownershipType = ownershipType else { - // TODO: should this be a warning? return .purchased } diff --git a/PurchasesCoreSwift/Public/Offering.swift b/PurchasesCoreSwift/Public/Offering.swift index ea020828cf..eb9612562d 100644 --- a/PurchasesCoreSwift/Public/Offering.swift +++ b/PurchasesCoreSwift/Public/Offering.swift @@ -71,7 +71,6 @@ import Foundation self.serverDescription = serverDescription self.availablePackages = availablePackages - // TODO: add validation to ensure we don't get multiple packages with the same type for package in availablePackages { switch package.packageType { case .lifetime: diff --git a/PurchasesCoreSwift/Public/PurchaserInfo.swift b/PurchasesCoreSwift/Public/PurchaserInfo.swift index 5721efdd25..1fd60e3559 100644 --- a/PurchasesCoreSwift/Public/PurchaserInfo.swift +++ b/PurchasesCoreSwift/Public/PurchaserInfo.swift @@ -145,11 +145,9 @@ import Foundation """ } - // TODO after migration make this internal - @objc public let schemaVersion: String? + let schemaVersion: String? - // TODO after migration make this internal - @objc public convenience init?(data: [String: Any]) { + convenience init?(data: [String: Any]) { self.init(data: data, dateFormatter: .iso8601SecondsDateFormatter, transactionsFactory: TransactionsFactory()) } @@ -189,11 +187,9 @@ import Foundation self.allPurchases = subscriberData.allPurchases } - // TODO after migration make this internal - @objc public static let currentSchemaVersion = "2" + static let currentSchemaVersion = "2" - // TODO after migration make this internal and remove objc rename - @objc(JSONObject) public func jsonObject() -> [String: Any] { + func jsonObject() -> [String: Any] { return originalData.merging( ["schema_version": PurchaserInfo.currentSchemaVersion], strategy: .keepOriginalValue diff --git a/PurchasesCoreSwift/Purchasing/ProductsRequestFactory.swift b/PurchasesCoreSwift/Purchasing/ProductsRequestFactory.swift index 6483b99fc6..ec386d7421 100644 --- a/PurchasesCoreSwift/Purchasing/ProductsRequestFactory.swift +++ b/PurchasesCoreSwift/Purchasing/ProductsRequestFactory.swift @@ -13,7 +13,6 @@ import Foundation import StoreKit -// todo: make internal class ProductsRequestFactory { func request(productIdentifiers: Set) -> SKProductsRequest { diff --git a/PurchasesCoreSwift/Purchasing/PurchasesOrchestrator.swift b/PurchasesCoreSwift/Purchasing/PurchasesOrchestrator.swift index 4bdff0fb72..5c0d0c7ead 100644 --- a/PurchasesCoreSwift/Purchasing/PurchasesOrchestrator.swift +++ b/PurchasesCoreSwift/Purchasing/PurchasesOrchestrator.swift @@ -131,8 +131,6 @@ class PurchasesOrchestrator { receiptData: receiptData, appUserID: self.appUserID) { maybeSignature, maybeKeyIdentifier, maybeNonce, maybeTimestamp, maybeError in if let error = maybeError { - // TODO: Consider making a custom error. issues/751 - // https://github.com/RevenueCat/purchases-ios/issues/751 completion(nil, error) return } @@ -141,8 +139,6 @@ class PurchasesOrchestrator { let nonce = maybeNonce, let signature = maybeSignature, let timestamp = maybeTimestamp else { - // TODO: Consider making a custom error. - // https://github.com/RevenueCat/purchases-ios/issues/751 completion(nil, ErrorUtils.unexpectedBackendResponseError()) return } @@ -225,7 +221,6 @@ extension PurchasesOrchestrator: StoreKitWrapperDelegate { func storeKitWrapper(_ storeKitWrapper: StoreKitWrapper, removedTransaction transaction: SKPaymentTransaction) { - // todo: remove // unused for now } diff --git a/PurchasesCoreSwift/Purchasing/StoreKitWrapper.swift b/PurchasesCoreSwift/Purchasing/StoreKitWrapper.swift index 0bce6ee0f1..3357e2e3fd 100644 --- a/PurchasesCoreSwift/Purchasing/StoreKitWrapper.swift +++ b/PurchasesCoreSwift/Purchasing/StoreKitWrapper.swift @@ -82,7 +82,7 @@ class StoreKitWrapper: NSObject, SKPaymentTransactionObserver { func payment(withProduct product: SKProduct) -> SKMutablePayment { let payment = SKMutablePayment(product: product) - // todo: check that it's fine to omit tvOS and iOS since the relevant methods exist in targets lower than ours + if #available(macOS 10.14, watchOS 6.2, macCatalyst 13.0, *) { payment.simulatesAskToBuyInSandbox = Self.simulatesAskToBuyInSandbox } diff --git a/PurchasesCoreSwiftTests/Purchasing/EntitlementInfosTests.swift b/PurchasesCoreSwiftTests/Purchasing/EntitlementInfosTests.swift index baa9496c1b..d2d4db2a10 100644 --- a/PurchasesCoreSwiftTests/Purchasing/EntitlementInfosTests.swift +++ b/PurchasesCoreSwiftTests/Purchasing/EntitlementInfosTests.swift @@ -10,7 +10,7 @@ import Foundation import XCTest import Nimble -import PurchasesCoreSwift +@testable import PurchasesCoreSwift class EntitlementInfosTests: XCTestCase { diff --git a/PurchasesCoreSwiftTests/Purchasing/OfferingsManagerTests.swift b/PurchasesCoreSwiftTests/Purchasing/OfferingsManagerTests.swift index 88d06987cf..b338e73b17 100644 --- a/PurchasesCoreSwiftTests/Purchasing/OfferingsManagerTests.swift +++ b/PurchasesCoreSwiftTests/Purchasing/OfferingsManagerTests.swift @@ -16,7 +16,6 @@ import Nimble import StoreKit @testable import PurchasesCoreSwift -// TODO (post-migration): Move this test case to the new framework target (PurchasesCoreSwift). class OfferingsManagerTests: XCTestCase { let mockDeviceCache = MockDeviceCache() diff --git a/PurchasesCoreSwiftTests/Purchasing/PurchaserInfoTests.swift b/PurchasesCoreSwiftTests/Purchasing/PurchaserInfoTests.swift index 15b57d0710..014f413fdd 100644 --- a/PurchasesCoreSwiftTests/Purchasing/PurchaserInfoTests.swift +++ b/PurchasesCoreSwiftTests/Purchasing/PurchaserInfoTests.swift @@ -10,10 +10,10 @@ import Foundation import XCTest import Nimble -import PurchasesCoreSwift +@testable import PurchasesCoreSwift class EmptyPurchaserInfoTests: XCTestCase { - let purchaserInfo = PurchaserInfo.init(data: [String : Any]()) + let purchaserInfo = PurchaserInfo(data: [String : Any]()) func testEmptyDataYieldsANilInfo() { expect(self.purchaserInfo).to(beNil()) diff --git a/RCPurchaserInfoAPI.m b/RCPurchaserInfoAPI.m index a1ce0b7fbf..be3bdf78d5 100644 --- a/RCPurchaserInfoAPI.m +++ b/RCPurchaserInfoAPI.m @@ -13,7 +13,8 @@ @implementation RCPurchaserInfoAPI + (void)checkAPI { - RCPurchaserInfo *pi = [[RCPurchaserInfo alloc]initWithData: [[NSDictionary alloc] init]]; + // RCPurchaserInfo initializer is publically unavailable. + RCPurchaserInfo *pi = nil; RCEntitlementInfos *ei = pi.entitlements; NSSet *as = pi.activeSubscriptions; NSSet *appis = pi.allPurchasedProductIdentifiers;