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