RLMSyncUser

@interface RLMSyncUser : NSObject

A RLMSyncUser instance represents a single Realm Object Server user account (or just user).

A user may have one or more credentials associated with it. These credentials uniquely identify the user to a third-party auth provider, and are used to sign into a Realm Object Server user account.

Note that users are only vended out via SDK APIs, and only one user instance ever exists for a given user account.

  • An array of all valid, logged-in users.

    Declaration

    Objective-C

    + (nonnull NSArray<RLMSyncUser *> *)all;

    Swift

    class func all() -> [RLMSyncUser]
  • The unique Realm Object Server user ID string identifying this user.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSString *_Nonnull identity;

    Swift

    var identity: String { get }
  • The URL of the authentication server this user will communicate with.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSURL *authenticationServer;

    Swift

    var authenticationServer: URL? { get }
  • The current state of the user.

    Declaration

    Objective-C

    @property (readonly, nonatomic) RLMSyncUserState state;

    Swift

    var state: RLMSyncUserState { get }
  • Create, log in, and asynchronously return a new user object, specifying a custom timeout for the network request. A credential identifying the user must be passed in. The user becomes available in the completion block, at which point it is ready for use.

    Declaration

    Objective-C

    + (void)authenticateWithCredential:(nonnull RLMSyncCredential *)credential
                         authServerURL:(nonnull NSURL *)authServerURL
                               timeout:(NSTimeInterval)timeout
                          onCompletion:(nonnull RLMUserCompletionBlock)completion;

    Swift

    class func __authenticate(with credential: RLMSyncCredential, authServerURL: URL, timeout: TimeInterval, onCompletion completion: @escaping RLMUserCompletionBlock)
  • Create, log in, and asynchronously return a new user object. A credential identifying the user must be passed in. The user becomes available in the completion block, at which point it is ready for use.

    Declaration

    Objective-C

    + (void)authenticateWithCredential:(nonnull RLMSyncCredential *)credential
                         authServerURL:(nonnull NSURL *)authServerURL
                          onCompletion:(nonnull RLMUserCompletionBlock)completion;
  • Log a user out, destroying their server state, deregistering them from the SDK, and removing any synced Realms associated with them from on-disk storage. If the user is already logged out or in an error state, this is a no-op.

    This method should be called whenever the application is committed to not using a user again unless they are recreated. Failing to call this method may result in unused files and metadata needlessly taking up space.

    Declaration

    Objective-C

    - (void)logOut;

    Swift

    func logOut()
  • Retrieve a valid session object belonging to this user for a given URL, or nil if no such object exists.

    Declaration

    Objective-C

    - (nullable RLMSyncSession *)sessionForURL:(nonnull NSURL *)url;

    Swift

    func session(for url: URL) -> RLMSyncSession?
  • Retrieve all the valid sessions belonging to this user.

    Declaration

    Objective-C

    - (nonnull NSArray<RLMSyncSession *> *)allSessions;

    Swift

    func allSessions() -> [RLMSyncSession]