简体   繁体   English

iPhone应用程序:应用程序内购买

[英]iPhone App : In App Purchase

In iPhone App for in App Purchase: when is SKPaymentTransactionStateRestored: called? 在iPhone App中购买的应用程序中:什么时候调用SKPaymentTransactionStateRestored :?

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
    for (SKPaymentTransaction *transaction in transactions) {
      switch (transaction.transactionState) {
      case SKPaymentTransactionStateRestored:
        [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
        break;
      }
    }
}

And how to get confirmation from apple that the app is purchased successfully means I want to Print that information in NSlog. 以及如何从苹果确认已成功购买该应用程序,这意味着我想在NSlog中打印该信息。

what should I write for that? 我应该为此写些什么?

就我而言,仅当Apple将updateTransactions状态响应为SKPaymentTransactionStateRestoredSKPaymentTransactionStatePurchasedtransactions才能成功购买。

When the method: 当方法:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray     *)transactions{

     for (SKPaymentTransaction * transaction in transactions) {        

        //process the transaction
        switch (transaction.transactionState) {
            case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
                break;
           default:
                break;
    }

        }

} }

is called it means that you have finished your transaction with apple and you handle three cases: 称为,表示您已完成与Apple的交易,并处理三种情况:

SKPaymentTransactionStatePurchased: it means that your product was bought. 已购买SKPaymentTransactionStatePurchased:这表示您的产品已购买。

SKPaymentTransactionStateFailed: your product couldn't be bought. SKPaymentTransactionStateFailed:您的产品无法购买。

SKPaymentTransactionStatePurchased: This is your question. 购买的SKPaymentTransactionState:这是您的问题。 As long as your SKPaymentTransactionObserver is alive the transaction is persistant, meaning that if your client intended to buy you product but something wrong happened while delivering the product (server error or something else), when the app starts again the transaction will return to this method to finish the purchase. 只要您的SKPaymentTransactionObserver处于活动状态,交易就将持续存在,这意味着如果您的客户打算购买您的产品,但在交付产品时发生了错误(服务器错误或其他原因),则当应用再次启动时,交易将返回此方法完成购买。

I hope the info helps. 希望该信息对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM