Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Downloading iAP Hosted Content gets stucks on SKDownloadStateWaiting for some users

Pretty much what the title says. The code works fine for all my development devices in the sandbox environment and for a majority of my users. However, there are some users reporting that the download process doesn't move beyond the waiting state (SKDownloadStateWaiting), even when left through the night. Some do manage to get the download started after a few tries (closing the app completely and going through restore purchases feature), so it does look to be completely random.

Here is the code I'm using to manage downloading:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloads
{
    SKDownload *download = [downloads objectAtIndex:0];
    SKPaymentTransaction *transaction = download.transaction;

    // Keep track of download status
    switch (download.downloadState) {
        case SKDownloadStateActive:
            // Present time remaining and percentage
            break;

        case SKDownloadStateWaiting:
            // Present "Waiting..." label
            break;

        case SKDownloadStateFinished:
            [self purchaseNonconsumableAtURL:download.contentURL forProductIdentifier:productIdentifier];
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
            break;

        case SKDownloadStateFailed:
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
            break;

        case SKDownloadStateCancelled:
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
            break;

        default:
            break;
    }
}

Any help would be much appreciated.

like image 573
Gasper Avatar asked Jan 18 '26 00:01

Gasper


1 Answers

You can try to start a download that's in SKDownloadStateWaiting by calling

[[SKPaymentQueue defaultQueue] startDownloads:[NSArray arrayWithObject:download]];

My application would always get downloads that were in a permanent "waiting" state when it attempted to resume earlier transactions. I edited the paymentQueue updatedDownloads function so that whenever it's called with a download that's in a waiting state, it will pass that download to startDownloads, and this seemed to fix the issue.

like image 125
Kaj_Sotala Avatar answered Jan 19 '26 16:01

Kaj_Sotala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!