User
public extension 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
User
is 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 TheCredentials
used 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
func linkUser(credentials: Credentials, _ completion: @escaping (Result<User, Error>) -> Void)
-
Create a sync configuration instance.
Additional settings can be optionally specified. Descriptions of these settings follow.
enableSSLValidation
is true by default. It can be disabled for debugging purposes.Warning
NEVER disable SSL validation for a system running in production. -
Create a sync configuration instance.
Warning
NEVER disable SSL validation for a system running in production.
Declaration
Parameters
partitionValue
Takes
nil
as a partition value.cancelAsyncOpenOnNonFatalErrors
By 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.
Warning
NEVER disable SSL validation for a system running in production.
Declaration
Parameters
partitionValue
The
BSON
value the Realm is partitioned on.cancelAsyncOpenOnNonFatalErrors
By 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 MongoDB Realm App.
Declaration
Swift
var customData: Document { get }
-
A client for interacting with a remote MongoDB instance
Declaration
Swift
func mongoClient(_ serviceName: String) -> MongoClient
Parameters
serviceName
The name of the MongoDB service
Return Value
A
MongoClient
which is used for interacting with a remote MongoDB service -
Call a MongoDB Realm 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 (
sum
in the above example) is directly associated with the function name. The first argument is theBSONArray
of 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
Dictionary
with user’s data orError
.Declaration
Swift
func refreshCustomData() -> Future<[AnyHashable : Any], Error>
-
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
User
is 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 TheCredentials
used to link the user to a new identity. @returns A publisher that eventually returnResult.success
orError
.Declaration
Swift
func linkUser(credentials: Credentials) -> Future<User, 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.success
orError
.Declaration
Swift
func remove() -> Future<Void, Error>
-
Logs out the current user The users state will be set to
Removed
is they are an anonymous user orLoggedOut
if 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.success
orError
.Declaration
Swift
func logOut() -> Future<Void, Error>
-
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
func refreshCustomData(_ completion: @escaping (Result<[AnyHashable : Any], Error>) -> Void)