OfflineClient
@objcMembers
public class OfflineClient : Client
An API client that adds offline features on top of the regular online API client.
Note
Requires Algolia’s Offline Core SDK. TheenableOfflineMode(...) method must be called with a valid license
key prior to calling any offline-related method.
-
Path to directory where the local data is stored. Defaults to an
algoliasub-directory inside theLibrary/Application Supportdirectory. If you set it to another value, do so before callingenableOfflineMode(...).Warning
This directory will be explicitly excluded from iCloud/iTunes backup.Declaration
Swift
@objc public var rootDataDir: String
-
Create a new offline-capable Algolia Search client.
Note
Offline mode is disabled by default, until you call
enableOfflineMode(...).Declaration
Swift
@objc public override init(appID: String, apiKey: String)Parameters
appIDthe application ID you have in your admin interface
apiKeya valid API key for the service
-
Enable the offline mode.
Declaration
Swift
@objc(enableOfflineModeWithLicenseKey:) public func enableOfflineMode(licenseKey: String)Parameters
licenseKeyLicense key for Algolia’s SDK.
-
Obtain a mirrored index.
Note
The offline client returns mirror-capable indices.
Note
Only one instance can exist for a given index name. Subsequent calls to this method with the same index name will return the same instance, unless it has already been released.
Warning
The name should not overlap with any
OfflineIndex(seeofflineIndex(withName:)).Declaration
Swift
@objc public override func index(withName indexName: String) -> MirroredIndexParameters
indexNameThe name of the index.
Return Value
A proxy to the specified index.
-
Obtain an offline index.
Note
Only one instance can exist for a given index name. Subsequent calls to this method with the same index name will return the same instance, unless it has already been released.
Warning
The name should not overlap with any
MirroredIndex(seeindex(withName:)).Declaration
Swift
@objc public func offlineIndex(withName indexName: String) -> OfflineIndexParameters
indexNameThe name of the index.
Return Value
A proxy to the specified index.
-
Test if an index has offline data on disk.
Note
This applies both to
MirroredIndexandOfflineIndexinstances.Warning
This method is synchronous!
Declaration
Swift
@objc public func hasOfflineData(indexName: String) -> BoolParameters
indexNameThe index’s name.
Return Value
trueif data exists on disk for this index,falseotherwise. -
List existing offline indexes. Only indices that actually exist on disk are listed. If an instance was created but never synced or written to, it will not appear in the list.
Note
This applies both to
MirroredIndexandOfflineIndexinstances.Declaration
Swift
@discardableResult @objc(listOfflineIndexes:) public func listOfflineIndexes(completionHandler: @escaping CompletionHandler) -> OperationParameters
completionHandlerCompletion handler to be notified of the request’s outcome.
Return Value
A cancellable operation.
-
Delete an offline index.
Note
This applies both to
MirroredIndexandOfflineIndexinstances.Declaration
Swift
@discardableResult @objc(deleteOfflineIndexWithName:completionHandler:) public func deleteOfflineIndex(withName indexName: String, completionHandler: CompletionHandler? = nil) -> OperationParameters
indexNameName of the index to delete.
completionHandlerCompletion handler to be notified of the request’s outcome.
Return Value
A cancellable operation.
-
Move an existing index.
Warning
This will overwrite the destination index if it exists.
Note
This applies both to
MirroredIndexandOfflineIndexinstances.Declaration
Swift
@discardableResult @objc public func moveOfflineIndex(from srcIndexName: String, to dstIndexName: String, completionHandler: CompletionHandler? = nil) -> OperationParameters
srcIndexNameName of index to move.
dstIndexNameThe new index name.
completionHandlerCompletion handler to be notified of the request’s outcome.
Return Value
A cancellable operation.
OfflineClient Class Reference