MMKOfflineCacheManager

class MMKOfflineCacheManager : NSObject

Note

This feature is not available in the free MapKit version.

Offline cache manager.

Summary

Instance methods

func regions() -> [MMKOfflineCacheRegion]
Copying a list of regions from memory

func allowUseCellularNetwork(withUseCellular useCellular: Bool)
Indicates whether to allow downloading using cellular networks (3G, LTE, and other)

func addRegionListUpdatesListener(with regionListUpdatesListener: MMKOfflineMapRegionListUpdatesListener)
Subscribe on update of region list

The class does not retain the object in the 'regionListUpdatesListener' parameter

func removeRegionListUpdatesListener(with regionListUpdatesListener: MMKOfflineMapRegionListUpdatesListener)
Unsubscribe from region list update

func addErrorListenerWith( errorListener: MMKOfflineCacheManagerErrorListener_)
Subscribe on errors

The class does not retain the object in the 'errorListener' parameter

func removeErrorListenerWith( errorListener: MMKOfflineCacheManagerErrorListener_)
Unsubscribe from errors

func addRegionListener(with regionListener: MMKOfflineCacheRegionListener)
Subscribe on status events

The class does not retain the object in the 'regionListener' parameter

func removeRegionListener(with regionListener: MMKOfflineCacheRegionListener)
Unsubscribe from status events

func getCitiesWithRegionId(_ regionId: UInt) -> [String]
Returns a list of cities

func getStateWithRegionId( regionId: UInt) -> MMKOfflineCacheRegionState_
Current region state

func getDownloadedReleaseTime(withRegionId regionId: UInt) -> Date?
Release time of downloaded region files

func getProgressWithRegionId(_ regionId: UInt) -> Float
Current region progress [0,1]

func startDownload(withRegionId regionId: UInt)
Start to download new offline cache for the region or update if region has been downloaded

func stopDownload(withRegionId regionId: UInt)
Stop downloading of region

func pauseDownload(withRegionId regionId: UInt)
Pause downloading of region

func drop(withRegionId regionId: UInt)
Drop region data from the device

func mayBeOutOfAvailableSpace(withRegionId regionId: UInt) -> Bool
Returns true if available disk space might not be enough for installation of the region data

func isLegacyPath(withRegionId regionId: UInt) -> Bool
Returns true if region has files with legacy localized path

func computeCacheSize(sizeCallback: @escaping MMKOfflineCacheManagerSizeCallback)
Calculates the full cache size in bytes

func requestPath(pathGetterListener: @escaping MMKOfflineCacheManagerPathGetterListener)
Provides the data path for offline cache files

func moveData(withNewPath newPath: String,
                 dataMoveListener: MMKOfflineCacheDataMoveListener)
Moves offline caches to the specified folder

func setCachePathWithPath(_ path: String,
              pathSetterListener: @escaping MMKOfflineCacheManagerPathSetterListener)
Sets a new path for caches

func enableAutoUpdate(withEnable enable: Bool)
Enables autoupdating downloaded caches when they become outdated

func clear(clearCallback: @escaping MMKOfflineCacheManagerClearCallback)
Erases all data for downloads and regions and wipes the cache

func requestRegionsAtPoint(with point: MMKPoint,
               regionsAtPointCallback: @escaping MMKRegionsAtPointCallback)
Provides ids of regions containing specified point

Properties

var isValid: Bool { get }
Tells if this object is valid or no

Instance methods

regions()

func regions() -> [MMKOfflineCacheRegion]

Copying a list of regions from memory. All changes of regions won't affected on on the collection.


allowUseCellularNetwork(withUseCellular:)

func allowUseCellularNetwork(withUseCellular useCellular: Bool)

Indicates whether to allow downloading using cellular networks (3G, LTE, and other). Disallowed by default.


addRegionListUpdatesListener(with:)

func addRegionListUpdatesListener(with regionListUpdatesListener: MMKOfflineMapRegionListUpdatesListener)

Subscribe on update of region list

The class does not retain the object in the 'regionListUpdatesListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.


removeRegionListUpdatesListener(with:)

func removeRegionListUpdatesListener(with regionListUpdatesListener: MMKOfflineMapRegionListUpdatesListener)

Unsubscribe from region list update


addErrorListenerWith(_:)

