Type Library Revision Release 2024.3703 Keywords on-demand resources, onDemandResources Platforms tvOS, iOS See also Apple TV and tvOS (guide)
The onDemandResources plugin provides an interface for Apple's on-demand resources, applicable to tvOS.
Usage of
Essentially,
You should not assign unique tags to both a folder and a nested folder within it. For example, if you assign a tag to assets/images
, you should not assign a separate tag to assets/images/level1
because, inherently, the level1
resources are already included as part of the broader tag.
If the operating system requires storage space, it may automatically cycle through tags and evict downloaded content. By default, resources which have not been used recently will be prioritized for eviction, although you can manage eviction behavior with onDemandResources.setPreservationPriority().
To use this plugin, add an entry into the plugins
table of build.settings
. When added, the build server will integrate the plugin during the build phase.
settings = { plugins = { ["plugin.onDemandResources"] = { publisherId = "com.coronalabs" }, }, }
To configure onDemandResources
table within the tvos
and/or ios
table of build.settings
. This table should consist of a series of entries (tables) which define the packages for tag
key (string) and a required resource
key (string) which can reference either a specific file or a folder containing multiple resources.
In addition, you can include an optional type
key equal to either of these values:
"install"
— These resources will be downloaded immediately when the app is downloaded from the App Store. This is useful for resources which may be required immediately when the app is first launched. In contrast to assets which are simply "install"
may still be evicted from local storage at some point.
"prefetch"
— These resources will begin to download in the background immediately after the app is downloaded from the App Store.
settings = { tvos = { onDemandResources = { { tag="introMusic", resource="intro.mp4", type="prefetch" }, { tag="imgTutorial", resource="img/tutorial", type="install" }, { tag="imgL1", resource="img/level1" }, }, }, iphone = { onDemandResources = { { tag="introMusic", resource="intro.mp4", type="prefetch" }, { tag="imgTutorial", resource="img/tutorial", type="install" }, { tag="imgL1", resource="img/level1" }, }, }, }