ZDCSyncManager

@interface ZDCSyncManager : NSObject

The SyncManager simplifies many aspects of determining sync state.

In particular, it can tell you:

  • whether or not the framework is syncing data (pushing or pulling)
  • which nodes are being synced

The framework can run on autopilot most of the time. But this class gives you fine grained controls. For example, you can pause the push queue for a particular user so changes aren’t uploaded.

  • This method is typically only used on the iOS simulator, which doesn’t support push notifications. So for testing & debugging on the simulator, you may wish to add a manual pull button that calls this method.

    Under normal operating conditions however, there’s little reason to use this method. Your application should be receiving push notifications when changes occur in the cloud that affect the user. And the push notifications will trigger the pull system correctly.

    Further, the LocalUserManager performs a poll on the server every so often (in the absence of push notifications) to ensure it’s up-to-date.

    Declaration

    Objective-C

    - (void)pullChangesForLocalUserID:(nonnull NSString *)localUserID;

    Swift

    func pullChanges(forLocalUserID localUserID: String)
  • This method is typically only used on the iOS simulator, which doesn’t support push notifications. So for testing & debugging on the simulator, you may wish to add a manual pull button that calls this method.

    Under normal operating conditions however, there’s little reason to use this method. Your application should be receive push notifications when changes occur in the cloud that affect the user. And the push notifications will trigger the pull system correctly.

    Further, the LocalUserManager performs a poll on the server every so often (in the absence of push notifications) to ensure it’s up-to-date.

    Declaration

    Objective-C

    - (void)pullChangesForAllLocalUsers;

    Swift

    func pullChangesForAllLocalUsers()
  • Allows you to pause the push system. That is, to pause the upload operation queue for the given user.

    This will only pause the push/upload system. Pulls & downloads are separate, and may continue while the push system is paused.

    Declaration

    Objective-C

    - (void)pausePushForLocalUserID:(nonnull NSString *)localUserID
                    andAbortUploads:(BOOL)shouldAbortUploads;

    Swift

    func pausePush(forLocalUserID localUserID: String, andAbortUploads shouldAbortUploads: Bool)

    Parameters

    localUserID

    The user for which you wish to pause push/uploads. (localUserID == ZDCLocalUser.uuid)

    shouldAbortUploads

    Whether or not you wish to cancal active/in-flight uploads. If yes, any corresponding uploads will be cancelled. Otherwise, in-flight uploads will continue until the task finishes (either success or failure), but new uploads won’t be started until you resume the push system.

  • Allows you to pause the push system. That is, to pause the upload operation queue.

    This will only pause the push/upload system. Pulls & downloads are separate, and may continue while the push system is paused.

    Declaration

    Objective-C

    - (void)pausePushForAllLocalUsersAndAbortUploads:(BOOL)shouldAbortUploads;

    Swift

    func pausePush(forAllLocalUsersAndAbortUploads shouldAbortUploads: Bool)

    Parameters

    shouldAbortUploads

    Whether or not you wish to cancal active/in-flight uploads. If yes, any corresponding uploads will be cancelled. Otherwise, in-flight uploads will continue until the task finishes (either success or failure), but new uploads won’t be started until you resume the push system.

    • Resumes the push system if it’s currently paused.
    • If the user has Internet reachability, the upload operation queue will resume immediately. *
    • The user for which you wish to resume push/uploads. (localUserID == ZDCLocalUser.uuid)

    Declaration

    Objective-C

    - (void)resumePushForLocalUserID:(nonnull NSString *)localUserID;

    Swift

    func resumePush(forLocalUserID localUserID: String)

    Parameters

    localUserID

  • Resumes all push systems. If the user has Internet reachability, the upload operation queue will resume immediately.

    Declaration

    Objective-C

    - (void)resumePushForAllLocalUsers;

    Swift

    func resumePushForAllLocalUsers()
  • Returns true if push is paused for the localUser.

    That is, if you’ve manually called either pausePushForLocalUserID:: or pausePushForAllLocalUsersAndAbortUploads.

    Declaration

    Objective-C

    - (BOOL)isPushingPausedForLocalUserID:(nonnull NSString *)localUserID;

    Swift

    func isPushingPaused(forLocalUserID localUserID: String) -> Bool
  • Returns true if push is paused for every single localUser

    Declaration

    Objective-C

    - (BOOL)isPushingPausedForAllUsers;

    Swift

    func isPushingPausedForAllUsers() -> Bool
  • Returns true if push is paused for any localUser

    Declaration

    Objective-C

    - (BOOL)isPushingPausedForAnyUser;

    Swift

    func isPushingPausedForAnyUser() -> Bool
  • This method can be used to discover if a pull is currently in progress for the given user.

    It’s important to understand what a pull means within the context of the ZeroDark.cloud framework, as its meaning may differ from the perspective of your application. The ZeroDark.cloud framework automatically updates the local cache of the treesystem hierarchy to match that of the cloud. This tree heirarchy that it maintains is separate from the node data. For example, if it discovers that new nodes have been added to the cloud, it automatically downloads the tree information (node name, position within tree, permsissions, etc), but not the underlying node data (the data that your application generates).

    So if a pull is active this means the PullManager has discovered:

    • one or more nodes that have been added, modified or deleted from the cloud
    • and the PullManager is actively working to update the local tree heirarchy to match the cloud

    Now, the perspective of your application may be a little different. For example, if a node is discovered with name some-random-uuid, this doesn’t tell you much. And more than likely, your application will choose to immedately request a download of this node. So your application will likely have a slightly different perspective, for example you may animate some UI component for your user if:

    • this method says it’s updating the tree
    • OR the download manager says it’s downloading stuff for the localUserID

    The following notifications can be used to determine when this state changes:

    • ZDCPullStartedNotification
    • ZDCPullStoppedNotification

    Declaration

    Objective-C

    - (BOOL)isPullingChangesForLocalUserID:(nonnull NSString *)localUserID;

    Swift

    func isPullingChanges(forLocalUserID localUserID: String) -> Bool
  • This method can be used to discover is a push is currently in progress for the given user.

    The following notifications can be used to determine when this state changes:

    • ZDCPushStartedNotification
    • ZDCPushStoppedNotification

    Declaration

    Objective-C

    - (BOOL)isPushingChangesForLocalUserID:(nonnull NSString *)localUserID;

    Swift

    func isPushingChanges(forLocalUserID localUserID: String) -> Bool
  • Helpful for checking general sync activity.

    Declaration

    Objective-C

    - (BOOL)isPullingOrPushingChangesForLocalUserID:(nonnull NSString *)localUserID;

    Swift

    func isPullingOrPushingChanges(forLocalUserID localUserID: String) -> Bool
  • Helpful for checking general sync activity.

    Declaration

    Objective-C

    - (BOOL)isPullingOrPushingChangesForAnyLocalUser;

    Swift

    func isPullingOrPushingChangesForAnyLocalUser() -> Bool
    • - The node is being pushed to the server, or scheduled to be pushed.
    • - The node has children, and there’s a descendant (at any depth - child, grandchild, etc)
    • that’s being pushed to the server (or scheduled to be pushed).
    • - The node has changes in the cloud, and we’re pulling the changes to it.
    • - The node has children, and there’s a descendant (at any depth - child, grandchild, etc)
    • for which we’re pulling changes for.
    • - There’s an active dowload for the given nodeID (which was requested via DownloadManager). *
    • This list is updated automatically as the sync system operates in the background.
    • The following notification can be used to determine when this state changes:
    • - ZDCSyncingNodeIDsChangedNotification *
    • - note: The functionality of this method may not perfectly match your application’s requirements.
    • But it’s usually a helpful starting point from which you can copy code into your own app,
    • and then make changes to better suite your needs.

    Declaration

    Objective-C

    - (nonnull NSSet<NSString *> *)syncingNodeIDsForLocalUserID:
        (nonnull NSString *)localUserID;

    Swift

    func syncingNodeIDs(forLocalUserID localUserID: String) -> Set<String>