func addErrorListenerWith( errorListener: MMKOfflineCacheManagerErrorListener_)

Subscribe on errors

The class does not retain the object in the 'errorListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.


removeErrorListenerWith(_:)

func removeErrorListenerWith( errorListener: MMKOfflineCacheManagerErrorListener_)

Unsubscribe from errors


addRegionListener(with:)

func addRegionListener(with regionListener: MMKOfflineCacheRegionListener)

Subscribe on status events

The class does not retain the object in the 'regionListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.


removeRegionListener(with:)

func removeRegionListener(with regionListener: MMKOfflineCacheRegionListener)

Unsubscribe from status events


getCitiesWithRegionId(_:)

func getCitiesWithRegionId(_ regionId: UInt) -> [String]

Returns a list of cities.


getStateWithRegionId(_:)

func getStateWithRegionId( regionId: UInt) -> MMKOfflineCacheRegionState_

Current region state


getDownloadedReleaseTime(withRegionId:)

func getDownloadedReleaseTime(withRegionId regionId: UInt) -> Date?

Release time of downloaded region files


getProgressWithRegionId(_:)

func getProgressWithRegionId(_ regionId: UInt) -> Float

Current region progress [0,1]. For downloaded files returns 1; If we haven't start download yet, returns 0;


startDownload(withRegionId:)

func startDownload(withRegionId regionId: UInt)

Start to download new offline cache for the region or update if region has been downloaded


stopDownload(withRegionId:)

func stopDownload(withRegionId regionId: UInt)

Stop downloading of region


pauseDownload(withRegionId:)

func pauseDownload(withRegionId regionId: UInt)

Pause downloading of region


drop(withRegionId:)

func drop(withRegionId regionId: UInt)

Drop region data from the device. If data is being downloaded then downloading is cancelled.


mayBeOutOfAvailableSpace(withRegionId:)

func mayBeOutOfAvailableSpace(withRegionId regionId: UInt) -> Bool

Returns true if available disk space might not be enough for installation of the region data.


isLegacyPath(withRegionId:)

func isLegacyPath(withRegionId regionId: UInt) -> Bool

Returns true if region has files with legacy localized path. If region in downloading state result may be incorrect.


computeCacheSize(sizeCallback:)

func computeCacheSize(sizeCallback: @escaping MMKOfflineCacheManagerSizeCallback)

Calculates the full cache size in bytes.


requestPath(pathGetterListener:)

func requestPath(pathGetterListener: @escaping MMKOfflineCacheManagerPathGetterListener)

Provides the data path for offline cache files.


moveData(withNewPath:dataMoveListener:)

func moveData(withNewPath newPath: String,
                 dataMoveListener: MMKOfflineCacheDataMoveListener)

Moves offline caches to the specified folder. This operation is non-cancellable. If there is already a pending operation to set the cache path, it throws an error (Android). If the application exits before the operation is completed, it does not take effect, but garbage will not be cleared.

The class does not retain the object in the 'dataMoveListener' parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a class.

Parameters

newPath

New path to store data.

dataMoveListener

It will be unsubscribed automatically when the operation is completed or fails with an error.


setCachePathWithPath(_:pathSetterListener:)

func setCachePathWithPath(_ path: String,
              pathSetterListener: @escaping MMKOfflineCacheManagerPathSetterListener)

Sets a new path for caches. If the specified path contains an existing cache, this cache will be used; otherwise, a new cache will be initialized.


enableAutoUpdate(withEnable:)

func enableAutoUpdate(withEnable enable: Bool)

Enables autoupdating downloaded caches when they become outdated.


clear(clearCallback:)

func clear(clearCallback: @escaping MMKOfflineCacheManagerClearCallback)

Erases all data for downloads and regions and wipes the cache. Forces reloading the list from the remote source


requestRegionsAtPoint(with:regionsAtPointCallback:)

func requestRegionsAtPoint(with point: MMKPoint,
               regionsAtPointCallback: @escaping MMKRegionsAtPointCallback)

Provides ids of regions containing specified point. Some of the returned regions may not be available in current regions list.


Properties

isValid

var isValid: Bool { get }

Tells if this object is valid or no. Any method called on an invalid object will throw an exception. The object becomes invalid only on UI thread, and only when its implementation depends on objects already destroyed by now. Please refer to general docs about the interface for details on its invalidation.