ZDCUserManager

@interface ZDCUserManager : NSObject

The UserManager handles various tasks involving ZDCUser’s.

Note

There is also a LocalUserManager, which handles various tasks specific to ZDCLocalUser’s.
  • Fetches the ZDCUser from the database. If missing, automatically downloads the user.

    The download involves the following steps:

    • Fetching the user’s general information (region & bucket)
    • Fetching the user’s linked identities

    Declaration

    Objective-C

    - (void)fetchUserWithID:(nonnull NSString *)remoteUserID
                requesterID:(nonnull NSString *)localUserID
            completionQueue:(nullable dispatch_queue_t)completionQueue
            completionBlock:(nullable void (^)(ZDCUser *_Nullable,
                                               NSError *_Nullable))completionBlock;

    Swift

    func fetchUser(withID remoteUserID: String, requesterID localUserID: String, completionQueue: DispatchQueue?, completionBlock: ((ZDCUser?, Error?) -> Void)? = nil)

    Parameters

    remoteUserID

    The userID of the user to fetch.

    localUserID

    The localUserID who’s making the request. The network requests need to come from a localUser, as they need to be authenticated.

    completionQueue

    The dispatch_queue on which to invoke the completionBlock. If nil, the main thread will automatically be used.

    completionBlock

    The block to invoke when the request is completed.

  • In some situations, a user’s public key may be missing.

    In general, the framework handles this aspect for you automatically. That is, if the framework needs the user’s publicKey, it will fetch it automatically. However, you can use this method to fetch it manually as needed.

    The download involves the following steps:

    • Fetching the user’s public key
    • Checking the user’s public key against the blockchain

    Declaration

    Objective-C

    - (void)fetchPublicKey:(nonnull ZDCUser *)remoteUser
               requesterID:(nonnull NSString *)localUserID
           completionQueue:(nullable dispatch_queue_t)completionQueue
           completionBlock:(nullable void (^)(ZDCUser *_Nullable,
                                              NSError *_Nullable))completionBlock;

    Swift

    func fetchPublicKey(_ remoteUser: ZDCUser, requesterID localUserID: String, completionQueue: DispatchQueue?, completionBlock: ((ZDCUser?, Error?) -> Void)? = nil)
  • Refreshes the user’s list of linked identities.

    Declaration

    Objective-C

    - (void)refreshIdentities:(nonnull ZDCUser *)user
                  requesterID:(nonnull NSString *)localUserID
              completionQueue:(nullable dispatch_queue_t)completionQueue
              completionBlock:
                  (nullable void (^)(ZDCUser *_Nullable,
                                     NSError *_Nullable))completionBlock;

    Swift

    func refreshIdentities(_ user: ZDCUser, requesterID localUserID: String, completionQueue: DispatchQueue?, completionBlock: ((ZDCUser?, Error?) -> Void)? = nil)
  • Checks the blockchain for proof of the user’s publicKey.

    If the blockchain contains a proof for this user, the system performs the calculations to verify the validity of the locally stored publicKey.

    Declaration

    Objective-C

    - (void)checkBlockchain:(nonnull ZDCUser *)user
            completionQueue:(nullable dispatch_queue_t)completionQueue
            completionBlock:(nullable void (^)(ZDCUser *_Nullable,
                                               NSError *_Nullable))completionBlock;

    Swift

    func checkBlockchain(_ user: ZDCUser, completionQueue: DispatchQueue?, completionBlock: ((ZDCUser?, Error?) -> Void)? = nil)
  • Given an array of ZDCUser’s, this will produce an array of unambiguous displayNames.

    For example, if there are 2 users with the displayName of Vinnie Moscaritolo, then this method will attempt to disambiguate them by appending information to the displayName.

     [
       {
         displayName = "Vinnie Moscaritolo (Amazon)";
         userID = 641ihdfw7qf5pj78pfxbunwkkwonu5rg;
       },
       {
         displayName = "Vinnie Moscaritolo (Facebook)";
         userID = 7gzeud1d9iam5b1d31j8sk6pnnktosut;
       }
     ]
    

    Declaration

    Objective-C

    - (nonnull NSArray<ZDCUserDisplay *> *)sortedUnambiguousNamesForUsers:
        (nonnull NSArray<ZDCUser *> *)users;

    Swift

    func sortedUnambiguousNames(for users: [ZDCUser]) -> [ZDCUserDisplay]