purchases-ios icon indicating copy to clipboard operation
purchases-ios copied to clipboard

`showManageSubscriptions` and `beginRefundRequest`: swiftUI view modifiers

Open aboedo opened this issue 3 years ago • 9 comments

For SwiftUI apps, we should provide view modifiers to make it easy to use showManageSubscriptions and beginRefundRequest.

We can use #if canImport(SwiftUI) to only declare these when SwiftUI types are available.

For reference, here are the view modifiers declared by StoreKit.

// Available when SwiftUI is imported with StoreKit
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {

    public func manageSubscriptionsSheet(isPresented: Binding<Bool>) -> some View

}

// Available when SwiftUI is imported with StoreKit
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
extension View {

    public func refundRequestSheet(for transactionID: UInt64, isPresented: Binding<Bool>, onDismiss: ((Result<Transaction.RefundRequestStatus, Transaction.RefundRequestError>) -> ())? = nil) -> some View

}

https://app.shortcut.com/revenuecat/story/11882/showmanagesubscriptions-and-beginrefundrequest-swiftui-view-modifiers

aboedo avatar Dec 13 '21 21:12 aboedo

Love it! I'd like to do it if it's still available :)

Juanpe avatar Dec 14 '21 15:12 Juanpe

I imagine we will grow SwiftUI extensions a lot over time. We might want to offer them separately eventually, or maybe now? There's something to be said about thin frameworks, and if a user doesn't need SwiftUI it doesn't make sense to include it for everyone IMO.

NachoSoto avatar Dec 14 '21 15:12 NachoSoto

🤔 Good point.

My two cents. Maybe not now, but as you said, there could be another UI related framework to isolate the Core layer from the UI.

Juanpe avatar Dec 14 '21 17:12 Juanpe

Yeah, I think it'd be nice and easy to set up as a separate pod and swift package. It'd also allow us to provide other extensions for SwiftUI to make life a lot easier for devs

aboedo avatar Jan 04 '22 13:01 aboedo

Hey 👋

I spotted the thread when I was looking here and there. It has the you can do this tag, so is it something that I can contribute to or the topic is on hold?

Zaprogramiacz avatar Nov 07 '22 10:11 Zaprogramiacz

Hey @Zaprogramiacz! 👋

You are absolutely welcome to contribute to this! We're more than happy to review and to assist with any questions you have along the way 💪

aboedo avatar Nov 07 '22 14:11 aboedo

Oh great 💪🏻

Do you have any documentation, task with AC or desired dreamed solution? I don't have an access to the link from the first post and I bet that I might find there useful info.

In the thread I saw that last idea was to setup a separate pod and swift package with SwiftUI extensions. Is it still the main idea that should be followed?

Zaprogramiacz avatar Nov 07 '22 17:11 Zaprogramiacz

Hey, sorry for the late reply. Yeah, that's still the main idea, to have a separate SPM package and maybe also a pod, with just the SwiftUI extensions

aboedo avatar Nov 23 '22 22:11 aboedo