1
我有一個問題,我有一個應用程序內購買,我想用我的沙箱測試。 應用內購買的狀態爲「準備提交」,我已按照步驟將pkg文件上傳至應用內購買。應用內購買下載永遠不會被下載
在沙盤交易工作正常,但是當涉及到下載的 - (空)paymentQueue:(SKPaymentQueue *)隊列updatedDownloads:(NSArray的*)下載 委託函數被調用一次。並且它首先進入塊「else if(download.downloadState == SKDownloadStateActive)」,並打印「Progress ... 0 ..」
應用內購買是否必須由「審覈和批准」下載之前蘋果會工作嗎? 否則可能是什麼錯誤?
謝謝。
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction * transaction in transactions) {
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
if (transaction.downloads) {
[[SKPaymentQueue defaultQueue] startDownloads:transaction.downloads];
}
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
if (transaction.downloads) {
[[SKPaymentQueue defaultQueue] startDownloads:transaction.downloads];
}
[self restoreTransaction:transaction];
default:
break;
}
};
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloads;
{
for (SKDownload *download in downloads) {
if (download.downloadState == SKDownloadStateFinished) {
[self processDownload:download]; // not written yet
// now we're done
[queue finishTransaction:download.transaction];
} else if (download.downloadState == SKDownloadStateActive) {
NSString *productID = download.contentIdentifier; // in app purchase identifier
NSTimeInterval remaining = download.timeRemaining; // secs
float progress = download.progress; // 0.0 -> 1.0
NSLog(@"Downloading %@", productID);
NSLog(@"progress... %f time remaining %f", progress, remaining);
// NOT SHOWN: use the productID to notify your model of download progress...
} else { // waiting, paused, failed, cancelled
NSLog(@"Warn: not handled: %d", download.downloadState);
}
}
}
用於測試的應用內購買無需Apple批准。我正在經歷同樣的事情。你有沒有發現問題是什麼? – aobs
我發現了paymentQueue:updatedDownloads在我的程序中只被調用一次的原因。在函數completeTransaction中,在我運行[[SKPaymentQueue defaultQueue] startDownloads:transaction.downloads]後調用[[SKPaymentQueue defaultQueue] finishTransaction:transaction]。如果沒有transaction.downloads,只應該調用'finishTransaction'。 – aobs