RLMSyncSession
@interface RLMSyncSession : NSObject
An object encapsulating a Realm Object Server session
. Sessions represent the
communication between the client (and a local Realm file on disk), and the server
(and a remote Realm at a given URL stored on a Realm Object Server).
Sessions are always created by the SDK and vended out through various APIs. The lifespans of sessions associated with Realms are managed automatically. Session objects can be accessed from any thread.
-
The session’s current state.
Declaration
Objective-C
@property (readonly, nonatomic) RLMSyncSessionState state;
Swift
var state: RLMSyncSessionState { get }
-
The Realm Object Server URL of the remote Realm this session corresponds to.
Declaration
Objective-C
@property (readonly, nonatomic, nullable) NSURL *realmURL;
Swift
var realmURL: URL? { get }
-
The user that owns this session.
Declaration
Objective-C
- (nullable RLMSyncUser *)parentUser;
Swift
func parentUser() -> RLMSyncUser?
-
If the session is valid, return a sync configuration that can be used to open the Realm associated with this session.
Declaration
Objective-C
- (nullable RLMSyncConfiguration *)configuration;
Swift
func configuration() -> RLMSyncConfiguration?
-
Register a progress notification block.
Multiple blocks can be registered with the same session at once. Each block will be invoked on a side queue devoted to progress notifications.
If the session has already received progress information from the synchronization subsystem, the block will be called immediately. Otherwise, it will be called as soon as progress information becomes available.
The token returned by this method must be retained as long as progress notifications are desired, and the
-stop
method should be called on it when notifications are no longer needed and before the token is destroyed.If no token is returned, the notification block will never be called again. There are a number of reasons this might be true. If the session has previously experienced a fatal error it will not accept progress notification blocks. If the block was configured in the
RLMSyncProgressForCurrentlyOutstandingWork
mode but there is no additional progress to report (for example, the number of transferrable bytes and transferred bytes are equal), the block will not be called again.Declaration
Objective-C
- (nullable RLMProgressNotificationToken *) addProgressNotificationForDirection:(RLMSyncProgressDirection)direction mode:(RLMSyncProgress)mode block:(nonnull RLMProgressNotificationBlock)block;
Swift
func __addProgressNotification(for direction: RLMSyncProgressDirection, mode: RLMSyncProgress, block: @escaping RLMProgressNotificationBlock) -> RLMProgressNotificationToken?
Parameters
direction
The transfer direction (upload or download) to track in this progress notification block.
mode
The desired behavior of this progress notification block.
block
The block to invoke when notifications are available.
Return Value
A token which must be held for as long as you want notifications to be delivered.