购买时重复方法
我的控制到达方法:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,我前段时间也经历过类似的行为。我设法通过(本地)跟踪已交付的产品来解决这个问题,并且忽略 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.