Cancel auto-renewal subscriptions with Swift

13,655

Solution 1

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")!)

Solution 2

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")!)

Solution 3

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")!)
Share:
13,655
Nikolaj Simonsen
Author by

Nikolaj Simonsen

As a very passionate iOS developer I have gained a lot of knowledge since I developed my first iOS app 11 years ago. I have developed several apps that has been used by many hundred-thousands of users. I always strive to write efficient, readable and scalable code, which makes it easy for my team members and future developers to understand and further develop my code. I also have experience leading iOS teams and architecting large iOS projects - combined with how I am as a developer I am both able to focus on the details and also zoom out to see the bigger picture.

Updated on June 04, 2022

Comments

  • Nikolaj Simonsen
    Nikolaj Simonsen almost 2 years

    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?