Content Distributions are a way to separate most or all of the app's content from its code. Apps generally gain access to data through local data sources (these are SQLite databases), Live data source (remote) via servers that offer interfaces returning XML or JSON) and the Media Folder.
The content in the Media Folder is locked into the app and cannot be modified once the app is created. The content that is made available via remote data sources doesn't need to be updated: it is a direct service accessed by the app and provides data in real time. Thus, the only thing Content Distributions addresses is On Device SQL Database (local data sources).
Enabling Content Distribution
To enable Content Distributions, select App Edit and under the General Tab you will see a section for Content Distribution.
- When in Develop, click on the 3 dots next to your app name then click on "Configure":
- Select the 'Content Distribution' Tab.
- Selecting 'Yes' in the Use Content Distribution for Android drop-down will enable this feature for Android.
- Selecting 'Yes' in the Use Content Distribution for iOS will enable this feature for iOS.
- The Content Distribution Patch Window will determine what time of day the update may occur. Note that on iOS this capability is only supported when the app is left running during that window: iOS inhibits this from occurring when the app is in the background.
- Selecting "Any Time" means that the app may check for patches (more on that below) at any time of the day.
- Selecting "Never" means that the app, once installed, will never check for patches.
- Selecting a time of day from the dropdown, means that starting during the specified hour, in GMT, the device will start looking for patches and will continue to look for updates until the time specified in minutes in the Content Distribution Patch Duration field. The time during that hour the app will look is randomized.
Please note that Web apps do not support Content Distributions at all.
Apps also look for patches at the following times:
- During startup
- When coming from the background if the Idle Refresh Timer has been exceeded (if Timer isn't set its value equals 0 meaning the app will always refresh coming from background)
- During the Content Update Patch Window (specified above)
In no circumstances does the user see any UI while the patch is downloading, aside from a network activity indication on the iOS Status Bar.
The patch will be applied when the app starts up. To "expedite" the process we currently cause the app to shut down when it's heading to the background. That way the app is assured of starting up with the fresh content.
Creating a Content Distribution
The Content Distribution itself is created when the app is generated.
For Android apps the Content Distribution takes the form of an "Expansion File" which at the time the app is distributed must be uploaded to the Google Play store. During the testing of ad hoc builds, the file will be hosted by EachScape.
For iOS apps, the content is always hosted at EachScape.
Content Distributions include
- All local databases (what holds the Data Source content) in the app
- as well as the associated downloaded files.
For example, if you have specified "download=true" or "download=original" then those files will be included in the Content Distribution. Read below for more details about these two options and patching.
Subsequent to the creation of the app, you can visit the Content Distribution area of the app and press the Create button to make a new Content Distribution. At the time the Content Distribution is created, a snapshot of the contents of all the data sources will be gathered. For this reason, it's important that you first update all the data sources prior to creating a new Content Distribution, just as you would do before doing a new build of an app.
Steps to Update
Data Source = Cloud Collection
- Publish Latest: Will create a fresh version of the SQL Database
- This is done in Cloud Collection
- Create New Content Distribution
- This is done in Develop under Content Distribution available under 'More Setting'
- Trigger the new update
Patching the Content
Content distributions are assigned a numeric ID number, called a patch level. As an example, let's say the app is created and the patch level is 100. Subsequently if a newer content distribution is created for the app, it will always have a higher number assigned as its patch level. Let's say the next patch level assigned to the same app is 108. And after that, a patch level of 112 is assigned.
Android apps currently don't support patching Content Distributions but they will in the future.
iOS apps support patching by downloading incremental changes. In this example, a device running the app at patch level 100 will look for more recent content distributions. If at the time the app is running patch level 108 is the newest published content distribution, the app will download the changes that take it from patch level 100 to 108. When patch level 112 becomes available, the patch will download only the file changes needed to go from patch level 108 to 112, whereas a device running at patch level 100 will need a larger patch to go directly from 100 to 112. The system figures all this out automatically.
After the patching has occurred, the app will continue to use the old content until it restarts. To this end, iOS apps currently shut down when they are sent to the background if a patch has been downloaded but not applied.
Making This Efficient
As it's desirable to minimize the size of patches. If you intend to enable patching of Content Distributions within your app, you should avoid using download=true and always use download=original. The reason is that download=true tends to change the names of files around each time the data source is created, causing the system to think a greater number of records have changed.
More about App Data
- App Data: SQL DB or Live Feeds
- Content Distribution through Google Play Store
- Process RSS, XML, JSON as a Live Feed