我被Apple拒绝了,并说:
...此外,我们发现您的应用提供应用内购买 可以恢复,它不包括所需的“恢复” 功能允许用户恢复以前购买的应用程序内 购买,如恢复交易部分所述 应用程序内购买编程指南:
“...如果您的应用程序支持必须的产品类型 restorable,你必须包含一个允许用户恢复的界面 这些购买。此界面允许用户添加产品 其他设备,或者,如果原始设备被擦除,恢复 原始设备上的交易。“
要恢复以前购买的应用程序内购买产品,它将是 适合提供“恢复”按钮并启动恢复 用户点击“恢复”按钮时进行处理。
有关恢复事务和验证存储的详细信息 收据,请参阅应用程序内购买编程指南。 ...
我找到了这个page,我按照示例代码,但是在我调用
之后- (void) checkPurchasedItems{
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
另一位代表没有被解雇!
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
它只会弹出一个警报视图,让你输入你的Apple ID ......什么都没发生?
我设定了一个断点,但它不会像示例所说的那样停止。
关于我的代码有什么问题的任何想法?
答案 0 :(得分:18)
除了添加restoreCompletedTransactions
之外,您还需要处理iap实际还原到用户的方式以及如何向用户提供内容。
基本上,您需要回想一下您在最初购买时为用户提供商品的方式。
对于示例,这就是我在其中一个应用中恢复产品的方式。
- (void)restoreTransaction:(SKPaymentTransaction *)transaction
{
isRestoring = YES;
[self recordTransaction: transaction];
/* This is where I provide the content to the user: */
[self provideContent: transaction.originalTransaction.payment.productIdentifier];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
- (void)completeTransaction:(SKPaymentTransaction *)transaction
{
[self recordTransaction: transaction];
[self provideContent: transaction.payment.productIdentifier];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
if (transaction.error.code == SKErrorPaymentCancelled) {
/// user has cancelled
[[NSNotificationCenter defaultCenter] postNotificationName:@"hideRestoring" object:nil];
}
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
default:
break;
}
}
}
- (void)provideContent:(NSString *)productIdentifier
{
int index;
NSMutableDictionary * purchased = [NSMutableDictionary dictionaryWithContentsOfFile:EXTRAS_PATH];
NSArray * availableProducts = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:SCANNER_IN_APP_PURCHASES]];
if ( isRestoring )
{
for ( index = 0; index < [availableProducts count]; index++ )
{
//NSLog(@"productIdentifier: %@",productIdentifier);
//NSLog(@"Product: %@",[availableProducts objectAtIndex:index]);
if ( [productIdentifier isEqualToString:[[availableProducts objectAtIndex:index] objectForKey:@"BundleID"]] )
{
[purchased setObject:[availableProducts objectAtIndex:index] forKey:productIdentifier];
[purchased writeToFile:EXTRAS_PATH atomically:YES];
[_purchasedProducts addObject:productIdentifier];
}
}
}
else
{
index = [[[NSUserDefaults standardUserDefaults] objectForKey:@"kTempProductPurchasingIndex"] intValue];
if ( [productIdentifier isEqualToString:[[availableProducts objectAtIndex:index] objectForKey:@"BundleID"]] )
{
[purchased setObject:[availableProducts objectAtIndex:index] forKey:productIdentifier];
[purchased writeToFile:EXTRAS_PATH atomically:YES];
[_purchasedProducts addObject:productIdentifier];
}
}
[[NSNotificationCenter defaultCenter] postNotificationName:kProductPurchasedNotification object:productIdentifier];
}
答案 1 :(得分:10)
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
添加上一行。您的paymentQueueRestoreCompletedTransactionsFinished
函数应该被调用。