Search code examples
ioscocoa-touchapp-storein-app-purchase

How to open the subscriptions page of the App Store app programmatically?


If you have a subscription with two different possible lengths in your iOS app, and the user, who has purchased the shorter subscription, decides to purchase the longer subscription instead, they get prompted with this dialog:

enter image description here

Tapping Settings takes the user to the App Store app and opens the page where they can manage their subscriptions. Most probably Cocoa simply uses a custom scheme URL (e.g. appstore://pages/subscriptions) to achieve this.

What is this URL? Is there another way to open the subscriptions page in the App Store app programmatically?


Solution

  • The subscription docs suggest that you can open the subscriptions management page using the following URL

    https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html#//apple_ref/doc/uid/TP40008267-CH7-SW8

    So something like

            let subscriptionURL = URL.init(string: "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions")!
            UIApplication.shared.open(subscriptionURL)
    

    this does work; though it's somewhat indirect. The link opens in Safari which then redirects through to the store link. The redirect is actually to

    itmss://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions

    so I'm using that directly in my app - though of course it isn't guaranteed to be stable.

    NB: Sandbox Subscriptions will not appear in this page. You'll have to do a trial signup to some other live service to have anything to see when you test.