SwiftyStoreKit icon indicating copy to clipboard operation
SwiftyStoreKit copied to clipboard

Downloading stopped at 0%

Open zhouhao27 opened this issue 4 years ago • 2 comments

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.

zhouhao27 avatar Jul 27 '20 11:07 zhouhao27

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)
      }
    }

zhouhao27 avatar Jul 27 '20 13:07 zhouhao27

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?

zhouhao27 avatar Jul 28 '20 02:07 zhouhao27