购买时重复方法

时间:2011-10-05 10:54:01

标签: iphone ios in-app-purchase

我的控制达到方法:

IAPHelper.m
  - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
    switch (transaction.transactionState)
    {
        case SKPaymentTransactionStatePurchased:
            [self completeTransaction:transaction];
            break;
        case SKPaymentTransactionStateFailed:
            [self failedTransaction:transaction];
            break;
        case SKPaymentTransactionStateRestored:
            [self restoreTransaction:transaction];
        default:
            break;
    }
}

}

中的通知方法之后
viewcontroller.m
- (void)productPurchased:(NSNotification *)notification {
NSLog(@"product purchased notification");
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[MBProgressHUD hideHUDForView:self.navigationController.view animated:YES];    

NSString *productIdentifier = (NSString *) notification.object;
NSLog(@"Purchased: %@", productIdentifier);
 }

我怎么能阻止这个?在购买第二个产品后,IAPHelper.m类中的任何代码或其他可能会停止在IAPHelper.m类中进行交易的方法?

1 个答案:

答案 0 :(得分:0)

是的,我前段时间经历过类似的行为。我设法通过跟踪(本地)已经交付的产品来解决它,我忽略了StoreKit对交付产品的后续回调。