ZeroDarkCloud

@interface ZeroDarkCloud : NSObject

This class is the primary interface for interacting with the ZeroDark.cloud framework.

  • Initializes an instance for use within your app.

    Typically you only need a single instance per app. Once instance is capable of supporting multiple users.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithDelegate:(nonnull id)delegate config:(id)config;

    Swift

    init(delegate: ZeroDarkCloudDelegate, config: ZDCConfig)

    Parameters

    delegate

    A delegate is required to support push & pull operations.

    config

    The configuration to use when setting up ZDC. A typical configuration consists of a single treeID (e.g. com.myCompany.myApp).

  • The delegate specified during initialization

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic) id _Nonnull delegate;

    Swift

    var delegate: ZeroDarkCloudDelegate { get set }
  • The databasePath specified during initialization. This information was used to create a YapDatabase instance. More information about the database can be found via the databaseManager property.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) NSURL *_Nonnull databasePath;

    Swift

    var databasePath: URL { get }
  • The primary treeID for this application. This is the name you registered within the ZeroDark.cloud developer dashboard. It’s generally of the form com.companyName.appName.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull primaryTreeID;

    Swift

    var primaryTreeID: String { get }
  • A reference to AFNetworkReachabilityManager.sharedManager.

    The framework automatically calls startMonitoring on this instance, as it needs internet reachability & notifications of reachability changes.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) AFNetworkReachabilityManager *reachability

    Swift

    var reachability: UnsafeMutablePointer<Int32> { get }
  • The ZeroDarkCloud framework stores data on the local device in a database. For security purposes, it requires this database to be encrypted. This is accomplished using a local sqlite database which is encrypted using SQLCipher. In order to start using the framework, this database file must first be unlocked (or created). This property returns whether or not the database file has been unlocked yet (or created).

    Note: The framework comes with a suite a tools for securely storing/retrieving a database key. For example, adding TouchID only takes a few lines of code.

    See

    DatabaseKeyManager

    Declaration

    Objective-C

    @property (readonly, atomic) BOOL isDatabaseUnlocked;

    Swift

    var isDatabaseUnlocked: Bool { get }
  • Attempts to unlock the database file using the given key. If the key matches, the unlock will succeed.

    See

    DatabaseKeyManager

    Declaration

    Objective-C

    - (BOOL)unlockOrCreateDatabase:(id)config
                             error:(NSError *_Nullable *_Nullable)outError;

    Swift

    func unlockOrCreateDatabase(_ config: ZDCDatabaseConfig) throws

    Return Value

    Returns true on success. Otherwise returns false, and sets outError.

  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task.

    Declaration

    Objective-C

    @property (readonly, nonatomic) int *_Nonnull cloudPathManager;

    Swift

    var cloudPathManager: ZDCCloudPathManager { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task.

    Declaration

    Objective-C

    @property (readonly, nonatomic) int *_Nonnull databaseKeyManager;

    Swift

    var databaseKeyManager: ZDCDatabaseKeyManager { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task.

    Declaration

    Objective-C

    @property (readonly, nonatomic) int *_Nonnull directoryManager;

    Swift

    var directoryManager: ZDCDirectoryManager { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task.

    Declaration

    Objective-C

    @property (readonly, nonatomic) int *_Nonnull nodeManager;

    Swift

    var nodeManager: ZDCNodeManager { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task.

    Declaration

    Objective-C

    @property (readonly, nonatomic) int *_Nonnull progressManager;

    Swift

    var progressManager: ZDCProgressManager { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *databaseManager;

    Swift

    var databaseManager: ZDCDatabaseManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *diskManager;

    Swift

    var diskManager: ZDCDiskManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *downloadManager;

    Swift

    var downloadManager: ZDCDownloadManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *imageManager;

    Swift

    var imageManager: ZDCImageManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *localUserManager;

    Swift

    var localUserManager: ZDCLocalUserManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *pullManager;

    Swift

    var pullManager: ZDCPullManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *pushManager;

    Swift

    var pushManager: ZDCPushManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *restManager;

    Swift

    var restManager: ZDCRestManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *searchManager;

    Swift

    var searchManager: ZDCUserSearchManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *syncManager;

    Swift

    var syncManager: ZDCSyncManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *userManager;

    Swift

    var userManager: ZDCUserManager? { get }
  • The functionality of ZeroDarkCloud is split into multiple managers, separated by task. Once the database is unlocked, this returns non-nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) int *uiTools;

    Swift

    var uiTools: ZDCUITools? { get }
  • Convenient way to get a reference to the ZDCCloudTransaction for the given localUserID.

    Note

    localUserID == ZDCLocalUser.uuid

    Declaration

    Objective-C

    - (id)cloudTransaction:(id)transaction
            forLocalUserID:(nonnull NSString *)localUserID;

    Swift

    func cloudTransaction(_ transaction: Any!, forLocalUserID localUserID: String) -> ZDCCloudTransaction?
  • Convenient way to get a reference to the ZDCCloudTransaction for the given {localUserID, treeID} tuple.

    Note

    localUserID == ZDCLocalUser.uuid

    Declaration

    Objective-C

    - (id)cloudTransaction:(id)transaction
            forLocalUserID:(nonnull NSString *)localUserID
                    treeID:(nullable NSString *)treeID;

    Swift

    func cloudTransaction(_ transaction: Any!, forLocalUserID localUserID: String, treeID: String?) -> ZDCCloudTransaction?
  • The (parsed) pushToken that gets registered with the server.

    See

    didRegisterForRemoteNotificationsWithDeviceToken:

    Declaration

    Objective-C

    @property (readonly, strong, atomic, nullable) NSString *pushToken;

    Swift

    var pushToken: String? { get }
  • The ZeroDark.cloud framework relies on push notifications for real-time updates. After registering for push notifications with the OS, invoke this method to inform the framework of the device’s push token.

    The framework will automatically register the push token with the server for all ZDCLocalUser’s in the database.

    Declaration

    Objective-C

    - (void)didRegisterForRemoteNotificationsWithDeviceToken:
        (nonnull NSData *)deviceToken;

    Swift

    func didRegisterForRemoteNotifications(withDeviceToken deviceToken: Data)
  • (iOS Version)

    When you receive a push notification, forward it to the ZeroDarkCloud framework using this method. If the notification is from the ZeroDark servers, this method will kick off the process of handling the notification, and return YES. When the notification has been fully handled, the framework will invoke the completionHandler automatically.

    If the notification isn’t from the ZeroDark servers, this method returns NO. Which means the notification (and invoking the completionHandler) is your responsibility.

    Declaration

    Objective-C

    - (BOOL)didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
                  fetchCompletionHandler:(nonnull void (^)(int))completionHandler;

    Swift

    func didReceiveRemoteNotification(_ userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) -> Bool

    Parameters

    userInfo

    The notification you received via the AppDelegate method.

    completionHandler

    The completionHandler you received via the AppDelegate method.

    Return Value

    YES if the ZDC framework will handle the notification & completionHandler. NO if the notification isn’t from the ZeroDark servers.

  • When your AppDelegate receives this notification, forward it to the ZeroDarkCloud framework using this method.

    If the session is managed by the ZDC framework, this method will kick off the process of handling the event(s), and then return YES. When the notification has been fully handled, the framework will invoke the completionHandler automatically.

    If the session isn’t managed by the ZDC framework, this method returns NO. Which means the events are your responsibility.

    Declaration

    Objective-C

    - (BOOL)handleEventsForBackgroundURLSession:
                (nonnull NSString *)sessionIdentifier
                              completionHandler:
                                  (nonnull void (^)(void))completionHandler;

    Swift

    func handleEvents(forBackgroundURLSession sessionIdentifier: String, completionHandler: @escaping () -> Void) -> Bool

    Parameters

    sessionIdentifier

    The session identifier, as delivered to your AppDelegate.

    completionHandler

    The completionHandler, as delivered to your AppDelegate.

    Return Value

    YES if the ZDC framework will handle the event(s) & completionHandler. NO if the session isn’t maanaged by the ZDC framework.

  • Utility method to returns the bundle for the ZeroDarkCloud framework.

    Declaration

    Objective-C

    + (nonnull NSBundle *)frameworkBundle;

    Swift

    class func frameworkBundle() -> Bundle
  • Allows you to configure a handler for log messages emitted from the framework.

    A custom log handler allows you to integrate framework-emitted log messages into your desired logging system.

    If you don’t configure your own log handler, then a default handler is used, which:

    • only logs errors & warnings
    • uses os_log

    Declaration

    Objective-C

    + (void)setLogHandler:(nonnull void (^)(int *_Nonnull))logHandler;

    Swift

    class func setLogHandler(_ logHandler: @escaping (ZDCLogMessage) -> Void)