StoreKit 2 How to get the product id that will be used when the subscription auto-renews

I'm working on implementing the new StoreKit 2 api in my iOS app. I offer auto-renewing subscriptions to my users. I have lots of different product levels each that come with yearly or monthly charging options.

Let's say a user has a yearly auto-renewing subscription that is paid through April 2024. In Sept 2023, they decide to downgrade to a monthly product. Their yearly product stays in place until it expires and then when the subscription auto-renews in April 2024, it will renew as monthly instead.

How do I look up what product id they downgraded to? When I look in the renewalInfo struct, it will give me info on if they will renew, when they will renew, and it'll give me their currentProductId... but I need the next product id. The one that they downgraded to, the monthly one. When their subscription to the yearly product expires, they'll renew as a different (monthly) product.

if let status = try? await self.subscriptionProducts.first?.subscription?.status.first {
    if let renewalInfo = try? self.checkVerified(status.renewalInfo) {
        // ... 
    }
}

I can't figure out how to access that info so that I can properly present the info in their Account screen. If my users were on a yearly product and last week they chose to downgrade to a monthly product, I need to show them that they are finishing their yearly sub and will auto-renew as monthly. I can't just show them that they are on the yearly sub, because they'll get confused because they know they downgraded to monthly.

In StoreKit 2 the field you're looking for is autoRenewPreference:

https://developer.apple.com/documentation/storekit/product/subscriptioninfo/renewalinfo/3749495-autorenewpreference

In the App Store Server API, the field is called autoRenewProductId:

https://developer.apple.com/documentation/appstoreserverapi/autorenewproductid

Hope this helps!

Hi,

do you have the solution? I try to figure out how to get the the autoRenewReference struct, but no clue.

I am facing with the same issue, what you have discribed.

Thanks for sharing the solution.

StoreKit 2 How to get the product id that will be used when the subscription auto-renews
 
 
Q