购买时重复方法

发布于 2024-12-08 02:27:09 字数 1109 浏览 0 评论 0原文

我的控制到达方法:

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 类中的交易方法的东西?

My control reaches to method:

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;
    }
}

}
after notification method in

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);
 }

how could i stop this ? any bunch line of code or something else that could stop going at transaction method in IAPHelper.m class after purchasing second product?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乜一 2024-12-15 02:27:09

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

Yes, i experienced similar behaviour some time ago. I managed to work around it by keeping track (locally) of already delivered products and i ignore the subsequent callbacks from StoreKit for the delivered products.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文