AGSGeodatabaseSyncTask: unregisterGeodatabase methods are not working

804
3
Jump to solution
08-28-2023 09:57 PM
ShiminCai
Occasional Contributor III

Hi there,

In our app we are trying to clean up the replica registry on our ArcGIS Servers whenever a downloaded offline geodatabase is deleted or overwritten by a new one.

We are using the methods unregisterGeodatabase(_ : AGSGeodatabase, completion: ((Error?) -> Void)) and unregisterGeodatabase(withSyncID: UUID, completion: ((Error?) -> Void)on AGSGeodatabaseSyncTask to unregister the replicas. We found both methods are not working and the completion closures are never invoked.

Here are the steps we are using the methods:

1. Create an instance (agsGdbSyncTask) of AGSGeodatabaseSyncTask with the feature service URL.

2. Set the agsGdbSyncTask.credential as our services are secured.

3. Load the task: agsGdbSyncTask.load() { error in ...}. The load completion closure is invoked and the error is nil.

4. Run the above unregister methods in the completion closure of the agsGdbSyncTask.load() 

5. Found both unregister methonds do not work and their completion closures are never called.

 

I'm using Xcode 14.3 and ArcGIS Runtime SDK for iOS 100.15.2. Has anybody come across this or got any idea please?

 

Thanks,

Shimin

 

0 Kudos
1 Solution

Accepted Solutions
Ting
by Esri Contributor
Esri Contributor

Hi, I'd like to know a bit more info before I create a repro case. Can you confirm that you hold the agsGdbSyncTask as an instance property while the unregister method is called?

AGSGeodatabaseSyncTask, as a subclass to the AGSLoadableRemoteResourceBase, needs to have at least 1 reference being held by another type, so it doesn't get deallocated while the syncing is happening in the background. The simplest way is to hold it as an instance property, as shown in this sample.

View solution in original post

3 Replies
Ting
by Esri Contributor
Esri Contributor

Hi, I'd like to know a bit more info before I create a repro case. Can you confirm that you hold the agsGdbSyncTask as an instance property while the unregister method is called?

AGSGeodatabaseSyncTask, as a subclass to the AGSLoadableRemoteResourceBase, needs to have at least 1 reference being held by another type, so it doesn't get deallocated while the syncing is happening in the background. The simplest way is to hold it as an instance property, as shown in this sample.

natefunk406
New Contributor

This saved me so much time, thank you!

ShiminCai
Occasional Contributor III

Thanks @Ting. Once the reference is held by a type outside of the sync scope, both unregister methods are working and the completion closures are called. Thank you so much for your help Ting. Cheers, Shimin  

0 Kudos