@interface MGLOfflineStorage : NSObject
MGLOfflineStorage implements a singleton (shared object) that manages offline packs. All of this class’s instance methods are asynchronous, reflecting the fact that offline resources are stored in a database.
Returns the shared offline storage object.
+ (nonnull instancetype)sharedOfflineStorage;
Creates and registers an offline pack that downloads the resources needed to use the given region offline.
The resulting pack starts out with a state of
MGLOfflinePackStateInactive. To begin downloading resources, call
-[MGLOfflinePack resume]. To monitor download progress, set the pack’s
delegateproperty to an object that conforms to the
- (void)addPackForRegion:(nonnull id<MGLOfflineRegion>)region withContext:(nonnull NSData *)context completionHandler: (nullable MGLOfflinePackAdditionCompletionHandler)completion;
A region to download.
Arbitrary data to store alongside the downloaded resources.
The completion handler to call once the pack has been added. This handler is executed asynchronously on the main queue.
Unregisters the given offline pack and frees any resources that are no longer required by any remaining packs.
As soon as this method is called on a pack, the pack becomes invalid; any attempt to send it a message will result in an exception being thrown. If an error occurs and the pack cannot be removed, do not attempt to reuse the pack object. Instead, use the
-getPacksWithCompletionHandler:method to obtain a valid pointer to the pack object.
- (void)removePack:(nonnull MGLOfflinePack *)pack withCompletionHandler: (nullable MGLOfflinePackRemovalCompletionHandler)completion;
The offline pack to remove.
The completion handler to call once the pack has been removed. This handler is executed asynchronously on the main queue.
Asynchronously calls a completion callback with all existing offline packs.
- (void)getPacksWithCompletionHandler: (nonnull MGLOfflinePackListingCompletionHandler)completion;
The completion handler to call with the list of packs. This handler is executed asynchronously on the main queue.
Sets the maximum number of Mapbox-hosted tiles that may be downloaded and stored on the current device.
Once this limit is reached,
-[MGLOfflinePackDelegate offlinePack:didReceiveMaximumAllowedMapboxTiles:]is called on every delegate of
MGLOfflinePackuntil already downloaded tiles are removed by calling the
NoteThe Mapbox Terms of Service prohibits changing or bypassing this limit without permission from Mapbox. Contact your Mapbox sales representative to have the limit raised.