Monitoring Download Progress

This page instructs how to subscribe to download progress updates for routing data and map tiles and releasing the subscription once the download finishes.

observeOfflineRegionProgress combines routing and map progress by regionId and calculates overallState and overallPercent. The callback is delivered on the main queue and can update UIKit directly. The minimum supported polling interval is 200 milliseconds.

Subscribe and Publish progress updates

1
private var progressSubscription: NBNavigation.OfflineProgressSubscription?
2
3
func startObservingProgress() {
4
progressSubscription = NBNavigation.observeOfflineRegionProgress(
5
intervalMs: 1_000
6
) { [weak self] rows in
7
self?.applyProgress(rows) // Delivered on the main queue.
8
}
9
}
10
11
func stopObservingProgress() {
12
progressSubscription?.cancel()
13
progressSubscription = nil
14
}

The screen must retain the subscription and cancel it when the screen closes. Canceling the subscription stops only UI polling but it does not stop the download. To display each data source separately, use observeUnifiedOfflineProgress and distinguish routing from map through entry.kind.

FieldMeaningUI guidance
overallStateCombined region task stateControls buttons and status text
overallPercentCombined percentage for routing data and map tilesDisplays overall progress
routeNetworkRouting subtask, if availableShows routing-data status
mapTileMap-tile subtask, if availableShows map-display data status