I decided to use a different approach:
@objc
class MyAppTransaction: NSObject{
@objc
class func checkReceipt() async -> String {
var appTransaction: VerificationResult<AppTransaction>?
do {
appTransaction = try await AppTransaction.shared
}
catch {
appTransaction = try? await AppTransaction.refresh()
}
do {
switch appTransaction {
case .verified(_):
return "VERIFIED"
case .unverified(_, _):
return "NO RECEIPT"
default: return "ERROR"
}
}
}
}
When my program executes the refresh() method it prompts me for my Sandbox user name and password, using two-factor authentication on my phone. Then in subsequent executions of the application it doesn't. I assume that this means that the receipt stays in the application bundle. Also I assume that refresh() won't be executed when my end users launch the application because the App Store will already have attached a valid receipt. Is this correct? Couldn't I comment out the refresh() in the final build I send to the App Store?
Topic:
App & System Services
SubTopic:
StoreKit
Tags: