2017-12-30 18 views
0

アプリストアのサンドボックス環境では動作していますが、Appstoreのバージョンではユーザアカウントからの残高は引き落とされますが、iOS-サンドボックス環境で正しく動作するアプリの購入で、Appstoreのバージョンのコンテンツがロックされていない

コーディングで問題はないと思います。それ以外の場合は、サンドボックス環境では動作しません。私はトランザクションの領収書がゼロである可能性があると思う。

「購入済み」と表示されている商品をクリックして再度購入すると、しかし、それでも、アプリのコンテンツをアンロックしているわけではありません。購入したものを復元するためにクリックしただけでも、それも機能しません。私はすべてがサンドボックス環境で動作しているのに驚きました。

サブスクリプションのタイプ:自動再生可能。 コンテンツのロック解除:オーディオ、ビデオ、およびPDFチュートリアル。
バックエンドログを確認しました。 APIは決して実行されず、ユーザーが正常に購入してもアプリストアの領収書を取得しなかったという唯一の問題があります。すべてがサンドボックス環境で完璧に動作します。

コード:領収書のqueue.finishTransaction(トランザクション)を確認した後

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

     for transaction in transactions { 

      switch transaction.transactionState { 
      case .purchasing: 
       handlePurchasingState(for: transaction, in: queue) 
      case .purchased: 
       handlePurchasedState(for: transaction, in: queue) 
      case .restored: 
       handleRestoredState(for: transaction, queue: queue) 
      case .failed: 
       handleFailedState(for: transaction, in: queue) 
      case .deferred: 
       handleDeferredState(for: transaction, in: queue) 
      } 
     } 
    } 

//On transaction state changed to purchased: 
func handlePurchasedState(for transaction: SKPaymentTransaction, in queue: SKPaymentQueue) { 
     print("User purchased product id: \(transaction.payment.productIdentifier)") 
     print("User purchased product id: \(transaction)") 
     queue.finishTransaction(transaction) 
     self.completeTransaction(transaction:transaction) 
    } 

//In completeTransaction Method: 
func completeTransaction(transaction:SKPaymentTransaction) 
    { 
     if let receiptURL = Bundle.main.appStoreReceiptURL,FileManager.default.fileExists(atPath: receiptURL.path) 
     { 
      let receipt:Data = try! Data(contentsOf: receiptURL) 
      let jsonObjectString = receipt.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)) 
      var strIdentifier:String = transaction.transactionIdentifier! 

      if let identifier = transaction.original?.transactionIdentifier 
      { 
       strIdentifier = identifier 
      } 

     //API call to save receipt to validate later and unlock the content 
     //In case API calling failed then I stored data and called API again on app home page. 
     } 
    } 
+1

私たちは、より詳細な情報を必要とする:こので、コンテンツの種類、それはロックを解除し、あなたのコードを投稿しているIAPの種類。一般的にコンテンツのロックを解除することはアプリの責任であるため、コーディングの問題を除外しません。 –

+0

あなたが尋ねたもので質問を編集しました。チェックしてください。ありがとう。 – Vicky

+0

これで、[this SO question](https://stackoverflow.com/q/20027322/2466193)の答えに記載されているように、refreshReceiptRequestを使ってレシートをリフレッシュしようとしましたか? –

答えて

0

がトランザクションを完了してください

リンゴも「後に取引を終了する前に、すべてのApple-ホストされているコンテンツをダウンロードすることをお勧めします。トランザクションが完了すると、そのダウンロードオブジェクトは使用できなくなります。

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/DeliverProduct.html

関連する問題