MMKOfflineCacheManager

@interface MMKOfflineCacheManager : NSObject

Note

This feature is not available in the free MapKit version.

Offline cache manager.

Summary

Instance methods

- (nonnull NSArray<MMKOfflineCacheRegion *> *)regions;
Copying a list of regions from memory

- (void)allowUseCellularNetworkWithUseCellular:(BOOL)useCellular;
Indicates whether to allow downloading using cellular networks (3G, LTE, and other)

- (void)addRegionListUpdatesListenerWithRegionListUpdatesListener:
    (nonnull id<MMKOfflineMapRegionListUpdatesListener>)
        regionListUpdatesListener;

Subscribe on update of region list

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

- (void)removeRegionListUpdatesListenerWithRegionListUpdatesListener:
    (nonnull id<MMKOfflineMapRegionListUpdatesListener>)
        regionListUpdatesListener;

Unsubscribe from region list update

- (void)addErrorListenerWithErrorListener:
    (nonnull id<MMKOfflineCacheManagerErrorListener>)errorListener;

Subscribe on errors

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

- (void)removeErrorListenerWithErrorListener:
    (nonnull id<MMKOfflineCacheManagerErrorListener>)errorListener;

Unsubscribe from errors

- (void)addRegionListenerWithRegionListener:
    (nonnull id<MMKOfflineCacheRegionListener>)regionListener;

Subscribe on status events

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

- (void)removeRegionListenerWithRegionListener:
    (nonnull id<MMKOfflineCacheRegionListener>)regionListener;

Unsubscribe from status events

- (nonnull NSArray<NSString *> *)getCitiesWithRegionId:(NSUInteger)regionId;
Returns a list of cities

- (MMKOfflineCacheRegionState)getStateWithRegionId:(NSUInteger)regionId;
Current region state

- (nullable NSDate *)getDownloadedReleaseTimeWithRegionId:(NSUInteger)regionId;
Release time of downloaded region files

- (float)getProgressWithRegionId:(NSUInteger)regionId;
Current region progress [0,1]

- (void)startDownloadWithRegionId:(NSUInteger)regionId;
Start to download new offline cache for the region or update if region has been downloaded

- (void)stopDownloadWithRegionId:(NSUInteger)regionId;
Stop downloading of region

- (void)pauseDownloadWithRegionId:(NSUInteger)regionId;
Pause downloading of region

- (void)dropWithRegionId:(NSUInteger)regionId;
Drop region data from the device

- (BOOL)mayBeOutOfAvailableSpaceWithRegionId:(NSUInteger)regionId;
Returns true if available disk space might not be enough for installation of the region data

- (BOOL)isLegacyPathWithRegionId:(NSUInteger)regionId;
Returns true if region has files with legacy localized path

- (void)computeCacheSizeWithSizeCallback:
    (nonnull MMKOfflineCacheManagerSizeCallback)sizeCallback;

Calculates the full cache size in bytes

- (void)requestPathWithPathGetterListener:
    (nonnull MMKOfflineCacheManagerPathGetterListener)pathGetterListener;

Provides the data path for offline cache files

- (void)moveDataWithNewPath:(nonnull NSString *)newPath
           dataMoveListener:
               (nonnull id<MMKOfflineCacheDataMoveListener>)dataMoveListener;

Moves offline caches to the specified folder

- (void)setCachePathWithPath:(nonnull NSString *)path
          pathSetterListener:(nonnull MMKOfflineCacheManagerPathSetterListener)
                                 pathSetterListener;

Sets a new path for caches

- (void)enableAutoUpdateWithEnable:(BOOL)enable;
Enables autoupdating downloaded caches when they become outdated

- (void)clearWithClearCallback:
    (nonnull MMKOfflineCacheManagerClearCallback)clearCallback;

Erases all data for downloads and regions and wipes the cache

- (void)requestRegionsAtPointWithPoint:(nonnull MMKPoint *)point
                regionsAtPointCallback:
                    (nonnull MMKRegionsAtPointCallback)regionsAtPointCallback;

Provides ids of regions containing specified point

Properties

@property (nonatomic, readonly, getter=isValid) BOOL valid;
Tells if this object is valid or no

Instance methods

regions

- (nonnull NSArray<MMKOfflineCacheRegion *> *)regions;

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


allowUseCellularNetworkWithUseCellular:

