Question

iOS: reliably get originalApplicationVersion without prompting for AppStore login

  • 30 May 2022
  • 1 reply
  • 225 views

Badge +2

Hello all,

I’d like to check the originalApplicationVersion for my iOS app, without prompting the user to login to their AppStore account.

Your “converting a paid iOS app to subscription” blogpost has the following code, which looks like it should do what I want:

if let receiptURL = Bundle.main.appStoreReceiptURL,

   let _ = try? Data(contentsOf: receiptURL) {

    Purchases.shared.restoreTransactions { (info, error) in

        completion?(info)

    }

}
 

This implies that it’s safe to call restoreTransactions if we’re certain that there is a receipt on the device.

However, the (recently renamed) restoreTransactions function has a refresh policy of .always, which I suspect might prompt the user to login.

So my questions:

  • will restoreTransactions ever prompt for AppStore login if there is a receipt on the device?
  • if that function might prompt, is there a reliable way to get originalApplicationVersion from an on-device receipt without prompting?

Thank-you!

  Matthew

 


1 reply

Badge +2

Ooh, new in iOS 16: AppTransaction.shared.originalAppVersion 🎖

https://developer.apple.com/documentation/storekit/apptransaction

 

Reply