Solved

Converting paid app into subscription

  • 14 July 2022
  • 3 replies
  • 106 views

Badge +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!

icon

Best answer by NachoSoto 14 July 2022, 21:13

View original

3 replies

Userlevel 1
Badge +5

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

Userlevel 1
Badge +5

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 {

 

Badge +4

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?

Reply