Cancel auto-renewal subscriptions with Swift

18.2k Views Asked by At

I want to create a button where a user can cancel a auto-renewal subscription (or get redirected to App Store).

Is that possible without the user having to go through the whole purchase process first? If it is, how would you go about doing it?

5

There are 5 best solutions below

5
On BEST ANSWER

From the Apple In-App Purchase Programming Guide -

Rather than needing to code your own subscription management UI, your app can open the following URL:

https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions Opening this URL launches iTunes or iTunes Store, and then displays the Manage Subscription page.

So, simply create a button that launches that URL.

UIApplication.shared.openURL(URL(string: "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions")!)
0
On

As mentioned in the documentation: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html#//apple_ref/doc/uid/TP40008267-CH7-SW19

So for Swift 3/4 just use this

UIApplication.shared.openURL(URL(string: "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions")!)
2
On

December 2019

The correct URL is now https://apps.apple.com/account/subscriptions according to Apple's Handling Subscriptions Billing Documentation.

So just use:

UIApplication.shared.open(URL(string: "https://apps.apple.com/account/subscriptions")!)
1
On

April 2021

According to the Apple Document, the URL has been updated to

https://apps.apple.com/account/subscriptions

So the following code can be used to redirect the user to manage subscriptions page.

DispatchQueue.main.async {
      UIApplication.shared.open(URL(string: "https://apps.apple.com/account/subscriptions")!, options: [:], completionHandler: nil)
    }
0
On

iOS 10 and above

UIApplication.shared.open(URL(string: "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions")!, options: [:], completionHandler: nil)