ios – Enterprise mannequin adjustments by utilizing the app transaction – StoreKit 2

ios – Enterprise mannequin adjustments by utilizing the app transaction – StoreKit 2


I’m making an attempt to alter my enterprise mannequin inside the app, and following Apple’s documentation pointers HERE I created this activity in the primary 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 unsure the best way 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.Medicine-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 consumer is premium. Unique model: 1.0

That is my activity…

        .activity {
            do {
                let shared = strive 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 = strive 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)")
            }
        }

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.