Background Assets:Failed to schedule download

I wrote the following code to schedule the download in extension:

AURLDownload *essentialDownload = [[BAURLDownload alloc] initWithIdentifier:url
                                                                                 request:[NSURLRequest requestWithURL:assetURL]
                                                                               essential:true
                                                                                fileSize:assetSize
                                                              applicationGroupIdentifier:YYBASharedSettings.appGroupIdentifier
                                                                                priority:BADownloaderPriorityDefault];
            NSLog(@"BackgroundAssetsTest extension Schedule essentialDownload url:%@",url);

and the delegate callback is implemented as follows:

- (void)backgroundDownload:(BADownload *)download failedWithError:(NSError *)error
{
    NSLog(@"BackgroundAssetsTest extension failedWithError: %@",error);
}

The console outputs the following error:

BackgroundAssetsTest extension failedWithError: Error Domain=BAErrorDomain Code=202 "The requested URL is not permitted to be downloaded until the application is launched." UserInfo={NSLocalizedFailureReason=The requested URL is not permitted to be downloaded until the application is launched.}

What's the problem? Scheduled downloads can only be triggered by launching the APP?

Replies

Any URLs you'd like to download from, must have their hostname specified in the BADownloadDomainAllowList or else Background Assets will not permit downloading those files until the app has been initially launched by the user.

https://developer.apple.com/documentation/bundleresources/information_property_list/bainitialdownloadrestrictions/badownloaddomainallowlist