0

我正在沙盒模式下测试我的应用内购买,当我尝试购买它时,我不断收到消息“这个应用内购买已经被购买”,其中产品应该是可以无限次购买的消耗品. 我尝试杀死我的应用程序并重新启动它,但它继续给我这个消息。这是 Xcode Objective C 的错误,还是 iOS 的错误?在此先感谢您提供解决此问题的任何答案或指导,我将不胜感激。

更新:SKPayment 代码

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for(SKPaymentTransaction *transaction in transactions){
    switch(transaction.transactionState){
        case SKPaymentTransactionStatePurchasing: NSLog(@"Transaction state -> Purchasing");
            //called when the user is in the process of purchasing, do not add any of your own code here.
            break;
        case SKPaymentTransactionStatePurchased:
            //this is called when the user has successfully purchased the package (Cha-Ching!)
            [self doRemoveAds:validProduct];
            //you can add your code for what you want to happen when the user buys the purchase here, for this tutorial we use removing ads
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
            NSLog(@"Transaction state -> Purchased");
            break;
        case SKPaymentTransactionStateRestored:
            NSLog(@"Transaction state -> Restored");
            [self doRemoveAds:validProduct];

            //add the same code as you did from SKPaymentTransactionStatePurchased here
            break;
        case SKPaymentTransactionStateFailed:
            //called when the transaction does not finish
            if(transaction.error.code == SKErrorPaymentCancelled){
                NSLog(@"Transaction state -> Cancelled");
                //the user cancelled the payment ;
            }
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];

            break;
    }
4

0 回答 0