User
-
Links the currently authenticated user with a new identity, where the identity is defined by the credential specified as a parameter. This will only be successful if this
Useris the currently authenticated with the client from which it was created. On success a new user will be returned with the new linked credentials. @param credentials TheCredentialsused to link the user to a new identity. @completion A completion that eventually returnResult.success(User)with user’s data orResult.failure(Error).Declaration
Swift
@preconcurrency func linkUser(credentials: Credentials, _ completion: @Sendable @escaping (Result<User, Error>) -> Void) -
Links the currently authenticated user with a new identity, where the identity is defined by the credential specified as a parameter. This will only be successful if this
Useris the currently authenticated with the client from which it was created. On success a new user will be returned with the new linked credentials. @param credentials TheCredentialsused to link the user to a new identity. @returns A publisher that eventually returnResult.successorError.Declaration
Swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) func linkUser(credentials: Credentials) -> Future<User, Error> -
linkUser(credentials:Asynchronous) Links the currently authenticated user with a new identity, where the identity is defined by the credential specified as a parameter. This will only be successful if this
Useris the currently authenticated with the client from which it was created. On success a new user will be returned with the new linked credentials.Declaration
Swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) func linkUser(credentials: Credentials) async throws -> UserParameters
credentialsThe
Credentialsused to link the user to a new identity.Return Value
A
Userafter successfully update its identity. -
Create a sync configuration instance.
Declaration
Swift
@preconcurrency func configuration<T: BSON>(partitionValue: T, clientResetMode: ClientResetMode = .recoverUnsyncedChanges(beforeReset: nil, afterReset: nil), cancelAsyncOpenOnNonFatalErrors: Bool = false) -> Realm.ConfigurationParameters
partitionValueThe
BSONvalue the Realm is partitioned on.clientResetModeDetermines file recovery behavior during a client reset.
.recoverUnsyncedChangesby default.cancelAsyncOpenOnNonFatalErrorsBy default, Realm.asyncOpen() swallows non-fatal connection errors such as a connection attempt timing out and simply retries until it succeeds. If this is set to
true, instead the error will be reported to the callback and the async open will be cancelled. -
Create a sync configuration instance.
Declaration
Swift
@preconcurrency func configuration(partitionValue: AnyBSON, clientResetMode: ClientResetMode = .recoverUnsyncedChanges(beforeReset: nil, afterReset: nil), cancelAsyncOpenOnNonFatalErrors: Bool = false) -> Realm.ConfigurationParameters
partitionValueTakes
nilas a partition value.clientResetModeDetermines file recovery behavior during a client reset.
.recoverUnsyncedChangesby default.cancelAsyncOpenOnNonFatalErrorsBy default, Realm.asyncOpen() swallows non-fatal connection errors such as a connection attempt timing out and simply retries until it succeeds. If this is set to
true, instead the error will be reported to the callback and the async open will be cancelled. -
The custom data of the user. This is configured in your Atlas App Services app.
Declaration
Swift
var customData: Document { get } -
A client for interacting with a remote MongoDB instance
Declaration
Swift
func mongoClient(_ serviceName: String) -> MongoClientParameters
serviceNameThe name of the MongoDB service
Return Value
A
MongoClientwhich is used for interacting with a remote MongoDB service -
Call an Atlas App Services function with the provided name and arguments.
user.functions.sum([1, 2, 3, 4, 5]) { sum, error in guard case let .int64(value) = sum else { print(error?.localizedDescription) } assert(value == 15) }The dynamic member name (
sumin the above example) is directly associated with the function name. The first argument is theBSONArrayof arguments to be provided to the function. The second and final argument is the completion handler to call when the function call is complete. This handler is executed on a non-main globalDispatchQueue.Declaration
Swift
var functions: Functions { get } -
Refresh a user’s custom data. This will, in effect, refresh the user’s auth session. @returns A publisher that eventually return
Dictionarywith user’s data orError.Declaration
Swift
func refreshCustomData() -> Future<[AnyHashable : Any], Error> -
Removes the user This logs out and destroys the session related to this user. The completion block will return an error if the user is not found or is already removed. @returns A publisher that eventually return
Result.successorError.Declaration
Swift
func remove() -> Future<Void, Error> -
Logs out the current user The users state will be set to
Removedis they are an anonymous user orLoggedOutif they are authenticated by a username / password or third party auth clients / If the logout request fails, this method will still clear local authentication state. @returns A publisher that eventually returnResult.successorError.Declaration
Swift
func logOut() -> Future<Void, Error> -
Permanently deletes this user from your Atlas App Services app. The users state will be set to
Removedand the session will be destroyed. If the delete request fails, the local authentication state will be untouched. @returns A publisher that eventually returnResult.successorError.Declaration
Swift
func delete() -> Future<Void, Error> -
A publisher that emits Void each time the user changes.
Despite the name, this actually emits after the user has changed.
Declaration
Swift
public var objectWillChange: AnyPublisher<UserPublisher.Output, UserPublisher.Failure> { get } -
Refresh a user’s custom data. This will, in effect, refresh the user’s auth session. @completion A completion that eventually return
Result.success(Dictionary)with user’s data orResult.failure(Error).Declaration
Swift
@preconcurrency func refreshCustomData(_ completion: @escaping @Sendable (Result<[AnyHashable : Any], Error>) -> Void) -
Create a flexible sync configuration instance, which can be used to open a realm which supports flexible sync.
It won’t be possible to combine flexible and partition sync in the same app, which means if you open a realm with a flexible sync configuration, you won’t be able to open a realm with a PBS configuration and the other way around.
Declaration
Swift
public func flexibleSyncConfiguration(clientResetMode: ClientResetMode = .recoverUnsyncedChanges(), cancelAsyncOpenOnNonFatalErrors: Bool = false) -> Realm.ConfigurationParameters
clientResetModeDetermines file recovery behavior during a client reset.
.recoverUnsyncedChangesby default.cancelAsyncOpenOnNonFatalErrorsBy default, Realm.asyncOpen() swallows non-fatal connection errors such as a connection attempt timing out and simply retries until it succeeds. If this is set to
true, instead the error will be reported to the callback and the async open will be cancelled. -
flexibleSyncConfiguration(clientResetMode:cancelAsyncOpenOnNonFatalErrors: initialSubscriptions: rerunOnOpen: ) Create a flexible sync configuration instance, which can be used to open a realm which supports flexible sync.
It won’t be possible to combine flexible and partition sync in the same app, which means if you open a realm with a flexible sync configuration, you won’t be able to open a realm with a PBS configuration and the other way around.
Using
rerunOnOpencovers the cases where you want to re-run dynamic queries, for example time ranges.var config = user.flexibleSyncConfiguration(initialSubscriptions: { subscriptions in subscriptions.append(QuerySubscription<User>() { $0.birthdate < Date() && $0.birthdate > Calendar.current.date(byAdding: .year, value: 21)! }) }, rerunOnOpen: true)Declaration
Swift
@preconcurrency public func flexibleSyncConfiguration(clientResetMode: ClientResetMode = .recoverUnsyncedChanges(), cancelAsyncOpenOnNonFatalErrors: Bool = false, initialSubscriptions: @escaping @Sendable (SyncSubscriptionSet) -> Void, rerunOnOpen: Bool = false) -> Realm.ConfigurationParameters
clientResetModeDetermines file recovery behavior during a client reset.
.recoverUnsyncedChangesby default.initialSubscriptionsA block which receives a subscription set instance, that can be used to add an initial set of subscriptions which will be executed when the Realm is first opened.
rerunOnOpenIf true, allows to run the initial set of subscriptions specified, on every app startup. This can be used to re-run dynamic time ranges and other queries that require a re-computation of a static variable.
cancelAsyncOpenOnNonFatalErrorsBy default, Realm.asyncOpen() swallows non-fatal connection errors such as a connection attempt timing out and simply retries until it succeeds. If this is set to
true, instead the error will be reported to the callback and the async open will be cancelled.
View on GitHub
Install in Dash