IAP for non consumable

I'm just updating my app after a long break. I am aware that Apple decided to remove hosting the pkg file for non consumable in app purchases. Does anyone know of a good guide to using external hosting of these packages and how to link them to my app?

Just to clarify...

Where do I host the PKG file? How do I add the URL in the main app or do I have to do this in apple connect?

Where do I host the PKG file?

On some web server of your choice. (E.g. AWS S3 or similar.)

How do I add the URL in the main app or do I have to do this in apple connect?

You need to implement all the code to securely download it yourself. You don’t just “add the URL” somewhere.


private let serverURL = "https://example.com/package.pkg"

func downloadPackage() {
        guard let packageURL = URL(string: serverURL) else {
            print("Failed to create URL for package")
            return
        }
        
        let downloadTask = URLSession.shared.downloadTask(with: packageURL) { (url, response, error) in
            if let error = error {
                print("Failed to download package: \(error.localizedDescription)")
                return
            }
            
            guard let fileURL = url else {
                print("Failed to retrieve downloaded file URL")
                return
            }
            
            // Move the downloaded file to desired location
            let fileManager = FileManager.default
            let documentsDirectoryURL = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first!
            let destinationURL = documentsDirectoryURL.appendingPathComponent("package.pkg")
            
            do {
                try fileManager.moveItem(at: fileURL, to: destinationURL)
                print("Package downloaded successfully")
                // Perform further actions with the downloaded package
            } catch let error {
                print("Failed to move downloaded package: \(error.localizedDescription)")
            }
        }
        downloadTask.resume()
    }
}

// Usage:

let inAppPurchaseManager = InAppPurchaseManager()
inAppPurchaseManager.startObservingTransactions()

// Call purchaseProduct() method when user completes the in-app purchase
inAppPurchaseManager.purchaseProduct(productId: "com.example.package") // Replace with your product identifier

Do you think this accepted by Apple? I've had the non consumable IAP approved by Apple but how does Apple verify the package? is this done by Xcode when I create the archive?

IAP for non consumable
 
 
Q