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 }
-
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 byParseAnonymous
or any authentication type that conforms toParseAuthentication
.Declaration
Swift
var authData: [String : [String : String]?]? { get set }
-
apple
Extension methodAn apple
ParseUser
.Declaration
Swift
static var apple: ParseApple<Self> { get }
-
apple
Extension methodAn apple
ParseUser
.Declaration
Swift
var apple: ParseApple<Self> { get }
-
anonymous
Extension methodAn anonymous
ParseUser
.Declaration
Swift
static var anonymous: ParseAnonymous<Self> { get }
-
anonymous
Extension methodAn anonymous
ParseUser
.Declaration
Swift
var anonymous: ParseAnonymous<Self> { get }
-
loginPublisher(_:
Extension methodauthData: options: ) 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(_:
Extension methodoptions: ) 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.
-
linkPublisher(_:
Extension methodauthData: options: ) 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.
-
login(_:
Extension methodauthData: options: ) 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 typeParseError
.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 aParseError
. -
login(_:
Extension methodauthData: options: callbackQueue: completion: ) 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>)
.
-
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 theParseUser
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(_:
Extension methodoptions: callbackQueue: completion: ) 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(_:
Extension methodauthData: options: ) 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 typeParseError
.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 aParseError
. -
link(_:
Extension methodauthData: options: callbackQueue: completion: ) 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>)
.
-
signupPublisher(username:
Extension methodpassword: options: ) 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.
-
loginPublisher(username:
Extension methodpassword: options: ) 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.
-
becomePublisher(sessionToken:
Extension methodoptions: ) Logs in a
ParseUser
asynchronously with a session token. Publishes an instance of the successfully logged inParseUser
. 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.
-
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 returnnil
.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.
-
passwordResetPublisher(email:
Extension methodoptions: ) 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.
-
verificationEmailPublisher(email:
Extension methodoptions: ) 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.
-
fetchPublisher(includeKeys:
Extension methodoptions: ) 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
ParseObject
s. Use["*"]
to include all keys. This is similar toinclude
andincludeAll
forQuery
.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.
-
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.
-
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.
-
className
Extension methodDeclaration
Swift
static var className: String { get }
-
current
Extension methodGets the currently logged in user from the Keychain and returns an instance of it.
Warning
Only usecurrent
users on the main thread as as modifications tocurrent
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, returnsnil
. -
sessionToken
Extension methodThe session token for the
ParseUser
.This is set by the server upon successful authentication.
Declaration
Swift
public var sessionToken: String? { get }
-
login(username:
Extension methodpassword: options: ) 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 typeParseError
.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 aParseError
. -
login(username:
Extension methodpassword: options: callbackQueue: completion: ) 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>)
. -
become(sessionToken:
Extension methodoptions: ) 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 ofParseError
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.
-
become(sessionToken:
Extension methodoptions: callbackQueue: completion: ) 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>)
.
-
logout(options:
Extension method) Logs out the currently logged in user in Keychain synchronously.
Declaration
Swift
public static func logout(options: API.Options = []) throws
-
logout(options:
Extension methodcallbackQueue: completion: ) 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 returnnil
. This is preferable to usinglogout
, 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.
-
passwordReset(email:
Extension methodoptions: ) 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.
-
passwordReset(email:
Extension methodoptions: callbackQueue: completion: ) 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.
-
verificationEmail(email:
Extension methodoptions: ) 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.
-
verificationEmail(email:
Extension methodoptions: callbackQueue: completion: ) 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.
-
signup(username:
Extension methodpassword: options: ) 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.
-
signup(options:
Extension methodcallbackQueue: completion: ) 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>)
. -
signup(username:
Extension methodpassword: options: callbackQueue: completion: ) 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>)
.
-
fetch(includeKeys:
Extension methodoptions: ) Fetches the
ParseUser
synchronously with the current data from the server and sets an error if one occurs.Throws
An error ofParseError
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
ParseObject
s. Use["*"]
to include all keys. This is similar toinclude
andincludeAll
forQuery
.options
A set of header options sent to the server. Defaults to an empty set.
-
fetch(includeKeys:
Extension methodoptions: callbackQueue: completion: ) 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
ParseObject
s. Use["*"]
to include all keys. This is similar toinclude
andincludeAll
forQuery
.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>)
.
-
save(options:
Extension method) Saves the
ParseUser
synchronously and throws an error if there’s an issue.Throws
An error of typeParseError
.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
. -
save(options:
Extension methodcallbackQueue: completion: ) 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>)
.
-
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 ofParseError
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.
-
delete(options:
Extension methodcallbackQueue: completion: ) 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>)
.