- (void)allowUseCellularNetworkWithUseCellular:(BOOL)useCellular;

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


addRegionListUpdatesListenerWithRegionListUpdatesListener:

- (void)addRegionListUpdatesListenerWithRegionListUpdatesListener:
    (nonnull id<MMKOfflineMapRegionListUpdatesListener>)
        regionListUpdatesListener;

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.


removeRegionListUpdatesListenerWithRegionListUpdatesListener:

- (void)removeRegionListUpdatesListenerWithRegionListUpdatesListener:
    (nonnull id<MMKOfflineMapRegionListUpdatesListener>)
        regionListUpdatesListener;

Unsubscribe from region list update


addErrorListenerWithErrorListener:

- (void)addErrorListenerWithErrorListener:
    (nonnull id<MMKOfflineCacheManagerErrorListener>)errorListener;

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.


removeErrorListenerWithErrorListener:

- (void)removeErrorListenerWithErrorListener:
    (nonnull id<MMKOfflineCacheManagerErrorListener>)errorListener;

Unsubscribe from errors


addRegionListenerWithRegionListener:

- (void)addRegionListenerWithRegionListener:
    (nonnull id<MMKOfflineCacheRegionListener>)regionListener;

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.


removeRegionListenerWithRegionListener:

- (void)removeRegionListenerWithRegionListener:
    (nonnull id<MMKOfflineCacheRegionListener>)regionListener;

Unsubscribe from status events


getCitiesWithRegionId:

- (nonnull NSArray<NSString *> *)getCitiesWithRegionId:(NSUInteger)regionId;

Returns a list of cities.


getStateWithRegionId:

- (MMKOfflineCacheRegionState)getStateWithRegionId:(NSUInteger)regionId;

Current region state


getDownloadedReleaseTimeWithRegionId:

- (nullable NSDate *)getDownloadedReleaseTimeWithRegionId:(NSUInteger)regionId;

Release time of downloaded region files


getProgressWithRegionId:

- (float)getProgressWithRegionId:(NSUInteger)regionId;

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


startDownloadWithRegionId:

- (void)startDownloadWithRegionId:(NSUInteger)regionId;

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


stopDownloadWithRegionId:

- (void)stopDownloadWithRegionId:(NSUInteger)regionId;

Stop downloading of region


pauseDownloadWithRegionId:

- (void)pauseDownloadWithRegionId:(NSUInteger)regionId;

Pause downloading of region


dropWithRegionId:

- (void)dropWithRegionId:(NSUInteger)regionId;

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


mayBeOutOfAvailableSpaceWithRegionId:

- (BOOL)mayBeOutOfAvailableSpaceWithRegionId:(NSUInteger)regionId;

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


isLegacyPathWithRegionId:

- (BOOL)isLegacyPathWithRegionId:(NSUInteger)regionId;

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


computeCacheSizeWithSizeCallback:

- (void)computeCacheSizeWithSizeCallback:
    (nonnull MMKOfflineCacheManagerSizeCallback)sizeCallback;

Calculates the full cache size in bytes.


requestPathWithPathGetterListener:

- (void)requestPathWithPathGetterListener:
    (nonnull MMKOfflineCacheManagerPathGetterListener)pathGetterListener;

Provides the data path for offline cache files.


moveDataWithNewPath:dataMoveListener:

- (void)moveDataWithNewPath:(nonnull NSString *)newPath
           dataMoveListener:
               (nonnull id<MMKOfflineCacheDataMoveListener>)dataMoveListener;

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:

- (void)setCachePathWithPath:(nonnull NSString *)path
          pathSetterListener:(nonnull MMKOfflineCacheManagerPathSetterListener)
                                 pathSetterListener;

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.


enableAutoUpdateWithEnable:

- (void)enableAutoUpdateWithEnable:(BOOL)enable;

Enables autoupdating downloaded caches when they become outdated.


clearWithClearCallback:

- (void)clearWithClearCallback:
    (nonnull MMKOfflineCacheManagerClearCallback)clearCallback;

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


requestRegionsAtPointWithPoint:regionsAtPointCallback:

- (void)requestRegionsAtPointWithPoint:(nonnull MMKPoint *)point
                regionsAtPointCallback:
                    (nonnull MMKRegionsAtPointCallback)regionsAtPointCallback;

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


Properties

valid

@property (nonatomic, readonly, getter=isValid) BOOL valid;

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.