java苹果支付二次验证_iOS In App Purchases:只有一笔付款添加到SKPaymentQueue,但SKPaymentTransactionObserver方法被多次调用...

您可能获得多个回调的原因是您无意中注册了多个观察者 . 如果要实例化在付款队列中注册为观察者的视图控制器,则需要确保在事务完成时将其删除 .

处理此类情况的更好方法可能是让单个观察者将通知发送回您的控制器 .

@implementation MyViewController : SomeParentController

- (void)startPayment:(SKPayment *)payment {

SKPaymentQueue *queue = [SKPaymentQueue defaultQueue];

/* Unless MyViewController is a singleton this line of code will add a new observer

* to the default queue. The observer is retained and every time a transaction is added

* to the queue the callback code will be executed on all registered observers.

*/

[queue addTransactionObserver:self];

[SKPaymentQueue addPayment:payment];

}

- (void)paymentQueue:(SKPaymentQueue *)queue

updatedTransactions:(NSArray *)transactions {

// Your transaction processing code here

}

@end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值