RLMSyncUser
@interface RLMSyncUser : NSObject
A RLMSyncUser
instance represents a single Realm Object Server user account.
A user may have one or more credentials associated with it. These credentials uniquely identify the user to the authentication provider, and are used to sign into a Realm Object Server user account.
Note that user objects are only vended out via SDK APIs, and cannot be directly initialized. User objects can be accessed from any thread.
-
A dictionary of all valid, logged-in user identities corresponding to their user objects.
Declaration
Objective-C
+ (nonnull NSDictionary<NSString *, RLMSyncUser *> *)allUsers;
Swift
class func __allUsers() -> [String : RLMSyncUser]
-
The logged-in user.
nil
if none exists.Warning
Throws an exception if more than one logged-in user exists.Declaration
Objective-C
+ (nullable RLMSyncUser *)currentUser;
Swift
class func __current() -> RLMSyncUser?
-
The unique Realm Object Server user ID string identifying this user.
Declaration
Objective-C
@property (readonly, nonatomic, nullable) NSString *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 }
-
Whether the user is a Realm Object Server administrator. Value reflects the state at the time of the last successful login of this user.
Declaration
Objective-C
@property (readonly, nonatomic) BOOL isAdmin;
Swift
var isAdmin: Bool { 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. Credentials 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)logInWithCredentials:(nonnull RLMSyncCredentials *)credentials authServerURL:(nonnull NSURL *)authServerURL timeout:(NSTimeInterval)timeout onCompletion:(nonnull RLMUserCompletionBlock)completion;
Swift
class func __logIn(with credentials: RLMSyncCredentials, authServerURL: URL, timeout: TimeInterval, onCompletion completion: @escaping RLMUserCompletionBlock)
-
Create, log in, and asynchronously return a new user object. Credentials 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)logInWithCredentials:(nonnull RLMSyncCredentials *)credentials authServerURL:(nonnull NSURL *)authServerURL onCompletion:(nonnull RLMUserCompletionBlock)completion;
-
Log a user out, destroying their server state, unregistering 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 method does nothing.
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]
-
Returns an instance of the Management Realm owned by the user.
This Realm can be used to control access permissions for Realms managed by the user. This includes granting other users access to Realms.
-
Returns an instance of the Permission Realm owned by the user.
This read-only Realm contains
RLMSyncPermission
objects reflecting the synchronized Realms and permission details this user has access to.