嗨我需要在Inapp-Purchase中实现恢复功能,为此创建了一个“恢复”按钮,它是调用方法
-(void)restorePurchasedProductsWithProductId:(NSString*)prodID { _productIdsArray = [[NSMutableArray alloc] init]; productID = [prodID retain]; [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; }
它给了我一个输入苹果id密码的弹出窗口.在这之后没有任何反应.
我读到了它所调用的地方
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
所以我喜欢这样
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { NSLog(@"paymentQueue"); for (SKPaymentTransaction *transaction in transactions) { switch (transaction.transactionState) { case SKPaymentTransactionStatePurchased: [self completeTransaction:transaction]; break; case SKPaymentTransactionStateFailed: [self FailedTransaction:transaction]; break; case SKPaymentTransactionStateRestored: NSLog(@"restored"); [self restoreTransaction:transaction]; break; default: break; } } }
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
也不
-(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
我还包括了所需的协议,
有些正文可以帮助我为什么这些委托方法不会要求恢复过程.
我正在尝试使用测试帐户.
解决方法
您需要确保实现paymentQueueRestoreCompletedTransactionsFinished的类:和paymentQueue:restoreCompletedTransactionsFailedWithError:被注册为您的支付队列的观察者.
如果您已在UIViewController中编写此代码,请尝试在viewDidLoad中添加此代码:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
并在viewDidDisappear中:
[[SKPaymentQueue defaultQueue] removeTransactionObserver:self];