gpt4 book ai didi

ios - 付款队列 :(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions is not called while restoreCompletedTransactions

转载 作者:可可西里 更新时间:2023-11-01 03:28:10 55 4
gpt4 key购买 nike

您好,我需要在 Inapp-Purchase 中实现恢复功能,为此制作了一个调用方法的“恢复”按钮

-(void)restorePurchasedProductsWithProductId:(NSString*)prodID
{
_productIdsArray = [[NSMutableArray alloc] init];
productID = [prodID retain];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}

它给了我一个弹出窗口,让我输入 apple 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;

}
}
}

但问题是上面的方法既没有调用this

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue

也不是

-(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error

我还包含了所需的协议(protocol),

有人能帮我解释为什么这些委托(delegate)方法不调用恢复过程吗?我正在尝试使用测试帐户。

最佳答案

您需要确保实现 paymentQueueRestoreCompletedTransactionsFinished:paymentQueue: restoreCompletedTransactionsFailedWithError: 的类已注册为您的支付队列的观察者。

如果您在 UIViewController 中编写了这段代码,请尝试将其添加到您的 viewDidLoad 中:

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];

viewDidDisappear 中:

[[SKPaymentQueue defaultQueue] removeTransactionObserver:self];

关于ios - 付款队列 :(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions is not called while restoreCompletedTransactions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11483526/

55 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com