Skip to content
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

Storefront: added sk1CurrentStorefront for Objective-C #1614

Merged
merged 2 commits into from May 31, 2022

Conversation

NachoSoto
Copy link
Contributor

Fixes https://community.revenuecat.com/sdks-51/objective-c-how-to-access-rcstorefront-1647?postid=5154#post5154

RCStoreFront does have a currentStorefront property which supports StoreKit 1 and StoreKit 2, but due to the fact that the SK2 way of obtaining the current storefront is async, this property is only async, which means that it indeed isn’t available on Objective-C.

This adds a way to be able to access the current storefront from Objective-C.

Fixes https://community.revenuecat.com/sdks-51/objective-c-how-to-access-rcstorefront-1647?postid=5154#post5154

`RCStoreFront` does have a `currentStorefront` property which supports StoreKit 1 and StoreKit 2, but due to the fact that the SK2 way of obtaining the current storefront is `async`, this property is only `async`, which means that it indeed isn’t available on Objective-C.

This adds a way to be able to access the current storefront from Objective-C.
@NachoSoto NachoSoto requested a review from a team May 25, 2022 23:35
/// The current App Store storefront for the device obtained from StoreKit 1 only.
/// - Note: this method is intended to be used only from Objective-C.
/// In Swift, ``Storefront/currentStorefront`` is preferred.
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, macCatalyst 13.1, *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can also enforce this at the compiler level? I.e.:

Suggested change
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, macCatalyst 13.1, *)
@available(swift, obsoleted: 0.0.1, message: "In Swift, ``Storefront/currentStorefront`` is preferred.")
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, macCatalyst 13.1, *)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG that's right!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'unavailable' cannot be used in 'available' attribute for platform 'swift'

LOL okay...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a rename too:
Screen Shot 2022-05-31 at 09 53 08

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I tried unavailable before posting, then I went with obsoleted when I ran into the same thing 😂
the rename is a great idea!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that comment was from me ^ I logged into that account to set up an automation and forgot 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha I remain unconvinced you're not a robot 🙃

@NachoSoto NachoSoto requested a review from aboedo May 31, 2022 16:54
@NachoSoto NachoSoto merged commit 2be3d02 into main May 31, 2022
@NachoSoto NachoSoto deleted the current-storefront-objc branch May 31, 2022 17:16
@NachoSoto NachoSoto mentioned this pull request Jun 2, 2022
NachoSoto added a commit that referenced this pull request Jun 2, 2022
### New Features
* `Purchases.customerInfo()`: added overload with a new `CacheFetchPolicy` (#1608) via NachoSoto (@NachoSoto)
* `Storefront`: added `sk1CurrentStorefront` for Objective-C (#1614) via NachoSoto (@NachoSoto)

### Bug Fixes
* Fix for not being able to read receipts on watchOS (#1625) via Patrick Busch (@patrickbusch)

### Other Changes
* Added tests for `PurchasesOrchestrator` invoking `listenForTransactions` only if SK2 is enabled (#1618) via NachoSoto (@NachoSoto)
* `PurchasesOrchestrator`: removed `lazy` hack for properties with `@available` (#1596) via NachoSoto (@NachoSoto)
* `PurchasesOrchestrator.purchase(sk2Product:promotionalOffer:)`: simplified implementation with new operator (#1602) via NachoSoto (@NachoSoto)
@aboedo aboedo mentioned this pull request Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants