Map Update
- UIKit
This example demonstrates how to use GEMKit in a UIKit application to update the maps. There are two scenarios explained here, the manual update that is mandatory when having offline maps downloaded, and the default automatic update when no offline maps are used.
Check the full implementation on GitHub.
How it Works
- Checks the map update status and displays the
Prepare Testbutton only when the map is up to date to ensure correct resource handling (especially on a fresh install). - Integrates the
Prepare Testaction to simulate the scenario for an update by adding an old regional map and replacing the default world map resource with an older version. - Applies the necessary logic to update the maps to the latest version.
- Manages and integrates map update testing functionality seamlessly within the app's UI.
The unmodified example requires the update to be applied manually after checking the status. If you want to test the automatic update process, without the use of offline maps, you will need to make a tiny adjustment in the example code. This is explained in the code snippets below.
In order for the example to work correctly you need to be connected to the internet so the SDK can check for updates and also retrieve initial missing map resources, as explained above. If the device is not connected to the internet the update check will fail and the button won't be displayed in order to avoid resources incompatibility issues for this test scenario.
The direct resource file manipulation done in this example is a "hack" to simulate the map update process and is only for demonstration purposes, you should NOT manipulate resource files in this way.




Map Display and Preparing Testing Scenario
The following code outlines the main view, which displays the map, adds the button that will lead to the maps view, and adds the Prepare Test button after checking the map update status:
Preparing Testing Scenario
The following code demonstrates the "hack" for this example, called after tapping the Prepare Test button, which involves replacing the current map resources with older versions, and then reinitializing the SDK and the map related objects in order to enable the map update flow:
TESTING AUTOMATIC UPDATES
If you wish to test the automatic update without the use of offline maps, you should edit the prepareTestingScenario method to remove or comment out the code under the // Offline Map section, leaving only the // World Map snippet. Make sure to delete any existing offline maps manually or by quickly deleting and reinstalling the app.
With this setup, after tapping the Prepare Test button, the update will be immediately applied after reinitializing the SDK with the old resource. To control when and if your application can apply the update you must implement and modify the shouldUpdateWorldwideRoadMap(for status: ContentStoreOnlineSupportStatus) method from the GEMSdkDelegate. This method can be seen in the code above, under the GEMSdkDelegate section.
Checking for Updates and Updating Maps
The following code implements the logic for checking for map updates inside the Maps view, prompting the user to update if one is available, as well as showing the update download status and progress by making use of ContentUpdateDelegate:
Rest of the UI code for the Maps view is not included here as it's not relevant for the map update process, check the full MapsViewController.swift file for the complete implementation.