In our previous post, we saw about the technologies by Google to manage the storage problem faced in the mobile. They have developed Progressive Web Apps and Android instant apps to save a lot of internal storage. On Demand Resources is a technology developed by iOS to manage the app efficiently. In this post, we are going to see the On Demand Resources in detail.
On demand resources was introduced in iOS 9 for efficiently managing the size of an app. The main purpose of this feature is to reduce the initial app download size so that developers can separate resources from their main application bundle so that resources are hosted in Apple app store and can be downloaded when needed. Resources can be images, sounds, data, scripts but no executable content.
Eg: In a game, level 1 and level 2 might be sufficient for the developer to run the app. And once level 1 is finished, he might request for level 3 and it will be downloaded in the background. And also developer can delete the resources and free up the spaces that are not needed like if a user reaches level 10, then he might free up the spaces for resources used by the previous levels of the game.
This feature also supports tvOS.
-> Dynamically downloads the content only when needed.
-> Reduces the app size.
-> Resources are Safely hosted in Apple server.
-> Efficient managing of memory in device (removes the resources when not needed)
-> Max. application size of total resources can be up to 20 GB.
-> Users will a have a better experience of the UI rich contents.
Three categories of on demand resources
– Initial install tag: Downloading the resources along with the app. The app size in app store include these resources.
– Prefetch tag order: Downloading the resources immediately after install. A simple example would be a “tutorial” related resources which might be needed after install.
– Download on demand: Downloading the content only when the resource is needed.
Managing On demand resources:-
-> Tagging: Resources are downloaded from the server based on tag name which is strings. Each resource is identified by its tag name. We can assign resources to tags. For e.g.: – We can assign tags “tutorial” to an image that displays basic app instructions. We can also apply one or multiple tags to a resource.
-> Developer request for the resources using tags. It also includes progress reporting of the downloading process, handling errors.
-> Developers can also set preservation priority and loading priority for the downloading. When preservation priority is set high, OS will most likely not delete the resource. When loading priority is high, it will be downloaded fast but might affect other app performance.
We can assign resources up to 512MB for a single tag, but the Apple recommended size is 64 MB. This will be useful in scenarios where if the internal memory gets low and the OS decides to purge resources associated with a tag. Eg: – If OS needs 64MB space to be cleared and if the tag size is 128 MB, then it will delete the 128MB completely. In this case, extra 64MB of content is deleted unnecessarily. So assigning the tag size efficiently increases the app performance.
On demand resources in iOS 9 and tvOS will help reduce the app size and give a better user experience. A small app with limited resources would not see much benefit, but a large app with many resources (like a game) would easily benefit from loading resources on demand i.e when needed.
iOS junior developer,