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?
Topic:
App & System Services
SubTopic:
StoreKit
Tags: