ArcGIS Runtime SDK for iOS: AGSGeodatabaseSyncTask Class Reference
ArcGIS Runtime SDK for iOS  100.15
AGSGeodatabaseSyncTask Class Reference

Description

A task to download and synchronize a sync-enabled geodatabase.

Instances of this class represent a task that can be used to create, download, and synchronize a sync-enabled geodatabase from a sync-enabled ArcGIS feature service. The service could be hosted in the cloud on ArcGIS Online or on-premises with ArcGIS servers.

Geodatabases generated from an ArcGIS feature service can be used for querying and viewing feature data when the application is offline. Geodatabases can also be edited when offline. Geodatabases for editing can only be requested if the service supports synchronization.

Geodatabases can be synchronized with the service when the application is able to connect to a network again. Synchronization can perform two tasks:

  • Upload to the service changes made while offline
  • Download changes made on the service to the geodatabase
Since
100
See also
AGSGeodatabase
Inheritance diagram for AGSGeodatabaseSyncTask:
AGSLoadableRemoteResourceBase <AGSAPIKeyResource> AGSLoadableBase <AGSRemoteResource> AGSObject <AGSLoadable>

Instance Methods

(void) - cancelLoad
 
(id< AGSCancelable >) - defaultGenerateGeodatabaseParametersWithExtent:completion:
 
(id< AGSCancelable >) - defaultSyncGeodatabaseParametersWithGeodatabase:completion:
 
(id< AGSCancelable >) - defaultSyncGeodatabaseParametersWithGeodatabase:syncDirection:completion:
 
(void) - doCancelLoading
 
(void) - doStartLoading:
 
(AGSGenerateGeodatabaseJob *) - generateJobWithParameters:downloadFileURL:
 
(id< AGSCancelable >) - importDeltaWithGeodatabase:inputPath:completion:
 
(instancetype) - initWithURL:
 
(void) - loadDidFinishWithError:
 
(void) - loadWithCompletion:
 
(void) - onLoadStatusChanged
 
(id< AGSCancelable >) - registerSyncEnabledGeodatabase:completion:
 
(void) - retryLoadWithCompletion:
 
(AGSSyncGeodatabaseJob *) - syncJobWithParameters:geodatabase:
 
(AGSSyncGeodatabaseJob *) - syncJobWithSyncDirection:rollbackOnFailure:geodatabase:
 
(id< AGSCancelable >) - unregisterGeodatabase:completion:
 
(id< AGSCancelable >) - unregisterGeodatabaseWithSyncID:completion:
 

Class Methods

(id< AGSCancelable >) + exportDeltaWithGeodatabase:outputFileURL:completion:
 
(instancetype) + geodatabaseSyncTaskWithURL:
 
(id< AGSCancelable >) + importDeltaWithGeodatabase:deltaPath:completion:
 

Properties

NSString * APIKey
 
AGSCredentialcredential
 
AGSArcGISFeatureServiceInfofeatureServiceInfo
 
NSError * loadError
 
AGSLoadStatus loadStatus
 
AGSRequestConfigurationrequestConfiguration
 
NSURL * URL
 

Method Documentation

◆ cancelLoad

- (void) cancelLoad
requiredinherited

Cancels loading if it is in progress, otherwise it does nothing. This should be called carefully because other objects could be waiting for loadWithCompletion: or retryLoadWithCompletion: to complete and this will call them all back with the error of NSUserCancelledError

Since
100

◆ defaultGenerateGeodatabaseParametersWithExtent:completion:

- (id<AGSCancelable>) defaultGenerateGeodatabaseParametersWithExtent: (AGSGeometry *)  extent
completion: (nullable void(^)(AGSGenerateGeodatabaseParameters *__nullable params, NSError *__nullable error))  completion 

A convenience method to get properly initialized parameters for generating a geodatabase.

This will populate the parameters with values matching what the service supports. For example if the service does not support an AGSSyncModelLayer sync model then an AGSSyncModelGeodatabase will be used. All layers from the service will be included. The extent will be the service's full extent. Attachments are included by default, but related tables/layers are not included. Features inside the provided extent are included in the generated geodatabase. Output features are in the spatial reference of the given extent.

