2

我遇到了一个问题,我有一个应用内购买,我想用我的沙盒进行测试。应用内购买的状态是“准备提交”,我已按照步骤将 pkg 文件上传到应用内购买。

沙箱中的交易工作正常,但在下载时,- (void)paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloads 委托函数只被调用一次。它首先进入块“else if (download.downloadState == SKDownloadStateActive)”,并打印“Progress ... 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);
        }
    }
}
4

1 回答 1

3

updatedTransaction

[self completeTransaction:transaction];

并将其插入

if (download.downloadState == SKDownloadStateFinished) {
        // now we're done
        [self completeTransaction:download.transaction];
}

updatedDownloads下载进度会调用这种方式。

于 2014-05-06T14:53:14.693 回答