Background Assets

RSS for tag

Schedule background downloads of large assets during app installation, when the app updates, and periodically while the app remains on-device.

Posts under Background Assets tag

92 Posts

Post

Replies

Boosts

Views

Activity

Background Assets: Questions about network status
Background asstes are triggered before the APP is launched. At this time, if the current device is not connected to the WIFI network, it will directly consume the operator's network traffic. Is there any way to limit this in order to avoid disputes over fees arising from the consumption of users' non-wifi traffic without their knowledge? For example, after extension is triggered, determine the network status when scheduling downloads?
0
0
790
Jul ’23
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?
1
0
897
Jul ’23
Background Assets Failed to move manifestURL to APP group
After receiving manifestURL in extension, I try to move it to the shared directory of APP group, as follows: NSURL *url = [NSFileManager.defaultManager containerURLForSecurityApplicationGroupIdentifier:self.appGroupIdentifier]; NSURL *storageURL = [url URLByAppendingPathComponent:@"YYBAResCache" isDirectory:YES]; BOOL isDirectory; BOOL isExists = [NSFileManager.defaultManager fileExistsAtPath:storageURL.path isDirectory:&isDirectory]; NSError *error = nil; if (!isExists || !isDirectory) { [NSFileManager.defaultManager createDirectoryAtURL:storageURL withIntermediateDirectories:YES attributes:@{NSFilePosixPermissions: [NSNumber numberWithShort:0777]} error:&error]; } if (error){ NSLog(@"Failed to create session storage directory:%@",error); } NSURL *localManifestURL = [sessionStorageURL URLByAppendingPathComponent:@"manifest.json"]; Next, move the file: NSError *error; [NSFileManager.defaultManager moveItemAtURL:manifestURL toURL:localManifestURL error:&error]; if (error) { NSLog(@"BackgroundAssetsTest extension saveMainifest:%@ to %@ error:%@",manifestURL,YYBASharedSettings.localManifestURL,error); } But I still received an error: BackgroundAssetsTest extension saveMainifest:file:///var/tmp/com.apple.backgroundassets.downloadstaging/com.devinprogress2021/2cf0ae65-3058-4522-80d5-f4d76747ad15.json to file:///private/var/mobile/Containers/Shared/AppGroup/F466C6BA-35D7-4115-8D8E-E1726E3D3696/YYBAResCache/manifest.json error:Error Domain=NSCocoaErrorDomain Code=513 "“2cf0ae65-3058-4522-80d5-f4d76747ad15.json” couldn’t be moved because you don’t have permission to access “YYBAResCache”." UserInfo={NSSourceFilePathErrorKey=/var/tmp/com.apple.backgroundassets.downloadstaging/com.yy.yymobile.devinprogress2021/2cf0ae65-3058-4522-80d5-f4d76747ad15.json, NSUserStringVariant=( Move ), NSDestinationFilePath=/private/var/mobile/Containers/Shared/AppGroup/F466C6BA-35D7-4115-8D8E-E1726E3D3696/YYBAResCache/manifest.json, NSFilePath=/var/tmp/com.apple.backgroundassets.downloadstaging/com.devinprogress2021/2cf0ae65-3058-4522-80d5-f4d76747ad15.json, NSUnderlyingError=0x14520d2d0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} why?
1
0
979
Jul ’23
Background Assets: Max Parallel downloads and Max Parallel Schedules allowed
In our app, We have to download 5000 assets in the Install/Periodic event. Obviously, we can't download them all in parallel. If we return all 5000 entries in the extension downloads function, will the system take care of queueing and downloading some 20 assets parallelly and take care of downloading all of 5000 assets? Or Should we return only 20 urls and after if got finished, from the finished call back we can repeatedly schedule the next 20 every time and can download all of 5000 assets? If we can't reduce the number of assets(like in our case 5000 entries), What is the recommended way of downloading it?
0
0
688
Jul ’23
Background Assets: BAURLDownload is finish, but the file cannot be read, the file does not exist
My Background Assets extension arranges to download image resources, as follows: NSURL *assetURL = [NSURL URLWithString:@"https://***.png”]; NSUInteger assetSize = 6849; switch (contentRequest) { case BAContentRequestInstall: case BAContentRequestUpdate: { BAURLDownload *essentialDownload = [[BAURLDownload alloc] initWithIdentifier:@"YYBADAsset" request:[NSURLRequest requestWithURL:assetURL] essential:true fileSize:assetSize applicationGroupIdentifier:appGroupIdentifier priority:BADownloaderPriorityDefault]; [downloadsToSchedule addObject:essentialDownload]; break; } } At the same time, the finishedWithFileURL method is implemented as follows: - (void)backgroundDownload:(BADownload *)download finishedWithFileURL:(NSURL *)fileURL { NSLog(@"BackgroundAssetsTest extension finishedWithFileURL:%@ forDownlad:%@",fileURL,download.identifier); NSLog(@"BackgroundAssetsTest extension finishedWithManifestURLExist:%@",@([[NSFileManager defaultManager] fileExistsAtPath:fileURL.absoluteString])); } And then use tools to trigger events, xcrun backgroundassets-debug --app-bundle-id com.luph.mytest --device-id 00008020-000A04xxF0002E --simulate --app-install The following log is observed through the console: BackgroundAssetsTest extension finishedWithFileURL:file:///private/var/mobile/Containers/Shared/AppGroup/1D051E06-E597-4670-969A-38ECA52C4F7A/Library/C aches/com.apple.BackgroundAssets/BAFile-5152AFB2.tmp forDownlad:YYBADAsset BackgroundAssetsTest extension finishedWithManifestURLExist:0 What's the problem? Did I set the size of BAURLDownload to be different from the actual download size? Or the wrong way to determine the existence of the file?
1
0
926
Jul ’23
Not able to download the file using Background Assets for TestFlight build
Hi, I used Background assets to download files during install/update events. The debug build works fine when I trigger the install event through terminal. The same code base (with different bundle ID ) is used in Test Flight build. But the file is not downloaded when I install the TestFlight build. I'm getting following error in Console while installing the TestFlight build. sometimes, i'm getting Failed to notify extension about finished download: BAURLDownload (0x61a80ab98): guard let url = URL(string:"https://devstreaming-cdn.apple.com/videos/wwdc/2021/10220/6/3866585A-3920-44B4-AB3F-03A446FCDE3A/downloads/wwdc2021-10220_hd.mp4") else{ return Set() } switch (request) { case .install, .update: let essentialDownload = BAURLDownload( identifier: "avtar345", request: URLRequest(url: url), essential: true, fileSize: 155384552, applicationGroupIdentifier: appGroupIdentifier, priority: .default) downloadsToSchedule.insert(essentialDownload) break; case .periodic: break; }
1
0
755
Jul ’23
Failed to notify extension about finished download: BAURLDownload
Hi team, I tried to download an image using the background assets . In development it downloads the image when I trigger the xcrun backgroundassets-debug command with instal event. But the image is not downloading for Test flight build. In console I observed the following errors while installing the app, Why am I getting this error while installing the app and how to resolve this?
0
0
703
Jul ’23
The requested URL is not permitted to be downloaded until the application is launched error in background assets
Hi , i tried to download image using background assets framework. I tried to use install and update events to test the extension. But the extension always delegate to backgroundDownload(_ :failedWithError :) function with following error 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.} I used the following url to download the image https://w0.peakpx.com/wallpaper/934/165/HD-wallpaper-avatar-aang-aang-airbender-aire-appa-avatar-legend-leyenda.jpg Why am i getting this error and how to resolve this?
3
0
1.2k
Jun ’23
Get an error when use backgroundassets-debug command
I download the demo provided by WWDC 2023 Session 10108 "What’s new in Background Assets", and I configure all targets to my developer team for signing so I can run the application on my device. But I get an error when I use backgroundassets-debug command: xcrun backgroundassets-debug --simulate --app-periodic-check --device-id 00008030-001631C036208XXX --app-bundle-id com.example.apple-samplecode.WWDC-Sessions8QQGK9DXXX Error Log: backgroundassets.user Unable to use persistent identifier to update application info. Falling back to bundle identifier lookup. (bundle identifier: com.example.apple-samplecode.WWDC-Sessions8QQGK9DJB9) ...... backgroundassets.user Failed to get extension process: Error Domain=com.apple.extensionKit.errorDomain Code=4 "Failed to aquire assertion for pid: 3091" UserInfo={NSLocalizedDescription=Failed to aquire assertion for pid: 3091} ...... backgroundassets.user Failed to get extension process: Error Domain=com.apple.extensionKit.errorDomain Code=4 "Failed to aquire assertion for pid: 3092" UserInfo={NSLocalizedDescription=Failed to aquire assertion for pid: 3092} backgroundassets.user -[BAAgentCore downloadQueue:manifest:finishedWithFileURL:]_block_invoke, Failed to access extension for com.example.apple-samplecode.WWDC-Sessions8QQGK9DXXX. backgroundassets.user Removing manifest download as extension did not handle manifest. BAManifestDownload (0x75cd44aa0): [ID:com.example.apple-samplecode.WWDC-Sessions8QQGK9DXXX.Manifest-3BE0D398-734D-4E12-90DD-EE943D6DCXXX, AppID:com.example.apple-samplecode.WWDC-Sessions8QQGK9DXXX, Necessity:Essential] Any help will be gratefully appreciated
2
1
1k
Jun ’23
Bakground Assets error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.backgroundassets.user"
Message failed: -[BAAgentClientProxy currentDownloadsWithCompletion:]_block_invoke error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.backgroundassets.user" UserInfo={NSDebugDescription=connection to service named com.apple.backgroundassets.user} The above error occurs when debugging Background Assets on iPhone。
1
0
1.1k
Jun ’23
Background Assets: Questions about network status
Background asstes are triggered before the APP is launched. At this time, if the current device is not connected to the WIFI network, it will directly consume the operator's network traffic. Is there any way to limit this in order to avoid disputes over fees arising from the consumption of users' non-wifi traffic without their knowledge? For example, after extension is triggered, determine the network status when scheduling downloads?
Replies
0
Boosts
0
Views
790
Activity
Jul ’23
Background Assets: Not able to get access to withExclusiveControl
Sometimes not able to get access to withExclusiveControl I am not able to repro this, but once it can't get access, then killing the app also does not release the lock. I have to restart the device to get the control. Can we please fix this issue?
Replies
2
Boosts
0
Views
859
Activity
Jul ’23
Background Assets: Whether the size of BAEssentiaMaxInstallSize is included in BAMaxInstallSize?
The BAEssentiaMaxInstallSize key in the plist file indicates the installed maximum size of the necessary resources. Is this size the uncompression size, and is this size included in the size of the BAMaxInstallSize key? Is BAEssentialDownloadAllowance included in BADownloadAllowance?
Replies
2
Boosts
0
Views
942
Activity
Jul ’23
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
1
Boosts
0
Views
897
Activity
Jul ’23
Background Assets Failed to move manifestURL to APP group
After receiving manifestURL in extension, I try to move it to the shared directory of APP group, as follows: NSURL *url = [NSFileManager.defaultManager containerURLForSecurityApplicationGroupIdentifier:self.appGroupIdentifier]; NSURL *storageURL = [url URLByAppendingPathComponent:@"YYBAResCache" isDirectory:YES]; BOOL isDirectory; BOOL isExists = [NSFileManager.defaultManager fileExistsAtPath:storageURL.path isDirectory:&isDirectory]; NSError *error = nil; if (!isExists || !isDirectory) { [NSFileManager.defaultManager createDirectoryAtURL:storageURL withIntermediateDirectories:YES attributes:@{NSFilePosixPermissions: [NSNumber numberWithShort:0777]} error:&error]; } if (error){ NSLog(@"Failed to create session storage directory:%@",error); } NSURL *localManifestURL = [sessionStorageURL URLByAppendingPathComponent:@"manifest.json"]; Next, move the file: NSError *error; [NSFileManager.defaultManager moveItemAtURL:manifestURL toURL:localManifestURL error:&error]; if (error) { NSLog(@"BackgroundAssetsTest extension saveMainifest:%@ to %@ error:%@",manifestURL,YYBASharedSettings.localManifestURL,error); } But I still received an error: BackgroundAssetsTest extension saveMainifest:file:///var/tmp/com.apple.backgroundassets.downloadstaging/com.devinprogress2021/2cf0ae65-3058-4522-80d5-f4d76747ad15.json to file:///private/var/mobile/Containers/Shared/AppGroup/F466C6BA-35D7-4115-8D8E-E1726E3D3696/YYBAResCache/manifest.json error:Error Domain=NSCocoaErrorDomain Code=513 "“2cf0ae65-3058-4522-80d5-f4d76747ad15.json” couldn’t be moved because you don’t have permission to access “YYBAResCache”." UserInfo={NSSourceFilePathErrorKey=/var/tmp/com.apple.backgroundassets.downloadstaging/com.yy.yymobile.devinprogress2021/2cf0ae65-3058-4522-80d5-f4d76747ad15.json, NSUserStringVariant=( Move ), NSDestinationFilePath=/private/var/mobile/Containers/Shared/AppGroup/F466C6BA-35D7-4115-8D8E-E1726E3D3696/YYBAResCache/manifest.json, NSFilePath=/var/tmp/com.apple.backgroundassets.downloadstaging/com.devinprogress2021/2cf0ae65-3058-4522-80d5-f4d76747ad15.json, NSUnderlyingError=0x14520d2d0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} why?
Replies
1
Boosts
0
Views
979
Activity
Jul ’23
Background Assets: Max Parallel downloads and Max Parallel Schedules allowed
In our app, We have to download 5000 assets in the Install/Periodic event. Obviously, we can't download them all in parallel. If we return all 5000 entries in the extension downloads function, will the system take care of queueing and downloading some 20 assets parallelly and take care of downloading all of 5000 assets? Or Should we return only 20 urls and after if got finished, from the finished call back we can repeatedly schedule the next 20 every time and can download all of 5000 assets? If we can't reduce the number of assets(like in our case 5000 entries), What is the recommended way of downloading it?
Replies
0
Boosts
0
Views
688
Activity
Jul ’23
Background Assets: BAURLDownload is finish, but the file cannot be read, the file does not exist
My Background Assets extension arranges to download image resources, as follows: NSURL *assetURL = [NSURL URLWithString:@"https://***.png”]; NSUInteger assetSize = 6849; switch (contentRequest) { case BAContentRequestInstall: case BAContentRequestUpdate: { BAURLDownload *essentialDownload = [[BAURLDownload alloc] initWithIdentifier:@"YYBADAsset" request:[NSURLRequest requestWithURL:assetURL] essential:true fileSize:assetSize applicationGroupIdentifier:appGroupIdentifier priority:BADownloaderPriorityDefault]; [downloadsToSchedule addObject:essentialDownload]; break; } } At the same time, the finishedWithFileURL method is implemented as follows: - (void)backgroundDownload:(BADownload *)download finishedWithFileURL:(NSURL *)fileURL { NSLog(@"BackgroundAssetsTest extension finishedWithFileURL:%@ forDownlad:%@",fileURL,download.identifier); NSLog(@"BackgroundAssetsTest extension finishedWithManifestURLExist:%@",@([[NSFileManager defaultManager] fileExistsAtPath:fileURL.absoluteString])); } And then use tools to trigger events, xcrun backgroundassets-debug --app-bundle-id com.luph.mytest --device-id 00008020-000A04xxF0002E --simulate --app-install The following log is observed through the console: BackgroundAssetsTest extension finishedWithFileURL:file:///private/var/mobile/Containers/Shared/AppGroup/1D051E06-E597-4670-969A-38ECA52C4F7A/Library/C aches/com.apple.BackgroundAssets/BAFile-5152AFB2.tmp forDownlad:YYBADAsset BackgroundAssetsTest extension finishedWithManifestURLExist:0 What's the problem? Did I set the size of BAURLDownload to be different from the actual download size? Or the wrong way to determine the existence of the file?
Replies
1
Boosts
0
Views
926
Activity
Jul ’23
Not able to download the file using Background Assets for TestFlight build
Hi, I used Background assets to download files during install/update events. The debug build works fine when I trigger the install event through terminal. The same code base (with different bundle ID ) is used in Test Flight build. But the file is not downloaded when I install the TestFlight build. I'm getting following error in Console while installing the TestFlight build. sometimes, i'm getting Failed to notify extension about finished download: BAURLDownload (0x61a80ab98): guard let url = URL(string:"https://devstreaming-cdn.apple.com/videos/wwdc/2021/10220/6/3866585A-3920-44B4-AB3F-03A446FCDE3A/downloads/wwdc2021-10220_hd.mp4") else{ return Set() } switch (request) { case .install, .update: let essentialDownload = BAURLDownload( identifier: "avtar345", request: URLRequest(url: url), essential: true, fileSize: 155384552, applicationGroupIdentifier: appGroupIdentifier, priority: .default) downloadsToSchedule.insert(essentialDownload) break; case .periodic: break; }
Replies
1
Boosts
0
Views
755
Activity
Jul ’23
Failed to notify extension about finished download: BAURLDownload
Hi team, I tried to download an image using the background assets . In development it downloads the image when I trigger the xcrun backgroundassets-debug command with instal event. But the image is not downloading for Test flight build. In console I observed the following errors while installing the app, Why am I getting this error while installing the app and how to resolve this?
Replies
0
Boosts
0
Views
703
Activity
Jul ’23
The requested URL is not permitted to be downloaded until the application is launched error in background assets
Hi , i tried to download image using background assets framework. I tried to use install and update events to test the extension. But the extension always delegate to backgroundDownload(_ :failedWithError :) function with following error 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.} I used the following url to download the image https://w0.peakpx.com/wallpaper/934/165/HD-wallpaper-avatar-aang-aang-airbender-aire-appa-avatar-legend-leyenda.jpg Why am i getting this error and how to resolve this?
Replies
3
Boosts
0
Views
1.2k
Activity
Jun ’23
Get an error when use backgroundassets-debug command
I download the demo provided by WWDC 2023 Session 10108 "What’s new in Background Assets", and I configure all targets to my developer team for signing so I can run the application on my device. But I get an error when I use backgroundassets-debug command: xcrun backgroundassets-debug --simulate --app-periodic-check --device-id 00008030-001631C036208XXX --app-bundle-id com.example.apple-samplecode.WWDC-Sessions8QQGK9DXXX Error Log: backgroundassets.user Unable to use persistent identifier to update application info. Falling back to bundle identifier lookup. (bundle identifier: com.example.apple-samplecode.WWDC-Sessions8QQGK9DJB9) ...... backgroundassets.user Failed to get extension process: Error Domain=com.apple.extensionKit.errorDomain Code=4 "Failed to aquire assertion for pid: 3091" UserInfo={NSLocalizedDescription=Failed to aquire assertion for pid: 3091} ...... backgroundassets.user Failed to get extension process: Error Domain=com.apple.extensionKit.errorDomain Code=4 "Failed to aquire assertion for pid: 3092" UserInfo={NSLocalizedDescription=Failed to aquire assertion for pid: 3092} backgroundassets.user -[BAAgentCore downloadQueue:manifest:finishedWithFileURL:]_block_invoke, Failed to access extension for com.example.apple-samplecode.WWDC-Sessions8QQGK9DXXX. backgroundassets.user Removing manifest download as extension did not handle manifest. BAManifestDownload (0x75cd44aa0): [ID:com.example.apple-samplecode.WWDC-Sessions8QQGK9DXXX.Manifest-3BE0D398-734D-4E12-90DD-EE943D6DCXXX, AppID:com.example.apple-samplecode.WWDC-Sessions8QQGK9DXXX, Necessity:Essential] Any help will be gratefully appreciated
Replies
2
Boosts
1
Views
1k
Activity
Jun ’23
Bakground Assets error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.backgroundassets.user"
Message failed: -[BAAgentClientProxy currentDownloadsWithCompletion:]_block_invoke error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.backgroundassets.user" UserInfo={NSDebugDescription=connection to service named com.apple.backgroundassets.user} The above error occurs when debugging Background Assets on iPhone。
Replies
1
Boosts
0
Views
1.1k
Activity
Jun ’23