我有一个问题,我有一个应用内购买,我想用我的沙盒测试。 应用内购买的状态为"准备提交"我已按照步骤将pkg文件上传到应用内购买。
沙盒中的事务工作正常,但是当涉及到下载时, - (void)paymentQueue :( SKPaymentQueue *)队列更新下载:(NSArray *)下载 委托函数只被调用一次。它首先进入块#34;否则如果(download.downloadState == SKDownloadStateActive)",并打印"进度... 0 .."
应用内购买是否必须经过审核和批准" Apple下载前会有效吗? 否则可能是什么错误?
感谢。
- (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);
}
}
}
答案 0 :(得分:2)
从updatedTransaction
[self completeTransaction:transaction];
并将其插入
if (download.downloadState == SKDownloadStateFinished) {
// now we're done
[self completeTransaction:download.transaction];
}
这种方式updatedDownloads
将通过下载进度调用。