2014-05-22 94 views
0

我用下面的代碼開始恢復應用程序內購買:恢復沒有完成

[[SKPaymentQueue defaultQueue] addTransactionObserver:self]; 
SKReceiptRefreshRequest * request = [[SKReceiptRefreshRequest alloc] init]; 
request.delegate = self; 
[request start]; 
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; 

應用程序商店的程序啓動,並從SKTransactionObserver這種方法被稱爲:

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue 

但這種方法從來沒有所謂的完成交易:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions 

有什麼問題,我該怎麼溶膠是嗎?

回答

1

我發現了這個問題。 將xCode從5.1更新到5.1.1是原因。蘋果將​​在應用購買方式上進行一些改變。它迫使開發人員在最新版本的xCode中進行這些更改。

順便說一下我修改我的方法是這樣的:

恢復請求:

NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL]; 
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL]; 
if (!receipt) { 
    SKReceiptRefreshRequest * request = [[SKReceiptRefreshRequest alloc] init]; 
    request.delegate = self; 
    [request start]; 
} 
[self registerAsPurchaseObserver]; 
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; 

和響應去:

-(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error 
{ 
    [Delegate transactionDidFail]; 
} 

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue 
{ 
    NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL]; 
    NSData *receipt = [NSData dataWithContentsOfURL:receiptURL]; 
    if (receipt) { 
     [Delegate transactionDidRestorePurchaseSuccessfullyWithReciept:receipt]; 
    } 
    else{ 
     [Delegate transactionDidFail]; 
    } 
}