Wednesday, October 28, 2026
HomeiOS Developmentios - Do I have to implement in app purchases to verify...

ios – Do I have to implement in app purchases to verify app retailer receipt?

[ad_1]

I am wish to flip my paid iOS app to a free one. I would like the paid customers to have all of the options they paid for, and the free customers will get different options.

All of the tutorials for app validation are very difficult for me and appear to contain IAP.

I merely simply wish to verify the unique obtain model of the App, (not IAP) & the unique buy date if potential and parse that so I can setup the app accurately.

My code is performing as if a receipt doesn’t exist after I run on simulator or on gadget, I am unsure how ot get a receipt so I can take a look at this, do I have to arrange an IAP with a purpose to get the preliminary receipt? Have been caught at this for days so any assist can be aprecieated!

Right here is my code for validating the receipt which I discovered from a tutorial, it returns nothing:

func validateReceipt() {

        #if DEBUG

                   let urlString = "https://sandbox.itunes.apple.com/verifyReceipt"

               #else

                   let urlString = "https://purchase.itunes.apple.com/verifyReceipt"

               #endif

        guard let receiptURL = Bundle.fundamental.appStoreReceiptURL, let receiptString = attempt? Knowledge(contentsOf: receiptURL).base64EncodedString() , let url = URL(string: urlString) else {

                return

            }

        let requestData : [String : Any] = ["receipt-data" : receiptString,

                                            "password" : sharedSecret,

                                            "exclude-old-transactions" : false]

        let httpBody = attempt? JSONSerialization.information(withJSONObject: requestData, choices: [])

        var request = URLRequest(url: url)

        request.httpMethod = "POST"

        request.setValue("Software/json", forHTTPHeaderField: "Content material-Kind")

        request.httpBody = httpBody

        URLSession.shared.dataTask(with: request)  { (information, response, error) in

            // convert information to Dictionary and look at purchases
            DispatchQueue.fundamental.async {

                if let information = information, let jsonData = attempt? JSONSerialization.jsonObject(with: information, choices: .allowFragments){

                // your non-consumable and non-renewing subscription receipts are in `in_app` array
                    
                    print("JSON Knowledge: ", jsonData)

                // your auto-renewable subscription receipts are in `latest_receipt_info` array

                }

            }

        }.resume()
    
    }

How can I get a receipt and verify the unique buy date/model so I can honor the paid app customers and alter this right into a free app?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments