SwiftyStoreKit
SwiftyStoreKit copied to clipboard
Downloading stopped at 0%
Here is my code:
SwiftyStoreKit.updatedDownloadsHandler = { downloads in
// contentURL is not nil if downloadState == .finished
let contentURLs = downloads.compactMap { $0.contentURL }
for download in downloads {
print("\(download.progress)")
}
if contentURLs.count == downloads.count {
downloads.forEach { [weak self] (download) in
self?.procesessDownload(downloadURL: download.contentURL, productId: download.contentIdentifier)
}
SwiftyStoreKit.finishTransaction(downloads[0].transaction)
}
}
I have 3 IAP items. The first one is ok. I can download after purchase. The other 2 are not working after purchase. It stopped at progress 0. Don't know the reason. How should I debug it? Thanks.
My purchase function is:
SwiftyStoreKit.purchaseProduct(productId, atomically: false) { result in
if case .success(let purchase) = result {
let downloads = purchase.transaction.downloads
if !downloads.isEmpty {
SwiftyStoreKit.start(downloads)
}
// Deliver content from server, then:
if purchase.needsFinishTransaction {
SwiftyStoreKit.finishTransaction(purchase.transaction)
}
} else if case .error(let error) = result {
complete(false, error.localizedDescription)
}
}
I think this is the code which cause the issue:
// Deliver content from server, then:
if purchase.needsFinishTransaction {
SwiftyStoreKit.finishTransaction(purchase.transaction)
}
Is it a bug?