diff --git a/.jazzy.yaml b/.jazzy.yaml index ab1c238fe3..3ab98550e1 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -5,9 +5,9 @@ objc: true sdk: iphonesimulator module: Purchases umbrella_header: Purchases/Public/Purchases.h -module_version: 3.15.0-SNAPSHOT +module_version: 3.14.1 github_url: https://github.com/revenuecat/purchases-ios -github_file_prefix: https://github.com/revenuecat/purchases-ios/tree/3.15.0-SNAPSHOT +github_file_prefix: https://github.com/revenuecat/purchases-ios/tree/3.14.1 output: docs # Leaving this commented out. We used to specify this before, but now it's working without it # xcodebuild_arguments: [--objc,Purchases/Public/Purchases.h,--,-x,objective-c,-isysroot,$(xcrun --show-sdk-path),-I,$(pwd)] diff --git a/.version b/.version index 35e6006f6a..5d737ca0ed 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -3.15.0-SNAPSHOT \ No newline at end of file +3.14.1 \ No newline at end of file diff --git a/CHANGELOG.latest.md b/CHANGELOG.latest.md index 079ded36d3..77e2ad777c 100644 --- a/CHANGELOG.latest.md +++ b/CHANGELOG.latest.md @@ -1,3 +1,3 @@ -- Added a setting to disable automatic syncinc of purchases. This setting will prevent RevenueCat from listening to -the StoreKit queue so you should only use if suggested by RevenueCat support team. - https://github.com/RevenueCat/purchases-ios/pull/1219 +- Fixed an issue where `checkTrialOrIntroductoryPriceEligibility` might refresh the receipt if it's not present on device, +causing a log in prompt for App Store credentials. + https://github.com/RevenueCat/purchases-ios/pull/1264 diff --git a/CHANGELOG.md b/CHANGELOG.md index 168d892b41..5a3be3172b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 3.14.1 +- Fixed an issue where `checkTrialOrIntroductoryPriceEligibility` might refresh the receipt if it's not present on device, +causing a log in prompt for App Store credentials. + https://github.com/RevenueCat/purchases-ios/pull/1264 + ## 3.14.0 - Added a setting to disable automatic syncinc of purchases. This setting will prevent RevenueCat from listening to the StoreKit queue so you should only use if suggested by RevenueCat support team. diff --git a/Purchases.podspec b/Purchases.podspec index 289b6f61bf..3b5ac4daa8 100644 --- a/Purchases.podspec +++ b/Purchases.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Purchases" - s.version = "3.15.0-SNAPSHOT" + s.version = "3.14.1" s.summary = "Subscription and in-app-purchase backend service." s.description = <<-DESC @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.tvos.deployment_target = '9.0' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } - s.dependency 'PurchasesCoreSwift', '3.15.0-SNAPSHOT' + s.dependency 'PurchasesCoreSwift', '3.14.1' s.source_files = ['Purchases/**/*.{h,m}'] diff --git a/Purchases/Info.plist b/Purchases/Info.plist index 2bf1baf0a1..5ffeb9cfd0 100644 --- a/Purchases/Info.plist +++ b/Purchases/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.15.0 + 3.14.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSHumanReadableCopyright diff --git a/Purchases/Misc/RCSystemInfo.m b/Purchases/Misc/RCSystemInfo.m index 3e66b103a7..dec29a6ca0 100644 --- a/Purchases/Misc/RCSystemInfo.m +++ b/Purchases/Misc/RCSystemInfo.m @@ -64,7 +64,7 @@ + (BOOL)isSandbox { } + (NSString *)frameworkVersion { - return @"3.15.0-SNAPSHOT"; + return @"3.14.1"; } + (NSString *)systemVersion { diff --git a/Purchases/Public/RCPurchases.h b/Purchases/Public/RCPurchases.h index b920788ddc..c9451a14fe 100644 --- a/Purchases/Public/RCPurchases.h +++ b/Purchases/Public/RCPurchases.h @@ -382,7 +382,7 @@ NS_SWIFT_NAME(syncPurchases(_:)); /** Computes whether or not a user is eligible for the introductory pricing period of a given product. You should use this method to determine whether or not you show the user the normal product price or the introductory price. This also applies to trials (trials are considered a type of introductory pricing). - @note Subscription groups are automatically collected for determining eligibility. If RevenueCat can't definitively compute the eligibilty, most likely because of missing group information, it will return `RCIntroEligibilityStatusUnknown`. The best course of action on unknown status is to display the non-intro pricing, to not create a misleading situation. To avoid this, make sure you are testing with the latest version of iOS so that the subscription group can be collected by the SDK. + @note Subscription groups are automatically collected for determining eligibility. If RevenueCat can't definitively compute the eligibility, most likely because of missing group information, it will return `RCIntroEligibilityStatusUnknown`. The best course of action on unknown status is to display the non-intro pricing, to not create a misleading situation. To avoid this, make sure you are testing with the latest version of iOS so that the subscription group can be collected by the SDK. @param productIdentifiers Array of product identifiers for which you want to compute eligibility @param receiveEligibility A block that receives a dictionary of product_id -> `RCIntroEligibility`. diff --git a/Purchases/Public/RCPurchases.m b/Purchases/Public/RCPurchases.m index fcda5a149b..129441769b 100644 --- a/Purchases/Public/RCPurchases.m +++ b/Purchases/Public/RCPurchases.m @@ -746,7 +746,7 @@ - (void)handleRestoreReceiptPostWithInfo:(RCPurchaserInfo *)info - (void)checkTrialOrIntroductoryPriceEligibility:(NSArray *)productIdentifiers completionBlock:(RCReceiveIntroEligibilityBlock)receiveEligibility { - [self receiptData:^(NSData *data) { + [self receiptDataWithReceiptRefreshPolicy:RCReceiptRefreshPolicyNever completion:^(NSData *data) { if (data != nil && data.length > 0) { if (@available(iOS 12.0, macOS 10.14, macCatalyst 13.0, tvOS 12.0, watchOS 6.2, *)) { NSSet *productIdentifiersSet = [[NSSet alloc] initWithArray:productIdentifiers]; diff --git a/PurchasesCoreSwift.podspec b/PurchasesCoreSwift.podspec index 3a6ae014ad..c67f8470d5 100644 --- a/PurchasesCoreSwift.podspec +++ b/PurchasesCoreSwift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "PurchasesCoreSwift" - s.version = "3.15.0-SNAPSHOT" + s.version = "3.14.1" s.summary = "Swift portion of RevenueCat's Subscription and in-app-purchase backend service." s.description = <<-DESC diff --git a/PurchasesCoreSwift/Info.plist b/PurchasesCoreSwift/Info.plist index 31bb7bfedb..641fa59f3e 100644 --- a/PurchasesCoreSwift/Info.plist +++ b/PurchasesCoreSwift/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 3.15.0 + 3.14.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) diff --git a/PurchasesCoreSwiftTests/Info.plist b/PurchasesCoreSwiftTests/Info.plist index b9ce70b7a3..9454a1c399 100644 --- a/PurchasesCoreSwiftTests/Info.plist +++ b/PurchasesCoreSwiftTests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 3.15.0 + 3.14.1 CFBundleVersion 1 diff --git a/PurchasesTests/Info.plist b/PurchasesTests/Info.plist index 1769cd198f..27dd808993 100644 --- a/PurchasesTests/Info.plist +++ b/PurchasesTests/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 3.15.0 + 3.14.1 CFBundleVersion 1 diff --git a/PurchasesTests/Purchasing/PurchasesTests.swift b/PurchasesTests/Purchasing/PurchasesTests.swift index f1d4239cc2..0025df93fc 100644 --- a/PurchasesTests/Purchasing/PurchasesTests.swift +++ b/PurchasesTests/Purchasing/PurchasesTests.swift @@ -269,8 +269,8 @@ class PurchasesTests: XCTestCase { receiptParser: mockReceiptParser, purchaserInfoManager: purchaserInfoManager) - purchases!.delegate = purchasesDelegate - Purchases.setDefaultInstance(purchases!) + purchases.delegate = purchasesDelegate + Purchases.setDefaultInstance(purchases) } func testIsAbleToBeInitialized() { @@ -473,7 +473,7 @@ class PurchasesTests: XCTestCase { func testDelegateIsNotCalledIfBlockPassed() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -495,7 +495,7 @@ class PurchasesTests: XCTestCase { setupPurchases() var products: [SKProduct]? let productIdentifiers = ["com.product.id1", "com.product.id2"] - purchases!.products(productIdentifiers) { (newProducts) in + purchases.products(productIdentifiers) { (newProducts) in products = newProducts } @@ -511,7 +511,7 @@ class PurchasesTests: XCTestCase { func testAddsPaymentToWrapper() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -522,7 +522,7 @@ class PurchasesTests: XCTestCase { func testTransitioningToPurchasing() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -538,7 +538,7 @@ class PurchasesTests: XCTestCase { func testTransitioningToPurchasedSendsToBackend() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -558,7 +558,7 @@ class PurchasesTests: XCTestCase { func testReceiptsSendsAsRestoreWhenAnon() { setupAnonPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -579,7 +579,7 @@ class PurchasesTests: XCTestCase { setupAnonPurchases() self.purchases.allowSharingAppStoreAccount = false let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -600,7 +600,7 @@ class PurchasesTests: XCTestCase { setupPurchases() self.purchases.allowSharingAppStoreAccount = true let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -620,7 +620,7 @@ class PurchasesTests: XCTestCase { func testFinishesTransactionsIfSentToBackendCorrectly() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -641,9 +641,9 @@ class PurchasesTests: XCTestCase { func testDoesntFinishTransactionsIfFinishingDisabled() { setupPurchases() - self.purchases?.finishTransactions = false + self.purchases.finishTransactions = false let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -665,9 +665,9 @@ class PurchasesTests: XCTestCase { func testSendsProductInfoIfProductIsCached() { setupPurchases() let productIdentifiers = ["com.product.id1", "com.product.id2"] - purchases!.products(productIdentifiers) { (newProducts) in + purchases.products(productIdentifiers) { (newProducts) in let product = newProducts[0]; - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -747,7 +747,7 @@ class PurchasesTests: XCTestCase { func testAfterSendingDoesntFinishTransactionIfBackendError() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -765,7 +765,7 @@ class PurchasesTests: XCTestCase { func testAfterSendingFinishesFromBackendErrorIfAppropriate() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -784,7 +784,7 @@ class PurchasesTests: XCTestCase { func testNotifiesIfTransactionFailsFromBackend() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -804,7 +804,7 @@ class PurchasesTests: XCTestCase { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") var receivedError: Error? - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in receivedError = error } @@ -843,7 +843,7 @@ class PurchasesTests: XCTestCase { self.backend.overridePurchaserInfo = purchaserInfoBeforePurchase self.backend.postReceiptPurchaserInfo = purchaserInfoAfterPurchase - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in purchaserInfo = info receivedError = error receivedUserCancelled = userCancelled @@ -867,7 +867,7 @@ class PurchasesTests: XCTestCase { var callCount = 0 - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in callCount += 1 } @@ -891,7 +891,7 @@ class PurchasesTests: XCTestCase { var callCount = 0 - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in callCount += 1 } @@ -912,7 +912,7 @@ class PurchasesTests: XCTestCase { let product = MockSKProduct(mockProductIdentifier: "com.product.id1") // First one "works" - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } var receivedInfo: Purchases.PurchaserInfo? @@ -920,7 +920,7 @@ class PurchasesTests: XCTestCase { var receivedUserCancelled: Bool? // Second one issues an error - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in receivedInfo = info receivedError = error as NSError? receivedUserCancelled = userCancelled @@ -953,11 +953,11 @@ class PurchasesTests: XCTestCase { func testDoesntSetWrapperDelegateToNilIfDelegateNil() { setupPurchases() - purchases!.delegate = nil + purchases.delegate = nil expect(self.storeKitWrapper.delegate).toNot(beNil()) - purchases!.delegate = purchasesDelegate + purchases.delegate = purchasesDelegate expect(self.storeKitWrapper.delegate).toNot(beNil()) } @@ -1005,14 +1005,14 @@ class PurchasesTests: XCTestCase { func testDoesntRemoveObservationWhenDelegateNil() { setupPurchases() - purchases!.delegate = nil + purchases.delegate = nil expect(self.notificationCenter.observers.count).to(equal(2)); } func testRestoringPurchasesPostsTheReceipt() { setupPurchases() - purchases!.restoreTransactions() + purchases.restoreTransactions() expect(self.backend.postReceiptDataCalled).to(beTrue()) } @@ -1033,7 +1033,7 @@ class PurchasesTests: XCTestCase { mockReceiptParser.stubbedReceiptHasTransactionsResult = false setupPurchases() - purchases!.restoreTransactions() + purchases.restoreTransactions() expect(self.backend.postReceiptDataCalled) == false } @@ -1042,7 +1042,7 @@ class PurchasesTests: XCTestCase { mockReceiptParser.stubbedReceiptHasTransactionsResult = false setupPurchases() - purchases!.restoreTransactions() + purchases.restoreTransactions() expect(self.backend.postReceiptDataCalled) == true } @@ -1064,7 +1064,7 @@ class PurchasesTests: XCTestCase { mockReceiptParser.stubbedReceiptHasTransactionsResult = true setupPurchases() - purchases!.restoreTransactions() + purchases.restoreTransactions() expect(self.backend.postReceiptDataCalled) == true } @@ -1073,7 +1073,7 @@ class PurchasesTests: XCTestCase { mockReceiptParser.stubbedReceiptHasTransactionsResult = true setupPurchases() - purchases!.restoreTransactions() + purchases.restoreTransactions() expect(self.backend.postReceiptDataCalled) == true } @@ -1081,7 +1081,7 @@ class PurchasesTests: XCTestCase { func testRestoringPurchasesAlwaysRefreshesAndPostsTheReceipt() { setupPurchases() self.receiptFetcher.shouldReturnReceipt = true - purchases!.restoreTransactions() + purchases.restoreTransactions() expect(self.receiptFetcher.receiptDataTimesCalled).to(equal(1)) expect(self.requestFetcher.refreshReceiptCalled).to(beTrue()) @@ -1089,13 +1089,13 @@ class PurchasesTests: XCTestCase { func testRestoringPurchasesSetsIsRestore() { setupPurchases() - purchases!.restoreTransactions(nil) + purchases.restoreTransactions(nil) expect(self.backend.postedIsRestore!).to(beTrue()) } func testRestoringPurchasesSetsIsRestoreForAnon() { setupAnonPurchases() - purchases!.restoreTransactions(nil) + purchases.restoreTransactions(nil) expect(self.backend.postedIsRestore!).to(beTrue()) } @@ -1108,7 +1108,7 @@ class PurchasesTests: XCTestCase { var receivedPurchaserInfo: Purchases.PurchaserInfo? - purchases!.restoreTransactions { (info, error) in + purchases.restoreTransactions { (info, error) in receivedPurchaserInfo = info } @@ -1128,7 +1128,7 @@ class PurchasesTests: XCTestCase { var receivedError: Error? - purchases!.restoreTransactions { (_, newError) in + purchases.restoreTransactions { (_, newError) in receivedError = newError } @@ -1137,7 +1137,7 @@ class PurchasesTests: XCTestCase { func testSyncPurchasesPostsTheReceipt() { setupPurchases() - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.backend.postReceiptDataCalled).to(beTrue()) } @@ -1148,7 +1148,7 @@ class PurchasesTests: XCTestCase { dangerousSettings: DangerousSettings(autoSyncPurchases: false)) initializePurchasesInstance(appUserId: nil) - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.backend.postReceiptDataCalled).to(beTrue()) } @@ -1169,7 +1169,7 @@ class PurchasesTests: XCTestCase { mockReceiptParser.stubbedReceiptHasTransactionsResult = false setupPurchases() - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.backend.postReceiptDataCalled) == false } @@ -1178,7 +1178,7 @@ class PurchasesTests: XCTestCase { mockReceiptParser.stubbedReceiptHasTransactionsResult = false setupPurchases() - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.backend.postReceiptDataCalled) == true } @@ -1200,7 +1200,7 @@ class PurchasesTests: XCTestCase { mockReceiptParser.stubbedReceiptHasTransactionsResult = true setupPurchases() - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.backend.postReceiptDataCalled) == true } @@ -1209,7 +1209,7 @@ class PurchasesTests: XCTestCase { mockReceiptParser.stubbedReceiptHasTransactionsResult = true setupPurchases() - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.backend.postReceiptDataCalled) == true } @@ -1217,7 +1217,7 @@ class PurchasesTests: XCTestCase { func testSyncPurchasesDoesntRefreshTheReceiptIfNotEmpty() { setupPurchases() self.receiptFetcher.shouldReturnReceipt = true - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.receiptFetcher.receiptDataTimesCalled) == 1 expect(self.requestFetcher.refreshReceiptCalled) == false @@ -1226,7 +1226,7 @@ class PurchasesTests: XCTestCase { func testSyncPurchasesDoesntRefreshTheReceiptIfEmpty() { setupPurchases() self.receiptFetcher.shouldReturnReceipt = false - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.receiptFetcher.receiptDataTimesCalled) == 1 expect(self.requestFetcher.refreshReceiptCalled) == false @@ -1236,11 +1236,11 @@ class PurchasesTests: XCTestCase { setupPurchases() purchases.allowSharingAppStoreAccount = false - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.backend.postedIsRestore!) == false purchases.allowSharingAppStoreAccount = true - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.backend.postedIsRestore!) == true } @@ -1248,11 +1248,11 @@ class PurchasesTests: XCTestCase { setupAnonPurchases() purchases.allowSharingAppStoreAccount = false - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.backend.postedIsRestore!) == false purchases.allowSharingAppStoreAccount = true - purchases!.syncPurchases() + purchases.syncPurchases() expect(self.backend.postedIsRestore!) == true } @@ -1264,7 +1264,7 @@ class PurchasesTests: XCTestCase { var receivedPurchaserInfo: Purchases.PurchaserInfo? - purchases!.syncPurchases { (info, error) in + purchases.syncPurchases { (info, error) in receivedPurchaserInfo = info } @@ -1284,7 +1284,7 @@ class PurchasesTests: XCTestCase { var receivedError: Error? - purchases!.syncPurchases { (_, newError) in + purchases.syncPurchases { (_, newError) in receivedError = newError } @@ -1362,18 +1362,32 @@ class PurchasesTests: XCTestCase { func testGetEligibility() { setupPurchases() - purchases!.checkTrialOrIntroductoryPriceEligibility([]) { (eligibilities) in + purchases.checkTrialOrIntroductoryPriceEligibility([]) { (eligibilities) in } } func testGetEligibilitySendsAReceipt() { setupPurchases() - purchases!.checkTrialOrIntroductoryPriceEligibility([]) { (eligibilities) in + purchases.checkTrialOrIntroductoryPriceEligibility([]) { (eligibilities) in } expect(self.receiptFetcher.receiptDataCalled).to(beTrue()) } + func testGetEligibilityDoesntRefreshReceipt() { + setupPurchases() + self.receiptFetcher.shouldReturnReceipt = false + + expect(self.requestFetcher.refreshReceiptCalled) == false + expect(self.receiptFetcher.receiptDataCalled) == false + + purchases.checkTrialOrIntroductoryPriceEligibility([]) { (eligibilities) in + } + + expect(self.receiptFetcher.receiptDataCalled) == true + expect(self.requestFetcher.refreshReceiptCalled) == false + } + func testFetchVersionSendsAReceiptIfNoVersion() { setupPurchases() @@ -1388,7 +1402,7 @@ class PurchasesTests: XCTestCase { var receivedPurchaserInfo: Purchases.PurchaserInfo? - purchases?.restoreTransactions { (info, error) in + purchases.restoreTransactions { (info, error) in receivedPurchaserInfo = info } @@ -1402,9 +1416,9 @@ class PurchasesTests: XCTestCase { setupPurchases() expect(self.deviceCache.cachedPurchaserInfo.count).toEventually(equal(1)) - expect(self.deviceCache.cachedPurchaserInfo[self.purchases!.appUserID]).toEventuallyNot(beNil()) + expect(self.deviceCache.cachedPurchaserInfo[self.purchases.appUserID]).toEventuallyNot(beNil()) - let purchaserInfo = self.deviceCache.cachedPurchaserInfo[self.purchases!.appUserID] + let purchaserInfo = self.deviceCache.cachedPurchaserInfo[self.purchases.appUserID] do { if (purchaserInfo != nil) { @@ -1427,7 +1441,7 @@ class PurchasesTests: XCTestCase { ]]); let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -1461,7 +1475,7 @@ class PurchasesTests: XCTestCase { var receivedInfo: Purchases.PurchaserInfo? - purchases!.purchaserInfo { (info, error) in + purchases.purchaserInfo { (info, error) in receivedInfo = info } @@ -1488,7 +1502,7 @@ class PurchasesTests: XCTestCase { var receivedInfo: Purchases.PurchaserInfo? - purchases!.purchaserInfo { (info, error) in + purchases.purchaserInfo { (info, error) in receivedInfo = info } @@ -1509,7 +1523,7 @@ class PurchasesTests: XCTestCase { var receivedInfo: Purchases.PurchaserInfo? - purchases!.purchaserInfo { (info, error) in + purchases.purchaserInfo { (info, error) in receivedInfo = info } @@ -1531,7 +1545,7 @@ class PurchasesTests: XCTestCase { var callCount = 0 - purchases!.purchaserInfo { (_, _) in + purchases.purchaserInfo { (_, _) in callCount += 1 } @@ -1555,7 +1569,7 @@ class PurchasesTests: XCTestCase { var receivedInfo: Purchases.PurchaserInfo? - purchases!.purchaserInfo { (info, error) in + purchases.purchaserInfo { (info, error) in receivedInfo = info } @@ -1579,7 +1593,7 @@ class PurchasesTests: XCTestCase { var receivedInfo: Purchases.PurchaserInfo? - purchases!.purchaserInfo { (info, error) in + purchases.purchaserInfo { (info, error) in receivedInfo = info } @@ -1593,7 +1607,7 @@ class PurchasesTests: XCTestCase { expect(self.backend.getSubscriberCallCount).toEventually(equal(1)) - purchases!.purchaserInfo { (info, error) in + purchases.purchaserInfo { (info, error) in } expect(self.backend.getSubscriberCallCount).to(equal(2)) @@ -1604,7 +1618,7 @@ class PurchasesTests: XCTestCase { expect(self.backend.gotOfferings).toEventually(equal(1)) var offerings: Purchases.Offerings? - self.purchases?.offerings { (newOfferings, _) in + self.purchases.offerings { (newOfferings, _) in offerings = newOfferings } @@ -1629,9 +1643,9 @@ class PurchasesTests: XCTestCase { func testProductInfoIsCachedForOfferings() { setupPurchases() expect(self.backend.gotOfferings).toEventually(equal(1)) - self.purchases?.offerings { (newOfferings, _) in + self.purchases.offerings { (newOfferings, _) in let product = newOfferings!["base"]!.monthly!.product; - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -1662,7 +1676,7 @@ class PurchasesTests: XCTestCase { setupPurchases() var offerings: Purchases.Offerings? - self.purchases?.offerings({ (newOfferings, _) in + self.purchases.offerings({ (newOfferings, _) in offerings = newOfferings }) @@ -1675,7 +1689,7 @@ class PurchasesTests: XCTestCase { setupPurchases() var receivedError: NSError? - self.purchases?.offerings({ (_, error) in + self.purchases.offerings({ (_, error) in receivedError = error as NSError? }) @@ -1691,7 +1705,7 @@ class PurchasesTests: XCTestCase { var maybeReceivedOfferings: Purchases.Offerings? var maybeReceivedError: Error? - self.purchases?.offerings({ offerings, error in + self.purchases.offerings({ offerings, error in maybeReceivedOfferings = offerings maybeReceivedError = error }) @@ -1723,7 +1737,7 @@ class PurchasesTests: XCTestCase { expect(self.backend.invokedPostAttributionDataParametersList[0].data?.keys.contains("rc_idfa")) == true expect(self.backend.invokedPostAttributionDataParametersList[0].data?.keys.contains("rc_idfv")) == true expect(self.backend.invokedPostAttributionDataParametersList[0].network) == RCAttributionNetwork.appleSearchAds - expect(self.backend.invokedPostAttributionDataParametersList[0].appUserID) == self.purchases?.appUserID + expect(self.backend.invokedPostAttributionDataParametersList[0].appUserID) == self.purchases.appUserID } func testSharedInstanceIsSetWhenConfiguring() { @@ -1754,7 +1768,7 @@ class PurchasesTests: XCTestCase { var completionCalled = false self.identityManager.aliasError = nil var info: Purchases.PurchaserInfo? - self.purchases?.createAlias("cesarpedro") { (newInfo, error) in + self.purchases.createAlias("cesarpedro") { (newInfo, error) in completionCalled = (error == nil) info = newInfo } @@ -1765,7 +1779,7 @@ class PurchasesTests: XCTestCase { self.identityManager.aliasError = Purchases.ErrorUtils.backendError(withBackendCode: Purchases.RevenueCatBackendErrorCode.invalidAPIKey.rawValue as NSNumber, backendMessage: "Invalid credentials", finishable: true) - self.purchases?.createAlias("cesardro") { (info, error) in + self.purchases.createAlias("cesardro") { (info, error) in completionCalled = (error == nil) } @@ -1786,7 +1800,7 @@ class PurchasesTests: XCTestCase { var completionCalled = false self.identityManager.aliasError = nil - self.purchases?.createAlias(newAppUserID) { (info, error) in + self.purchases.createAlias(newAppUserID) { (info, error) in completionCalled = (error == nil) } @@ -1799,7 +1813,7 @@ class PurchasesTests: XCTestCase { var completionCalled = false var info: Purchases.PurchaserInfo? - self.purchases?.identify("cesarpedro") { (newInfo, error) in + self.purchases.identify("cesarpedro") { (newInfo, error) in completionCalled = true info = newInfo } @@ -1810,7 +1824,7 @@ class PurchasesTests: XCTestCase { self.identityManager.identifyError = Purchases.ErrorUtils.backendError(withBackendCode: Purchases.RevenueCatBackendErrorCode.invalidAPIKey.rawValue as NSNumber, backendMessage: "Invalid credentials", finishable: true) - self.purchases?.identify("cesardro") { (info, error) in + self.purchases.identify("cesardro") { (info, error) in completionCalled = (error == nil) } @@ -1831,7 +1845,7 @@ class PurchasesTests: XCTestCase { let newAppUserID = "cesarPedro" var completionCalled = false - self.purchases?.identify(newAppUserID) { (info, error) in + self.purchases.identify(newAppUserID) { (info, error) in completionCalled = true } @@ -1844,7 +1858,7 @@ class PurchasesTests: XCTestCase { var completionCalled = false var info: Purchases.PurchaserInfo? - self.purchases?.reset { newInfo, error in + self.purchases.reset { newInfo, error in completionCalled = true info = newInfo } @@ -1864,7 +1878,7 @@ class PurchasesTests: XCTestCase { ]]) var completionCalled = false - self.purchases?.reset() { (info, error) in + self.purchases.reset() { (info, error) in completionCalled = (error == nil) } @@ -1880,7 +1894,7 @@ class PurchasesTests: XCTestCase { var completionCalled = false var info: Purchases.PurchaserInfo? - self.purchases?.createAlias(identityManager.currentAppUserID) { (newInfo, error) in + self.purchases.createAlias(identityManager.currentAppUserID) { (newInfo, error) in completionCalled = true info = newInfo } @@ -1898,7 +1912,7 @@ class PurchasesTests: XCTestCase { var completionCalled = false var info: Purchases.PurchaserInfo? - self.purchases?.identify(identityManager.currentAppUserID) { (newInfo, error) in + self.purchases.identify(identityManager.currentAppUserID) { (newInfo, error) in completionCalled = true info = newInfo } @@ -1944,7 +1958,7 @@ class PurchasesTests: XCTestCase { setupPurchases() self.receiptFetcher.shouldReturnReceipt = false var receivedError: NSError? - self.purchases?.restoreTransactions() { (info, error) in + self.purchases.restoreTransactions() { (info, error) in receivedError = error as NSError? } @@ -1956,7 +1970,7 @@ class PurchasesTests: XCTestCase { let product = MockSKProduct(mockProductIdentifier: "com.product.id1") var receivedUserCancelled: Bool? - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in receivedUserCancelled = userCancelled } @@ -1975,7 +1989,7 @@ class PurchasesTests: XCTestCase { var receivedError: NSError? var receivedUnderlyingError: NSError? - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in receivedError = error as NSError? receivedUserCancelled = userCancelled receivedUnderlyingError = receivedError?.userInfo[NSUnderlyingErrorKey] as! NSError? @@ -2003,7 +2017,7 @@ class PurchasesTests: XCTestCase { var receivedUserCancelled: Bool? var receivedError: NSError? - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in receivedError = error as NSError? receivedUserCancelled = userCancelled } @@ -2049,7 +2063,7 @@ class PurchasesTests: XCTestCase { let product = MockSKProduct(mockProductIdentifier: "com.product.id1") let discount = SKPaymentDiscount.init(identifier: "discount", keyIdentifier: "TIKAMASALA1", nonce: UUID(), signature: "Base64 encoded signature", timestamp: NSNumber(value: Int64(123413232131))) - self.purchases?.purchaseProduct(product, discount: discount) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product, discount: discount) { (tx, info, error, userCancelled) in } @@ -2077,7 +2091,7 @@ class PurchasesTests: XCTestCase { var completionCalled = false var receivedPaymentDiscount: SKPaymentDiscount? - self.purchases?.paymentDiscount(for: productDiscount, product: product, completion: { (paymentDiscount, error) in + self.purchases.paymentDiscount(for: productDiscount, product: product, completion: { (paymentDiscount, error) in receivedPaymentDiscount = paymentDiscount completionCalled = true }) @@ -2106,7 +2120,7 @@ class PurchasesTests: XCTestCase { var completionCalled = false var receivedPaymentDiscount: SKPaymentDiscount? var receivedError: Error? = nil - self.purchases?.paymentDiscount(for: productDiscount, product: product, completion: { (paymentDiscount, error) in + self.purchases.paymentDiscount(for: productDiscount, product: product, completion: { (paymentDiscount, error) in receivedPaymentDiscount = paymentDiscount completionCalled = true receivedError = error @@ -2133,7 +2147,7 @@ class PurchasesTests: XCTestCase { var completionCalled = false var receivedPaymentDiscount: SKPaymentDiscount? var receivedError: Error? = nil - self.purchases?.paymentDiscount(for: productDiscount, product: product, completion: { (paymentDiscount, error) in + self.purchases.paymentDiscount(for: productDiscount, product: product, completion: { (paymentDiscount, error) in receivedPaymentDiscount = paymentDiscount completionCalled = true receivedError = error @@ -2164,7 +2178,7 @@ class PurchasesTests: XCTestCase { expect(invokedParameters?.attributionData.keys.contains("rc_idfa")) == true expect(invokedParameters?.attributionData.keys.contains("rc_idfv")) == true expect(invokedParameters?.network) == RCAttributionNetwork.appsFlyer - expect(invokedParameters?.appUserID) == self.purchases?.appUserID + expect(invokedParameters?.appUserID) == self.purchases.appUserID } func testAttributionDataSendsNetworkAppUserId() { @@ -2229,7 +2243,7 @@ class PurchasesTests: XCTestCase { func testObserverModeSetToFalseSetFinishTransactions() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -2251,7 +2265,7 @@ class PurchasesTests: XCTestCase { func testDoesntFinishTransactionsIfObserverModeIsSet() { setupPurchasesObserverModeOn() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -2278,7 +2292,7 @@ class PurchasesTests: XCTestCase { initializePurchasesInstance(appUserId: nil) let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -2305,7 +2319,7 @@ class PurchasesTests: XCTestCase { initializePurchasesInstance(appUserId: nil) let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -2328,7 +2342,7 @@ class PurchasesTests: XCTestCase { func testRestoredPurchasesArePosted() { setupPurchasesObserverModeOn() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -2346,7 +2360,7 @@ class PurchasesTests: XCTestCase { setupPurchases() let product = SKProduct() var receivedError: Error? - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in receivedError = error } @@ -2356,7 +2370,7 @@ class PurchasesTests: XCTestCase { func testNoCrashIfPaymentIsMissing() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } let transaction = SKPaymentTransaction() @@ -2371,9 +2385,9 @@ class PurchasesTests: XCTestCase { func testPostsOfferingIfPurchasingPackage() { setupPurchases() - self.purchases!.offerings { (newOfferings, _) in + self.purchases.offerings { (newOfferings, _) in let package = newOfferings!["base"]!.monthly! - self.purchases!.purchasePackage(package) { (tx, info, error, userCancelled) in + self.purchases.purchasePackage(package) { (tx, info, error, userCancelled) in } @@ -2402,10 +2416,10 @@ class PurchasesTests: XCTestCase { setupPurchases() var receivedError: NSError? = nil var secondCompletionCalled = false - self.purchases!.offerings { (newOfferings, _) in + self.purchases.offerings { (newOfferings, _) in let package = newOfferings!["base"]!.monthly! - self.purchases!.purchasePackage(package) { _,_,_,_ in - self.purchases!.purchasePackage(package) { (tx, info, error, userCancelled) in + self.purchases.purchasePackage(package) { _,_,_,_ in + self.purchases.purchasePackage(package) { (tx, info, error, userCancelled) in receivedError = error as NSError? secondCompletionCalled = true } @@ -2433,7 +2447,7 @@ class PurchasesTests: XCTestCase { setupPurchases() self.deviceCache.stubbedIsPurchaserInfoCacheStale = true - self.purchases?.purchaserInfo() { (info, error) in + self.purchases.purchaserInfo() { (info, error) in } @@ -2487,7 +2501,7 @@ class PurchasesTests: XCTestCase { func testReceiptsSendsObserverModeWhenObserverMode() { setupPurchasesObserverModeOn() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -2507,7 +2521,7 @@ class PurchasesTests: XCTestCase { func testReceiptsSendsObserverModeOffWhenObserverModeOff() { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in } @@ -2629,7 +2643,7 @@ class PurchasesTests: XCTestCase { setupPurchases() let product = MockSKProduct(mockProductIdentifier: "com.product.id1") var receivedError: NSError? - self.purchases?.purchaseProduct(product) { (tx, info, error, userCancelled) in + self.purchases.purchaseProduct(product) { (tx, info, error, userCancelled) in receivedError = error as NSError? } diff --git a/StoreKitTestApp/Info.plist b/StoreKitTestApp/Info.plist index d8e42611b7..e89e515c98 100644 --- a/StoreKitTestApp/Info.plist +++ b/StoreKitTestApp/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 3.15.0 + 3.14.1 CFBundleVersion 1 LSRequiresIPhoneOS diff --git a/StoreKitTests/Info.plist b/StoreKitTests/Info.plist index b9ce70b7a3..9454a1c399 100644 --- a/StoreKitTests/Info.plist +++ b/StoreKitTests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 3.15.0 + 3.14.1 CFBundleVersion 1