获取购买的产品列表,inApp购买iPhone [英] Get list of purchased products, inApp Purchase iPhone

查看:240
本文介绍了获取购买的产品列表,inApp购买iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的iOS应用程序购买应用程序。由于没有恢复购买的产品,Apple拒绝了我的二进制文件。在我的应用程序中,一旦用户点击产品图标(如果项目被锁定),他/她将指向inApp购买流程,否则产品将被打开。没有可视购买按钮。现在苹果说要提供恢复按钮?谁能告诉我如何处理这个问题?我试过了

I am implementing in app purchases for my iOS application. Apple has rejected my binary for not restoring purchased products. In my application once the user taps the icon of product if item is locked he/she directed to inApp purchase process else the products gets openend. There is no visual Buy button. Now apple is saying to provide the restore button? Can anybody tell me how to handle this? I have tried

- (void) checkPurchasedItems
{
    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}// Call This Function

//Then this delegate Function Will be fired
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
    alreadyPurchasedItems = [[NSMutableArray alloc] init];

    NSLog(@"received restored transactions: %i", queue.transactions.count);
    for (SKPaymentTransaction *transaction in queue.transactions)
    {
        NSString *ID = transaction.payment.productIdentifier;
        [alreadyPurchasedItems addObject:ID];
    }

}

在应用程序启动但是paymentQueueRestoreCompletedTransactionsFinished方法是从来没有打电话让我可以获得已经购买的物品清单,然后直接通知用户他/她是否已经购买了这个物品。

On application launch but paymentQueueRestoreCompletedTransactionsFinished method is never called so that I can get the list of already purchased items and then directly inform user if he/she purchased this already.

推荐答案

如何设置 [SKPaymentQueue defaultQueue] 的代理?我猜你已经做过smt了:

How do you set the delegate of [SKPaymentQueue defaultQueue]? I guess you already do smt like:

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];

之后 [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; 应该导致以下方法被触发。因此SKPaymentTransactionStateRestored就是你实现它的地方:

After that [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; should result in below method to be fired. So the case SKPaymentTransactionStateRestored is where you implement it:

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

您可以查看本教程,更详细地解释恢复它的最后。
http:// www .raywenderlich.com / 21081 /介绍在应用程序中购买ios-6教程

You may have a look at this tutorial, restoration is explained in more detail towards the very end of it. http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial

这篇关于获取购买的产品列表,inApp购买iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