Skip to main content
Solved

Converting paid app into subscription


Forum|alt.badge.img+4

Hello, 

First of all I want to thank you for this great framework. My app has been downloaded more that 20K, now I am about to release the the new update, and also, I have read this article.

Just have a question, my new update version for both app version and build is 11.0, so I need to detect if the originalApplicationVersion  of previous users (who bought the app) is less than 11 the app should unlock the premium version. So I am doing it like this, and I was wondering am I doing it right?

First setup configurations:

init() {
		Purchases.logLevel = .debug
		Purchases.configure(
			with: Configuration.Builder(withAPIKey: "appl_mj*****")
				.with(usesStoreKit2IfAvailable: true)
				.build()
		)
		Purchases.shared.delegate = PurchasesDelegateHandler.shared
	}

and then detecting it using delegate:

func purchases(_ purchases: Purchases, receivedUpdated customerInfo: CustomerInfo) {
        SubscriptionManager.shared.customerInfo = customerInfo

		if let version = Double(customerInfo.originalApplicationVersion!) {
			if version < 11.0 {
				print("premium unlocked")
			}
		}
    }

as the article mentioned the sandbox always gives me version 1.0. So I was wondering is this the right approach to release the app on the app store?

Thanks!

Best answer by NachoSoto

What you’re doing makes sense, but keep in mind that CustomerInfo.originalApplicationVersion is Optional, so I would recommend changing the code to:

if let originalVersion = customerInfo.originalApplicationVersion, let version = Double(originalVersion), version < 11.0 {

 

View original
Did this post help you find an answer to your question?

3 replies

NachoSoto
Forum|alt.badge.img+5
  • Active Helper
  • 22 replies
  • Answer
  • July 14, 2022

What you’re doing makes sense, but keep in mind that CustomerInfo.originalApplicationVersion is Optional, so I would recommend changing the code to:

if let originalVersion = customerInfo.originalApplicationVersion, let version = Double(originalVersion), version < 11.0 {

 


Forum|alt.badge.img+4
NachoSoto wrote:

What you’re doing makes sense, but keep in mind that CustomerInfo.originalApplicationVersion is Optional, so I would recommend changing the code to:

if let originalVersion = customerInfo.originalApplicationVersion, let version = Double(originalVersion), version < 11.0 {

 

Thank you so much, is there any possible way to test it in real situation? like test flight or something?


NachoSoto
Forum|alt.badge.img+5
  • Active Helper
  • 22 replies
  • July 14, 2022

As mentioned in that article, the version will always be 1.0 outside of production. @cody himself has a Package where he uses an override to be able to test this in sandbox: https://github.com/codykerns/PurchasesHelper/blob/main/Sources/PurchasesHelper/CompatibilityAccessManager.swift#L37


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings