4.8 C
New York
Tuesday, January 28, 2025

ios – Enterprise mannequin modifications through the use of the app transaction – StoreKit 2


I’m attempting to alter my enterprise mannequin inside the app, and following Apple’s documentation tips HERE I created this job in the principle view of the app. It appears to work completely within the simulator, on bodily gadgets, and on TestFlight. Nevertheless, after releasing it to manufacturing and importing the brand new model to the App Retailer, it doesn’t work, and all customers, whether or not new or current, are requested to subscribe. Within the console, it seems to retrieve the transactions accurately, however in manufacturing, I’m undecided methods to view the console or see what it’s retrieving.

Right here the sandbox receipt I obtained

AppTransaction.shared obtained: {
  "applicationVersion" : "1",
  "bundleId" : "com.anestesiaIB.Medication-Infusion-Calc",
  "deviceVerification" : "6M0Nnw14nSEOBVTPE//EfnWSwLm7LFSlrpFEwxgH74SBHp5dSzBEm896Uvo42mwr",
  "deviceVerificationNonce" : "8a8238c0-0aee-41e6-bfb0-1cfc52b70fb6",
  "originalApplicationVersion" : "1.0",
  "originalPurchaseDate" : 1375340400000,
  "receiptCreationDate" : 1737577840917,
  "receiptType" : "Sandbox",
  "requestDate" : 1737577840917
}


This are the processing log whereas verified the receipt

New enterprise mannequin change: 1.7
Unique versionéis parts: ["1", "0"]
Main model: 1, Minor model: 0
This person is premium. Unique model: 1.0

That is my job…

        .job {
            do {
                let shared = attempt await AppTransaction.shared
                if case .verified(let appTransaction) = shared {
                    let newBusinessModelVersion = (1, 7) // Representado como (main, minor)
                    let versionComponents = appTransaction.originalAppVersion.break up(separator: ".")
                    if let majorVersion = versionComponents.first.flatMap({ Int($0) }),
                       let minorVersion = versionComponents.dropFirst().first.flatMap({ Int($0) }) {
                        if (majorVersion, minorVersion) < newBusinessModelVersion {
                            self.premiumStatus.isPremium = true
                            isPremium = true    
                        } else {
                          
                            let customerInfo = attempt await Purchases.shared.customerInfo()
                            self.premiumStatus.isPremium = customerInfo.entitlements["premium"]?.isActive == true
                            isPremium = self.premiumStatus.isPremium
                        }
                    } else {
                        print("Error: obteining model parts")
                    }
                } else {
                    print("Not verified")
                }
            } catch {
                print("Error processing transaction: (error.localizedDescription)")
            }
        }

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles