ParseUser

public protocol ParseUser : ParseObject

Objects that conform to the ParseUser protocol have a local representation of a user persisted to the Parse Data. This protocol inherits from the ParseObject protocol, and retains the same functionality of a ParseObject, but also extends it with various user specific methods, like authentication, signing up, and validation uniqueness.

  • The username for the ParseUser.

    Declaration

    Swift

    var username: String? { get set }
  • The email for the ParseUser.

    Declaration

    Swift

    var email: String? { get set }
  • Determines if the email is verified for the ParseUser.

    Note

    This value can only be changed on the Parse Server.

    Declaration

    Swift

    var emailVerified: Bool? { get }
  • The password for the ParseUser.

    This will not be filled in from the server with the password. It is only meant to be set.

    Declaration

    Swift

    var password: String? { get set }
  • The authentication data for the ParseUser. Used by ParseAnonymous or any authentication type that conforms to ParseAuthentication.

    Declaration

    Swift

    var authData: [String : [String : String]?]? { get set }

3rd Party Authentication - ParseApple

  • apple Extension method

    An apple ParseUser.

    Declaration

    Swift

    static var apple: ParseApple<Self> { get }
  • apple Extension method

    An apple ParseUser.

    Declaration

    Swift

    var apple: ParseApple<Self> { get }

3rd Party Authentication - ParseFacebook

  • facebook Extension method

    A facebook ParseUser.

    Declaration

    Swift

    static var facebook: ParseFacebook<Self> { get }
  • facebook Extension method

    An facebook ParseUser.

    Declaration

    Swift

    var facebook: ParseFacebook<Self> { get }

3rd Party Authentication - ParseLDAP

  • ldap Extension method

    An ldap ParseUser.

    Declaration

    Swift

    static var ldap: ParseLDAP<Self> { get }
  • ldap Extension method

    An ldap ParseUser.

    Declaration

    Swift

    var ldap: ParseLDAP<Self> { get }

3rd Party Authentication - ParseTwitter

  • twitter Extension method

    A twitter ParseUser.

    Declaration

    Swift

    static var twitter: ParseTwitter<Self> { get }
  • twitter Extension method

    A twitterParseUser.

    Declaration

    Swift

    var twitter: ParseTwitter<Self> { get }

ParseAnonymous

  • anonymous Extension method

    An anonymous ParseUser.

    Declaration

    Swift

    static var anonymous: ParseAnonymous<Self> { get }
  • anonymous Extension method

    An anonymous ParseUser.

    Declaration

    Swift

    var anonymous: ParseAnonymous<Self> { get }

3rd Party Authentication - Login Combine

  • Makes an asynchronous request to log in a user with specified credentials. Publishes an instance of the successfully logged in ParseUser.

    This also caches the user locally so that calls to current will use the latest logged in user.

    Declaration

    Swift

    static func loginPublisher(_ type: String,
                               authData: [String: String],
                               options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    type

    The authentication type.

    authData

    The data that represents the authentication.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • unlinkPublisher(_:options:) Extension method

    Unlink the authentication type asynchronously. Publishes when complete.

    Declaration

    Swift

    func unlinkPublisher(_ type: String,
                         options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    type

    The type to unlink. The user must be logged in on this device.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Makes an asynchronous request to link a user with specified credentials. The user should already be logged in. Publishes an instance of the successfully linked ParseUser.

    This also caches the user locally so that calls to current will use the latest logged in user.

    Declaration

    Swift

    static func linkPublisher(_ type: String,
                              authData: [String: String],
                              options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    type

    The authentication type.

    authData

    The data that represents the authentication.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

3rd Party Authentication - Login

  • login(_:authData:options:) Extension method

    Makes a synchronous request to login a user with specified credentials.

    Returns an instance of the successfully logged in ParseUser. This also caches the user locally so that calls to current will use the latest logged in user.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    static func login(_ type: String,
                      authData: [String: String],
                      options: API.Options) throws -> Self

    Parameters

    type

    The authentication type.

    authData

    The data that represents the authentication.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An instance of the logged in ParseUser. If login failed due to either an incorrect password or incorrect username, it throws a ParseError.

  • Makes an asynchronous request to log in a user with specified credentials. Returns an instance of the successfully logged in ParseUser.

    This also caches the user locally so that calls to current will use the latest logged in user.

    Declaration

    Swift

    static func login(_ type: String,
                      authData: [String: String],
                      options: API.Options,
                      callbackQueue: DispatchQueue = .main,
                      completion: @escaping (Result<Self, ParseError>) -> Void)

    Parameters

    type

    The authentication type.

    authData

    The data that represents the authentication.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Self, ParseError>).

3rd Party Authentication - Link

  • isLinked(with:) Extension method

    Whether the ParseUser is logged in with the respective authentication string type.

    Declaration

    Swift

    func isLinked(with type: String) -> Bool

    Parameters

    type

    The authentication type to check. The user must be logged in on this device.

    Return Value

    true if the ParseUser is logged in via the repective authentication type. false if the user is not.

  • strip(_:) Extension method

    Strips the current user of a respective authentication type.

    Declaration

    Swift

    func strip(_ type: String) -> Self

    Parameters

    type

    The authentication type to strip.

    Return Value

    The user whose autentication type was stripped.

  • Unlink the authentication type asynchronously.

    Declaration

    Swift

    func unlink(_ type: String,
                options: API.Options = [],
                callbackQueue: DispatchQueue = .main,
                completion: @escaping (Result<Self, ParseError>) -> Void)

    Parameters

    type

    The type to unlink. The user must be logged in on this device.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Self, ParseError>).

  • link(_:authData:options:) Extension method

    Makes a synchronous request to link a user with specified credentials. The user should already be logged in.

    Returns an instance of the successfully linked ParseUser. This also caches the user locally so that calls to current will use the latest logged in user.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    static func link(_ type: String,
                     authData: [String: String],
                     options: API.Options) throws -> Self

    Parameters

    type

    The authentication type.

    authData

    The data that represents the authentication.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An instance of the logged in ParseUser. If login failed due to either an incorrect password or incorrect username, it throws a ParseError.

  • Makes an asynchronous request to link a user with specified credentials. The user should already be logged in. Returns an instance of the successfully linked ParseUser.

    This also caches the user locally so that calls to current will use the latest logged in user.

    Declaration

    Swift

    static func link(_ type: String,
                     authData: [String: String],
                     options: API.Options = [],
                     callbackQueue: DispatchQueue = .main,
                     completion: @escaping (Result<Self, ParseError>) -> Void)

    Parameters

    type

    The authentication type.

    authData

    The data that represents the authentication.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Self, ParseError>).

Signing Up - Combine

  • Signs up the user asynchronously and publishes value.

    This will also enforce that the username isn’t already taken.

    Warning

    Make sure that password and username are set before calling this method.

    Declaration

    Swift

    static func signupPublisher(username: String,
                                password: String,
                                options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    username

    The username of the user.

    password

    The password of the user.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • signupPublisher(options:) Extension method

    Signs up the user asynchronously and publishes value.

    This will also enforce that the username isn’t already taken.

    Warning

    Make sure that password and username are set before calling this method.

    Declaration

    Swift

    func signupPublisher(options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Logging In - Combine

  • Makes an asynchronous request to log in a user with specified credentials. Publishes an instance of the successfully logged in ParseUser.

    This also caches the user locally so that calls to current will use the latest logged in user.

    Declaration

    Swift

    static func loginPublisher(username: String,
                               password: String,
                               options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    username

    The username of the user.

    password

    The password of the user.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

  • Logs in a ParseUser asynchronously with a session token. Publishes an instance of the successfully logged in ParseUser. If successful, this saves the session to the keychain, so you can retrieve the currently logged in user using current.

    Declaration

    Swift

    func becomePublisher(sessionToken: String, options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    sessionToken

    The sessionToken of the user to login.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Logging Out - Combine

  • logoutPublisher(options:) Extension method

    Logs out the currently logged in user asynchronously. Publishes when complete.

    This will also remove the session from the Keychain, log out of linked services and all future calls to current will return nil.

    Declaration

    Swift

    static func logoutPublisher(options: API.Options = []) -> Future<Void, ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Password Reset - Combine

  • Requests asynchronously a password reset email to be sent to the specified email address associated with the user account. This email allows the user to securely reset their password on the web. Publishes when complete.

    Declaration

    Swift

    static func passwordResetPublisher(email: String,
                                       options: API.Options = []) -> Future<Void, ParseError>

    Parameters

    email

    The email address associated with the user that forgot their password.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Verification Email Request - Combine

  • Requests asynchronously a verification email be sent to the specified email address associated with the user account. Publishes when complete.

    Declaration

    Swift

    static func verificationEmailPublisher(email: String,
                                           options: API.Options = []) -> Future<Void, ParseError>

    Parameters

    email

    The email address associated with the user.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Fetchable - Combine

  • Fetches the ParseUser aynchronously with the current data from the server and sets an error if one occurs. Publishes when complete.

    Important

    If an object fetched has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    func fetchPublisher(includeKeys: [String]? = nil,
                        options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    includeKeys

    The name(s) of the key(s) to include that are ParseObjects. Use ["*"] to include all keys. This is similar to include and includeAll for Query.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Savable - Combine

  • savePublisher(options:) Extension method

    Saves the ParseUser asynchronously and publishes when complete.

    Important

    If an object saved has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    func savePublisher(options: API.Options = []) -> Future<Self, ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Deletable - Combine

  • deletePublisher(options:) Extension method

    Deletes the ParseUser asynchronously and publishes when complete.

    Important

    If an object deleted has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    func deletePublisher(options: API.Options = []) -> Future<Void, ParseError>

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    A publisher that eventually produces a single value and then finishes or fails.

Default Implementations

  • className Extension method

    Declaration

    Swift

    static var className: String { get }

Current User Support

  • current Extension method

    Gets the currently logged in user from the Keychain and returns an instance of it.

    Warning

    Only use current users on the main thread as as modifications to current have to be unique.

    Declaration

    Swift

    public static var current: Self? { get set }

    Return Value

    Returns a ParseUser that is the currently logged in user. If there is none, returns nil.

  • sessionToken Extension method

    The session token for the ParseUser.

    This is set by the server upon successful authentication.

    Declaration

    Swift

    public var sessionToken: String? { get }

Logging In

  • Makes a synchronous request to login a user with specified credentials.

    Returns an instance of the successfully logged in ParseUser. This also caches the user locally so that calls to current will use the latest logged in user.

    Throws

    An error of type ParseError.

    Declaration

    Swift

    public static func login(username: String,
                             password: String, options: API.Options = []) throws -> Self

    Parameters

    username

    The username of the user.

    password

    The password of the user.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    An instance of the logged in ParseUser. If login failed due to either an incorrect password or incorrect username, it throws a ParseError.

  • Makes an asynchronous request to log in a user with specified credentials. Returns an instance of the successfully logged in ParseUser.

    This also caches the user locally so that calls to current will use the latest logged in user.

    Declaration

    Swift

    public static func login(
        username: String,
        password: String,
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<Self, ParseError>) -> Void
    )

    Parameters

    username

    The username of the user.

    password

    The password of the user.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Self, ParseError>).

  • Logs in a ParseUser synchronously with a session token. On success, this saves the session to the keychain, so you can retrieve the currently logged in user using current.

    Throws

    An Error of ParseError type.

    Declaration

    Swift

    public func become(sessionToken: String, options: API.Options = []) throws -> Self

    Parameters

    sessionToken

    The sessionToken of the user to login.

    options

    A set of header options sent to the server. Defaults to an empty set.

  • Logs in a ParseUser asynchronously with a session token. On success, this saves the session to the keychain, so you can retrieve the currently logged in user using current.

    Declaration

    Swift

    public func become(sessionToken: String,
                       options: API.Options = [],
                       callbackQueue: DispatchQueue = .main,
                       completion: @escaping (Result<Self, ParseError>) -> Void)

    Parameters

    sessionToken

    The sessionToken of the user to login.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute when completed. It should have the following argument signature: (Result<Self, ParseError>).

Logging Out

  • logout(options:) Extension method

    Logs out the currently logged in user in Keychain synchronously.

    Declaration

    Swift

    public static func logout(options: API.Options = []) throws
  • Logs out the currently logged in user asynchronously.

    This will also remove the session from the Keychain, log out of linked services and all future calls to current will return nil. This is preferable to using logout, unless your code is already running from a background thread.

    Declaration

    Swift

    public static func logout(options: API.Options = [], callbackQueue: DispatchQueue = .main,
                              completion: @escaping (Result<Void, ParseError>) -> Void)

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    A block that will be called when logging out completes or fails.

Password Reset

  • Requests synchronously a password reset email to be sent to the specified email address associated with the user account. This email allows the user to securely reset their password on the web.

    Declaration

    Swift

    public static func passwordReset(email: String, options: API.Options = []) throws

    Parameters

    email

    The email address associated with the user that forgot their password.

    options

    A set of header options sent to the server. Defaults to an empty set.

  • Requests asynchronously a password reset email to be sent to the specified email address associated with the user account. This email allows the user to securely reset their password on the web.

    Declaration

    Swift

    public static func passwordReset(email: String, options: API.Options = [],
                                     callbackQueue: DispatchQueue = .main,
                                     completion: @escaping (Result<Void, ParseError>) -> Void)

    Parameters

    email

    The email address associated with the user that forgot their password.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    A block that will be called when the password reset completes or fails.

Verification Email Request

  • Requests synchronously a verification email be sent to the specified email address associated with the user account.

    Declaration

    Swift

    public static func verificationEmail(email: String,
                                         options: API.Options = []) throws

    Parameters

    email

    The email address associated with the user.

    options

    A set of header options sent to the server. Defaults to an empty set.

  • Requests asynchronously a verification email be sent to the specified email address associated with the user account.

    Declaration

    Swift

    public static func verificationEmail(email: String,
                                         options: API.Options = [],
                                         callbackQueue: DispatchQueue = .main,
                                         completion: @escaping (Result<Void, ParseError>) -> Void)

    Parameters

    email

    The email address associated with the user.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    A block that will be called when the verification request completes or fails.

Signing Up

  • Signs up the user synchronously.

    This will also enforce that the username isn’t already taken.

    Warning

    Make sure that password and username are set before calling this method.

    Declaration

    Swift

    public static func signup(username: String,
                              password: String,
                              options: API.Options = []) throws -> Self

    Parameters

    username

    The username of the user.

    password

    The password of the user.

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns whether the sign up was successful.

  • signup(options:) Extension method

    Signs up the user synchronously.

    This will also enforce that the username isn’t already taken.

    Warning

    Make sure that password and username are set before calling this method.

    Declaration

    Swift

    public func signup(options: API.Options = []) throws -> Self

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns whether the sign up was successful.

  • Signs up the user asynchronously.

    This will also enforce that the username isn’t already taken.

    Warning

    Make sure that password and username are set before calling this method.

    Declaration

    Swift

    public func signup(options: API.Options = [], callbackQueue: DispatchQueue = .main,
                       completion: @escaping (Result<Self, ParseError>) -> Void)

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Self, ParseError>).

  • Signs up the user asynchronously.

    This will also enforce that the username isn’t already taken.

    Warning

    Make sure that password and username are set before calling this method.

    Declaration

    Swift

    public static func signup(
        username: String,
        password: String,
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<Self, ParseError>) -> Void)

    Parameters

    username

    The username of the user.

    password

    The password of the user.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Self, ParseError>).

Fetchable

  • fetch(includeKeys:options:) Extension method

    Fetches the ParseUser synchronously with the current data from the server and sets an error if one occurs.

    Throws

    An error of ParseError type.

    Important

    If an object fetched has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    public func fetch(includeKeys: [String]? = nil,
                      options: API.Options = []) throws -> Self

    Parameters

    includeKeys

    The name(s) of the key(s) to include that are ParseObjects. Use ["*"] to include all keys. This is similar to include and includeAll for Query.

    options

    A set of header options sent to the server. Defaults to an empty set.

  • Fetches the ParseUser asynchronously and executes the given callback block.

    Important

    If an object fetched has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    public func fetch(
        includeKeys: [String]? = nil,
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<Self, ParseError>) -> Void
    )

    Parameters

    includeKeys

    The name(s) of the key(s) to include that are ParseObjects. Use ["*"] to include all keys. This is similar to include and includeAll for Query.

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute when completed. It should have the following argument signature: (Result<Self, ParseError>).

Savable

  • save(options:) Extension method

    Saves the ParseUser synchronously and throws an error if there’s an issue.

    Throws

    An error of type ParseError.

    Important

    If an object saved has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    public func save(options: API.Options = []) throws -> Self

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    Return Value

    Returns saved ParseUser.

  • Saves the ParseUser asynchronously and executes the given callback block.

    Important

    If an object saved has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    public func save(
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<Self, ParseError>) -> Void
    )

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute. It should have the following argument signature: (Result<Self, ParseError>).

Deletable

  • delete(options:) Extension method

    Deletes the ParseUser synchronously with the current data from the server and sets an error if one occurs.

    Throws

    An error of ParseError type.

    Important

    If an object deleted has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    public func delete(options: API.Options = []) throws

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

  • Deletes the ParseUser asynchronously and executes the given callback block.

    Important

    If an object deleted has the same objectId as current, it will automatically update the current.

    Declaration

    Swift

    public func delete(
        options: API.Options = [],
        callbackQueue: DispatchQueue = .main,
        completion: @escaping (Result<Void, ParseError>) -> Void
    )

    Parameters

    options

    A set of header options sent to the server. Defaults to an empty set.

    callbackQueue

    The queue to return to after completion. Default value of .main.

    completion

    The block to execute when completed. It should have the following argument signature: (Result<Void, ParseError>).