I am using the showManageSubscriptions(in:) function to show the iOS native subscription manager screen. It shows the subscription manager screen and lets me make changes to the subscription, but when I close the Subscription Manager view the app crash. How can I close the Subscription Manager View and show the view controller that is behind it without the app crashing?
I am using Xcode 13.4.1 and swift 5.5
Apple Documentation for showManagerSubscription(in:) https://developer.apple.com/documentation/storekit/appstore/3803198-showmanagesubscriptions
import UIKit
import StoreKit
class ViewController: UIViewController {
@IBOutlet var managerBtn: UIButton!
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
managerBtn.addTarget(self, action: #selector(manageSubscription), for: .touchUpInside)
}
@MainActor
@objc func manageSubscription() async throws {
// if var window = self.view.window?.windowScene {
if let window = UIApplication.shared.connectedScenes.first as? UIWindowScene {
do {
try await AppStore.showManageSubscriptions(in: window )
} catch {
print(error)
}
}
}}