Update Offline Map Packages

The SDK does not download regional updates automatically. Use this guide to periodically check the online map catalog for newer region versions and install replacement packages when an update is available.

1
private func isNewer(remote: String?, than local: String?) -> Bool {
2
return NGLRegionalOfflineVersionIsNewer(remote, local)
3
}
4
5
func checkForUpdates() {
6
let installed = NGLRegionalOffline.listInstalledRegions()
7
let localById = Dictionary(
8
uniqueKeysWithValues: installed.map { ($0.regionId, $0) }
9
)
10
11
NGLRegionalOffline.fetchRegionList {
12
[weak self] catalog, error in
13
guard let self, error == nil else { return }
14
15
for remote in catalog ?? [] {
16
guard let local = localById[remote.regionId] else { continue }
17
18
if isNewer(remote: remote.version, than: local.regionVersion) {
19
// remote.regionId has an update.
20
}
21
}
22
}
23
}

If the service does not provide a stable version string, use timestamp only according to the service contract. Do not detect updates by comparing file sizes alone.

Install a full replacement update

Use the following script for a complete replacement of an installed offline package:

1
NGLRegionalOffline.downloadRegion(
2
withId: regionId,
3
clearBefore: true
4
) { [weak self] error in
5
if let error {
6
self?.handleRegionalOfflineError(error)
7
}
8
}

The update is complete only when the progress listener reports .completed.

For package-level update detection:

  1. Call fetchRegionDetail(forRegionId:) to obtain the latest online tarList.

  2. Call loadDetail(forRegionId:) to obtain the locally cached details.

  3. Index the packages by tarName.

  4. Treat added packages, removed packages, or changed package versions as a regional catalog update.