0 Replies
      Latest reply on Aug 8, 2019 1:23 PM by brduffy
      brduffy Level 1 Level 1 (0 points)

        Hi,

         

        I have been testing an IAP in my app. The payment succeeds but when I test the count property on transaction.downloads it is 0. I have uploaded my content for the product and the product shows the content package date and time of upload in the details on App Store Connect. I didn't have any trouble uploading the product according to these instructions ... https://codingexpedition.wordpress.com/2017/11/10/how-to-upload-ios-in-app-purchase-content-using-xcode-9-1/

        My IAP's status are "Waiting for Upload" (I don't know if that makes any difference). I don't want to submit the app or the IAP's for review before testing the download of hosted content. Any ideas?

         

        Thanks

         

        Brian Duffy

         

        /// Extends StoreObserver to conform to SKPaymentTransactionObserver.

        extension StoreObserver: SKPaymentTransactionObserver {

          /// Called when there are transactions in the payment queue.

          func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {

          for transaction in transactions {

          switch transaction.transactionState {

          case .purchasing: break

          // Do not block your UI. Allow the user to continue using your app.

          case .deferred: print(Messages.deferred)

          // The purchase was successful.

          case .purchased: handlePurchased(transaction)

                        print("success")

                        if transaction.downloads.count > 0 {

                            print("downloadable") // Can't see the hosted content here for some reason !!!!!!!!!!!!!!!

                        }

          // The transaction failed.

          case .failed: handleFailed(transaction)

                        print("failure")

                    // There are restored products.

          case .restored: handleRestored(transaction)

          @unknown default: fatalError("\(Messages.unknownDefault)")

          }

          }

          }

         

          /// Logs all transactions that have been removed from the payment queue.

          func paymentQueue(_ queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction]) {

          for transaction in transactions {

          print ("\(transaction.payment.productIdentifier) \(Messages.removed)")

          }

          }

         

          /// Called when an error occur while restoring purchases. Notify the user about the error.

          func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: Error) {

          if let error = error as? SKError, error.code != .paymentCancelled {

          DispatchQueue.main.async {

          self.delegate?.storeObserverDidReceiveMessage(error.localizedDescription)

          }

          }

          }

         

          /// Called when all restorable transactions have been processed by the payment queue.

          func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {

          print(Messages.restorable)

         

          if !hasRestorablePurchases {

          DispatchQueue.main.async {

          self.delegate?.storeObserverDidReceiveMessage(Messages.noRestorablePurchases)

          }

          }

          }

        }