Subscription Management by StoreKit2

Store Kit2 was announced in WWDC21 and it simplied process to handle in-app purchase than previous APIs. But still there are some limitation and over iOS 15 is required to use it. In my developing app, I have implemented subscription plan to erase ads space. But I couldn’t find best way as StoreKit2  to directly handle subscription management like cancelling and renewing the subscription in App. One of the way apple providing as of now is sheet to have dedicated subscription management page in App. Other approaches to use store kit 1 methods. To try new way, I tried to use new one instead of that.

Here is instance method in SwiftUI as presentation modifier 

And in internet, there is quite few sample code for that. So let me post my sample with Swift UI. 

Button(action: {
   Task{
      if let windowScene = UIApplication.shared.connectedScenes.first {
         do {
            try await AppStore.showManageSubscriptions(in: windowScene as! UIWindowScene)
         } catch {
         //error
         }
      }
   }
}

It’s easy to implement it in SwiftUI View code as Button. Then clicking the button, The sheet having Subscription plan options including cancelling will be shown on the APP.  Like this.

Also you can see the implementation on below app.

SmartClockBoard(スマートクロックボード)

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.