Parameters
completionblock that is invoked with the initialized params if the method succeeds, or an error if it fails.
Returns
An operation that can be canceled.
Since
100

◆ defaultSyncGeodatabaseParametersWithGeodatabase:completion:

- (id<AGSCancelable>) defaultSyncGeodatabaseParametersWithGeodatabase: (AGSGeodatabase *)  geodatabase
completion: (nullable void(^)(AGSSyncGeodatabaseParameters *__nullable params, NSError *__nullable error))  completion 

Creates default parameters for a sync geodatabase.

This will populate the parameters with values matching what the sync task's feature service and the geodatabase supports. For a geodatabase with AGSSyncModelLayer, all geodatabase layers will be included. If the service is read-only, then the sync direction will be AGSSyncDirectionDownload. Otherwise the sync direction will be AGSSyncDirectionBidirectional.

Parameters
geodatabasethat needs to be synchronized with its service.
completionblock that is invoked with the initialized params if the method succeeds, or an error if it fails.
Returns
An operation that can be canceled.
Since
100

◆ defaultSyncGeodatabaseParametersWithGeodatabase:syncDirection:completion:

- (id<AGSCancelable>) defaultSyncGeodatabaseParametersWithGeodatabase: (AGSGeodatabase *)  geodatabase
syncDirection: (AGSSyncDirection syncDirection
completion: (nullable void(^)(AGSSyncGeodatabaseParameters *__nullable params, NSError *__nullable error))  completion 

Creates default parameters for a sync geodatabase using the given sync direction.

This will populate the parameters with values matching what the sync task's feature service and the geodatabase supports.

For a geodatabase with a AGSSyncModelLayer object, all geodatabase layers will be included.

A service is editable if it has capabilities that include any of create, update or delete. In this case both AGSSyncDirectionBidirectional and AGSSyncDirectionUpload are supported sync directions. Alternatively, a service that does not have create, update or delete capability is considered read-only and only AGSSyncDirectionDownload will be supported. If the given sync direction is not compatible with the sync task's feature service or the geodatabase is not sync enabled, the returned task will fail.

Returns a parameters object with the given sync direction. Other parameters are populated with default values.

Parameters
geodatabasethat needs to be synchronized with its service.
syncDirectionthe sync direction to use.
completionblock that is invoked with the initialized params if the method succeeds, or an error if it fails.
Returns
An operation that can be canceled.
Since
100.3

◆ doCancelLoading

- (void) doCancelLoading

Never call this method directly. The framework calls this method on a background thread when cancelLoad (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to cancel loading their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) at the end passing in an error representing NSUserCancelledError.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ doStartLoading:

- (void) doStartLoading: (BOOL)  retrying

Never call this method directly. The framework calls this method on a background thread when loadWithCompletion: (AGSLoadable-p) or retryLoadWithCompletion: (AGSLoadable-p) is called. It is meant to be overriden by subclasses. Subclasses should override this method to load their data and call loadDidFinishWithError: (AGSLoadableBase(ForSubclassEyesOnly)) upon completion, passing in the error if any.

Parameters
retryingflag that is true if this method was called from retryLoadWithCompletion: (AGSLoadable-p).
Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ exportDeltaWithGeodatabase:outputFileURL:completion:

+ (id<AGSCancelable>) exportDeltaWithGeodatabase: (AGSGeodatabase *)  geodatabase
outputFileURL: (NSURL *)  outputFileURL
completion: (void(^)(BOOL result, NSError *__nullable error))  completion 

Generates an upload delta geodatabase file containing all the changes since the last sync.

A delta geodatabase contains the changes that have occurred since a mobile replica AGSGeodatabase was last-synchronized with the feature service. See https://developers.arcgis.com/rest/services-reference/enterprise/synchronize-replica.htm for an overview of the delta files used in synchronization. An "upload" delta geodatabase contains the local edits, performed on the user's device, to be sent to the originating feature service.

When you run this task, any local edits in the AGSGeodatabase will be exported to the specified output URL. The output URL should include the full path and file name (ending in ".geodatabase") for the export.

The delta file created by this method is not sent to the server and has no impact on any subsequent sync job. You can call this method repeatedly without affecting the state of the local geodatabase.

The task returned by this method has a boolean result that indicates whether or not a delta geodatabase was created.

You should not execute more than one sync on a particular geodatabase at the same time. This includes operations that export or import deltas from the local AGSGeodatabase:

Parameters
geodatabaseThe geodatabase to generate a delta from.
outputFileURLThe path and filename to save the generated delta to.
completionA block that is invoked when the operation finishes. The result parameter is populated if the operation completed successfully, otherwise the error parameter is populated.
Returns
An operation which can be canceled.
See also
AGSSyncGeodatabaseParameters::keepGeodatabaseDeltas
Since
100.10

◆ generateJobWithParameters:downloadFileURL:

- (AGSGenerateGeodatabaseJob*) generateJobWithParameters: (AGSGenerateGeodatabaseParameters *)  parameters
downloadFileURL: (NSURL *)  downloadFileURL 

Returns a job which can be used to generate a geodatabase from an ArcGIS feature service using the specified parameters. The result of the job will be of type AGSGeodatabase.

Note
The job is dormant and needs to be explicitly started using startWithStatusHandler:completion: (AGSGenerateGeodatabaseJob)
Parameters
parametersspecifying what data to include in the generated geodatabase.
downloadFileURLwhere the geodatabase should be saved on disk, including the desired file name ending with the .geodatabase file extension.
Returns
A job representing the progress on the server. The result of the job will be of type AGSGeodatabase.
Since
100

◆ geodatabaseSyncTaskWithURL:

+ (instancetype) geodatabaseSyncTaskWithURL: (NSURL *)  URL

Creates a task with a URL to a sync-enabled ArcGIS feature service.

Parameters
URLto a sync-enabled ArcGIS feature service.
Returns
A new task.
Since
100

◆ importDeltaWithGeodatabase:deltaPath:completion:

+ (id<AGSCancelable>) importDeltaWithGeodatabase: (AGSGeodatabase *)  geodatabase
deltaPath: (NSURL *)  deltaPath
completion: (void(^)(NSArray< AGSSyncLayerResult * > *__nullable result, NSError *__nullable error))  completion 

Imports a geodatabase delta and applies it to the given geodatabase.

A delta geodatabase contains the changes that have occurred since a mobile replica AGSGeodatabase was last-synchronized with the feature service. See https://developers.arcgis.com/rest/services-reference/enterprise/synchronize-replica.htm for an overview of the delta files used in synchronization. A "download" delta geodatabase contains the online edits that will be imported to the local geodatabase.

The task returned by this method returns an array of AGSSyncLayerResult.

You should not execute more than one sync on a particular geodatabase at the same time. This includes operations that export or import deltas from the local AGSGeodatabase:

Parameters
geodatabaseinto which to import the delta.
deltaPathof the delta file (*.gdb file) containing the changes from the sync-enabled feature service.
completionblock that is invoked when the operation completes successfully or encounters an error.
Since
100.3

◆ importDeltaWithGeodatabase:inputPath:completion:

- (id<AGSCancelable>) importDeltaWithGeodatabase: (AGSGeodatabase *)  geodatabase
inputPath: (NSString *)  inputPath
completion: (void(^)(NSArray< AGSSyncLayerResult * > *_Nullable result, NSError *_Nullable error))  completion 

Imports a geodatabase delta and applies it to the given geodatabase. This is useful in workflows where the client does not directly connect to the originating service to synchronize changes with the server (either because the client does not have access to the service, or to improve scalability where it is impractical for a large number of clients to depend upon the service). Rather, the changes from the sync-enabled service are made available as a delta file (*.gdb file) to all clients which then import them into their copy of the geodatabase.

A delta geodatabase contains the changes that have occurred since a mobile replica AGSGeodatabase was last synchronized with the feature service. See https://developers.arcgis.com/rest/services-reference/enterprise/synchronize-replica.htm for an overview of the delta files used in synchronization. A "download" delta geodatabase contains the online edits which will be imported to the local geodatabase.

The completion handler takes an array of AGSSyncLayerResult.

You should not execute more than one sync on a geodatabase at the same time. This includes operations that export or import deltas from the local AGSGeodatabase:

Parameters
geodatabaseThe geodatabase into which to import the delta.
inputPathThe path of the delta file (*.gdb file) containing the changes from the sync-enabled feature service.
completionA block that is invoked when the operation completes successfully or encounters an error.
Since
100
Deprecated:
100.3. Use class method importDeltaWithGeodatabase:deltaPath:completion: instead.

Provided by category AGSGeodatabaseSyncTask(AGSDeprecated).

◆ initWithURL:

- (instancetype) initWithURL: (NSURL *)  URL

Creates a task with a URL to a sync-enabled ArcGIS feature service.

Parameters
URLto a sync-enabled ArcGIS feature service.
Since
100

◆ loadDidFinishWithError:

- (void) loadDidFinishWithError: (nullable NSError *)  error

Only subclasses should call this method in doStartLoading: (AGSLoadableBase(ForSubclassEyesOnly)) and doCancelLoading (AGSLoadableBase(ForSubclassEyesOnly)) when done loading or failed to load.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ loadWithCompletion:

- (void) loadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Loads data for the object asynchronously. The completion block is invoked upon completion.

You can call this method any number of times, however only one attempt is made to load the data. If it is already loading, it will just continue to load (i.e. not force a reload). If it has already loaded successfully, the completion block will be invoked right away. If it has already failed to load, the completion block will be invoked right away with error previously encountered. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100
See also
- cancelLoad to cancel loading
- retryLoadWithCompletion: to force reload

◆ onLoadStatusChanged

- (void) onLoadStatusChanged

Never call this method directly. The framework calls this method on a background thread when AGSLoadable::loadStatus changes is called. Subclasses can optionally implement this to know when their loading status has changed.

Since
100

Provided by category AGSLoadableBase(ForSubclassEyesOnly).

◆ registerSyncEnabledGeodatabase:completion:

- (id<AGSCancelable>) registerSyncEnabledGeodatabase: (AGSGeodatabase *)  geodatabase
completion: (nullable void(^)(NSError *__nullable error))  completion 

Registers a copy of a sync enabled geodatabase with a service to allow the copy to sync changes.

This method is typically used as part of services pattern workflow, sometimes known as a pre-planned workflow. A sync enabled geodatabase is generated centrally and not modified or synced. Copies of this original geodatabase are distributed and loaded onto each user's device. The copy must first be registered with the service to allow the server to identify changes in subsequent sync operations. One of the main benefits of this workflow is a reduction in server load to generate geodatabases for many clients. It is important not to sync the copy before registering to ensure the server can maintain consistent state on each copy. This operation is not the opposite of unregisterGeodatabase:completion: which is used to remove a geodatabase from the service prior to deletion.

Parameters
geodatabaseThe sync-enabled geodatabase to register as a new replica with the originating service.
completionblock that is invoked when the operation completes successfully or encounters an error.
Returns
An operation that can be canceled.
Since
100

◆ retryLoadWithCompletion:

- (void) retryLoadWithCompletion: (nullable void(^)(NSError *__nullable error))  completion
requiredinherited

Tries to reload when an object has failed to load. This method should be called judiciously. It should be called when:

  1. you didn't have network connectivity earlier when it failed and you want to retry now that you have connectivity
  2. the server was down earlier when it failed and you want to retry
  3. the request is taking too long and you want to cancel it and retry, in which case you will first call cancelLoad and then this method

If the data hasn't started loading, it will start loading. If it is already loading, it will just continue to load. If it has already loaded successfully, calls back right away. If it has already failed to load, tries again. This method supports multiple callers and will call them all back on completion. However, each caller's completion block will be invoked once and only once.

Parameters
completionblock that is invoked when object loads successfully or fails to load. An error is passed to the block if the object fails to load.
Note
The completion block is always invoked on the main thread.
Since
100

◆ unregisterGeodatabase:completion:

- (id<AGSCancelable>) unregisterGeodatabase: (AGSGeodatabase *)  geodatabase
completion: (nullable void(^)(NSError *__nullable error))  completion 

Unregisters a geodatabase from a service removing the service's replica id.

After unregistering a geodatabase, it can no longer be synced back to the service. This is often used prior to deleting a local geodatabase. The local geodatabase will be left behind, but all information about the geodatabase on the service will be removed. This operation is not related to registerSyncEnabledGeodatabase:completion:, which is for registering copies of a sync enabled geodatabase.

Note
Once a sync-enabled geodatabase is unregistered, it cannot be re-registered with the service.
Parameters
geodatabaseto unregister.
completionblock that is invoked when the operation completes successfully or encounters an error.
Returns
An operation that can be canceled.
Since
100

◆ unregisterGeodatabaseWithSyncID:completion:

- (id<AGSCancelable>) unregisterGeodatabaseWithSyncID: (NSUUID *)  syncID
completion: (nullable void(^)(NSError *__nullable error))  completion 

Unregisters a geodatabase from a service removing the service's replica id. This overload uses the geodatabase's sync ID rather than a reference to the geodatabase itself.

This method is used to unregister a geodatabase from a service using the sync ID. This is commonly used to enable cleanup of the service after the local geodatabase has already been deleted. See AGSGeodatabase::syncID. After unregistering a geodatabase it can no longer be synced back to the service. This operation is not related to registerSyncEnabledGeodatabase:completion:, which is for registering copies of a sync enabled geodatabase.

Note
Once a sync-enabled geodatabase is unregistered, it cannot be re-registered with the service.
Parameters
syncIDof the geodatabase to unregister.
completionblock that is invoked when the operation completes successfully or encounters an error.
Returns
An operation that can be canceled.
Since
100.2

Property Documentation

◆ APIKey

- (NSString*) APIKey
readwriterequirednonatomiccopyinherited

The API key to access API key enabled services and resources in ArcGIS Online.

An API key is a unique key used to authorize access to specific services and resources in ArcGIS Online. It is also used to monitor access to those services. An API key is created and managed in the ArcGIS developer dashboard and is tied to a specific ArcGIS account.

In addition to setting an API key at a global level for your application using the AGSArcGISRuntimeEnvironment::APIKey property, you can set an AGSAPIKeyResource::APIKey property on any ArcGIS Runtime class that implements AGSAPIKeyResource. When you set an individual AGSAPIKeyResource::APIKey property on an AGSAPIKeyResource it will override the default key at the global level (on the AGSArcGISRuntimeEnvironment::APIKey property, in other words), enabling more granular usage telemetry and management for ArcGIS Online resources used by your app. Classes that expose an API key property by implementing AGSAPIKeyResource include:

◆ credential

- (AGSCredential*) credential
readwritenonatomicstronginherited

Security credentials to access the remote resource. Only applicable if the resource is secured.

Since
100

◆ featureServiceInfo

- (AGSArcGISFeatureServiceInfo*) featureServiceInfo
readnonatomicstrong

Metadata about the ArcGIS feature service that the task is using.

Since
100

◆ loadError

- (NSError*) loadError
readnonatomicstronginherited

The error that was encountered during the most recent load operation. Will be nil if the operation succeeded.

Since
100

◆ loadStatus

- (AGSLoadStatus) loadStatus
readrequirednonatomicassigninherited

Status of the load operation.

Since
100

◆ requestConfiguration

- (AGSRequestConfiguration*) requestConfiguration
readwritenonatomicstronginherited

The AGSRequestConfiguration object which defines the behavior and policies to use when accessing the remote resource. The default will be nil. If it is nil the [AGSRequestConfiguration globalConfiguration] will be used.

Since
100

◆ URL

- (NSURL*) URL
readrequirednonatomicstronginherited

The URL of the remote resource.

Since
100