[SK2] Add Configuration.with(storeKitVersion:) to select the version of StoreKit to use#3487
Conversation
| } | ||
|
|
||
| extension StoreKitVersion { | ||
| var versionString: String { |
|
|
||
| extension StoreKitVersion { | ||
| var versionString: String { | ||
| if isStoreKit2EnabledAndAvailable { |
There was a problem hiding this comment.
Explicit self:
| if isStoreKit2EnabledAndAvailable { | |
| if self.isStoreKit2EnabledAndAvailable { |
|
|
||
| @testable import RevenueCat | ||
|
|
||
| class StoreKitVersionTests: TestCase { |
| "X-Platform-Flavor" : "native", | ||
| "X-Platform-Version" : "Version 17.0.0 (Build 21A342)", | ||
| "X-Storefront" : "USA", | ||
| "X-StoreKit-Version" : "1", |
There was a problem hiding this comment.
This is a better header than X-StoreKit2-Enabled 👍🏻
| /// | ||
| /// ### Related Symbols | ||
| /// - ``StoreKitVersion`` | ||
| @objc public func with(storeKitVersion version: StoreKitVersion) -> Builder { |
There was a problem hiding this comment.
I started doing this for #3066 but ended up removing it. I think it's a better API 👍🏻
|
Looks good in general, but I want to discuss the duplicate flag. |
|
Let's print the configured SK version on SDK initialization too: https://github.com/RevenueCat/purchases-ios/blob/main/Sources/Purchasing/Purchases/Purchases.swift#L556 |
c47b5bd to
f2a0820
Compare
85b2048 to
4886d77
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## sk2-full-flow #3487 +/- ##
=================================================
- Coverage 85.97% 85.97% -0.01%
=================================================
Files 240 240
Lines 17494 17490 -4
=================================================
- Hits 15041 15037 -4
Misses 2453 2453 ☔ View full report in Codecov by Sentry. |
|
|
||
| case response_verification_mode(Signing.ResponseVerificationMode) | ||
|
|
||
| case storekit_version(String) |
There was a problem hiding this comment.
This String could be anything. Better to use StoreKitVersion to make it type safe.
| case storeKit2 | ||
|
|
||
| /// Let RevenueCat use the most appropiate version of StoreKit | ||
| case `default` |
There was a problem hiding this comment.
Instead of making this a case, I think it would make more sense to define it like this:
extension StoreKitVersion {
public static `default`: Self = .storeKit1
}
Since it's technically not a different version.
Then we don't need to consider it separately in all the logic, and to update it we only need to change it in one place.
|
|
||
| extension StoreKitVersion { | ||
|
|
||
| var versionString: String { |
There was a problem hiding this comment.
Nit: putting the type of the value in the name isn't a thing anymore 😅
Maybe we can do this:
extension StoreKitVersion: CustomDebugStringConvertible {
public var debugDescription: {
switch self {} // Let's use a switch, so if we ever add more cases, the compiler reminds us to handle it here.
}
}
There was a problem hiding this comment.
Renamed it to effectiveVersion instead of using the debugDescription mechanism since it does not represent the enum value, but the effective version of StoreKit that's use despite what's configured. Added a docstring comment too.
NachoSoto
left a comment
There was a problem hiding this comment.
Let's agree one what to do with StoreKit2Setting
| expect(self.receiptFetcher.receiptDataReceivedRefreshPolicy) == .onlyIfEmpty | ||
| } | ||
|
|
||
| func testPurchaseSK1PackageRetriesReceiptFetchIfEnabled() async throws { |
There was a problem hiding this comment.
Functionally equivalent to the removed test below, but uses SK1, since SK2 does not post receipts now.
| public extension StoreKitVersion { | ||
|
|
||
| /// Let RevenueCat use the most appropiate version of StoreKit | ||
| static var `default` = Self.storeKit1 |
There was a problem hiding this comment.
Oops! This is mutable , meaning you can do
StoreKitVersion.default = .storeKit2 😬
| static var `default` = Self.storeKit1 | |
| static let `default`: Self = .storeKit1 |
|
|
||
| /// Returns a string representing the effective version of StoreKit used. | ||
| /// This can be different from the configured version if StoreKit 2 is not available on the current device. | ||
| var effectiveVersion: String { |
There was a problem hiding this comment.
It seems like this is doing 2 things:
- Detecting the effective
StoreKitVersion - Converting to
String
I'd change this to
| var effectiveVersion: String { | |
| var effectiveVersion: StoreKitVersion { |
Then maybe using my CustomDebugStringConvertible suggestion?
|
|
||
| Simply remove this method call to let RevenueCat decide for you which StoreKit implementation to use. | ||
| """) | ||
| @available(*, deprecated, message: "Use .with(storeKitVersion:) to enable StoreKit 2") |
|
|
||
| Logger.debug(Strings.configure.debug_enabled, fileName: nil) | ||
| if systemInfo.storeKit2Setting == .enabledForCompatibleDevices { | ||
| if systemInfo.storeKitVersion.isStoreKit2EnabledAndAvailable { |
There was a problem hiding this comment.
Maybe we can remove this now that we have the generic storekit_version below?
| @@ -0,0 +1,50 @@ | |||
| { | |||
There was a problem hiding this comment.
Oops, can you remove this file?
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
…n of StoreKit to use (#3487) This PR introduces a new configuration option to select the StoreKit version to use. It supersedes the deprecated `.with(usesStoreKit2IfAvailable: true)` and the internal `usesStoreKit2JWS` configuration options. Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable. Example usage: ```swift Purchases.configure( with: .builder(withAPIKey: apiKey) .with(storeKitVersion: .storeKit2) .build() ```
This PR introduces a new configuration option to select the StoreKit version to use.
It supersedes the deprecated
.with(usesStoreKit2IfAvailable: true)and the internalusesStoreKit2JWSconfiguration options.Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable.
Example usage: