gpt4 book ai didi

iOS 应用内恢复购买噩梦

转载 作者:行者123 更新时间:2023-11-28 21:48:54 25 4
gpt4 key购买 nike

我已经阅读了 Internet 上的所有线程等,但当我尝试恢复购买的产品(沙盒环境)时,仍然得到零恢复交易。

我已经通过 iTunes 连接创建了 3 个非续订产品和 2 个沙盒测试器。

我在设置实际购买产品的能力时遇到了零个问题;一切都很好。

我已经创建了一个“恢复购买”按钮,并试图让它发挥作用。我一直在测试以下内容:安装应用程序并进行购买。再次购买,它询问我是否要续订。删除应用程序并退出应用程序商店。重新安装应用程序并按恢复购买...零!!!

这是我正在使用的一些代码:

-(void)viewDidLoad
{
[super viewDidLoad];

//in-app purchase setup
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
}
-(void)viewDidAppear:(BOOL)animated
{
//make request for in-app products
if([SKPaymentQueue canMakePayments])
{
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObjects:@"product1_id",@"product2_id",@"product3_id",nil]];
request.delegate = self;

[request start];
}
else
{
//alert user
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"..." message:@"Please enable In App Purchase in settings" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}

-(IBAction)restoreTransactionsPressed
{
_refreshRequest = [[SKReceiptRefreshRequest alloc] init];
_refreshRequest.delegate = self;
[_refreshRequest start];
}
-(void)requestDidFinish:(SKRequest *)request
{
if([request isKindOfClass:[SKReceiptRefreshRequest class]])
{
NSLog(@"Got a new receipt... %@",request.description);
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
}
-(void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
NSLog(@"%@",error.description);
}

-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
NSLog(@"updatedTransactions");

for(SKPaymentTransaction *transaction in transactions)
{
NSLog(@"updatedTransaction:%@ ... state:%@",transaction.originalTransaction.payment.productIdentifier,transaction.transactionState);

switch(transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
NSLog(@"SKPaymentTransactionStatePurchased");
//unlock feature code
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;

case SKPaymentTransactionStateFailed:
NSLog(@"SKPaymentTransactionStateFailed");
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;

case SKPaymentTransactionStateRestored:
NSLog(@"SKPaymentTransactionStateRestored");
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;

default:
break;
}
}
}

-(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
NSLog(@"paymentQueueRestoreCompletedTransactionsFinished");

NSLog(@"received restored transactions: %i", (int)queue.transactions.count);

for(SKPaymentTransaction *transaction in queue.transactions)
{
NSLog(@"transaction:%@",transaction);
}
}
-(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
{
NSLog(@"restoreCompletedTransactionsFailedWithError %@",error);
}

为什么我总是得到零恢复交易?

似乎“restoreCompletedTransactions”并没有依次调用 - paymentQueue:updatedTransactions: 如果有帮助的话。

我不确定 SKReceiptRefreshRequest 是否必要,但我已经尝试过在恢复之前刷新收据和在恢复之前不刷新收据。

请不要发布主题链接。我已经调查了几天了!有人声称 Apple 的 Sandbox 过去有问题……这可能是原因吗? tyvm 高级;感谢所有帮助!

最佳答案

根据 Apple's documentation ,您无法恢复非续订订阅。另外,请阅读 here以获得更详细的解释。

关于iOS 应用内恢复购买噩梦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29064408/

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