-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SK2] Add Configuration.with(storeKitVersion:)
to select the version of StoreKit to use
#3487
Conversation
Sources/Misc/StoreKitVersion.swift
Outdated
} | ||
|
||
extension StoreKitVersion { | ||
var versionString: String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: spacing here
Sources/Misc/StoreKitVersion.swift
Outdated
|
||
extension StoreKitVersion { | ||
var versionString: String { | ||
if isStoreKit2EnabledAndAvailable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicit self
:
if isStoreKit2EnabledAndAvailable { | |
if self.isStoreKit2EnabledAndAvailable { |
|
||
@testable import RevenueCat | ||
|
||
class StoreKitVersionTests: TestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
@@ -12,6 +12,7 @@ | |||
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@@ -37,6 +37,8 @@ enum ConfigureStrings { | |||
|
|||
case response_verification_mode(Signing.ResponseVerificationMode) | |||
|
|||
case storekit_version(String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This String
could be anything. Better to use StoreKitVersion
to make it type safe.
Sources/Misc/StoreKitVersion.swift
Outdated
case storeKit2 | ||
|
||
/// Let RevenueCat use the most appropiate version of StoreKit | ||
case `default` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Sources/Misc/StoreKitVersion.swift
Outdated
|
||
extension StoreKitVersion { | ||
|
||
var versionString: String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Objc throwback 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's agree one what to do with StoreKit2Setting
@@ -449,6 +447,51 @@ class PurchasesOrchestratorTests: StoreKitConfigTestCase { | |||
expect(self.receiptFetcher.receiptDataReceivedRefreshPolicy) == .onlyIfEmpty | |||
} | |||
|
|||
func testPurchaseSK1PackageRetriesReceiptFetchIfEnabled() async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally equivalent to the removed test below, but uses SK1, since SK2 does not post receipts now.
Sources/Misc/StoreKitVersion.swift
Outdated
public extension StoreKitVersion { | ||
|
||
/// Let RevenueCat use the most appropiate version of StoreKit | ||
static var `default` = Self.storeKit1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! This is mutable , meaning you can do
StoreKitVersion.default = .storeKit2 😬
static var `default` = Self.storeKit1 | |
static let `default`: Self = .storeKit1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omg good catch 😅
Sources/Misc/StoreKitVersion.swift
Outdated
|
||
/// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
@@ -548,7 +548,7 @@ public typealias StartPurchaseBlock = (@escaping PurchaseCompletedBlock) -> Void | |||
} | |||
|
|||
Logger.debug(Strings.configure.debug_enabled, fileName: nil) | |||
if systemInfo.storeKit2Setting == .enabledForCompatibleDevices { | |||
if systemInfo.storeKitVersion.isStoreKit2EnabledAndAvailable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 internalusesStoreKit2JWS
configuration options.Uses JWS tokens instead of SK1 receipts when in StoreKit 2 mode where applicable.
Example usage: