Customer session

Refresh Customer token


Refreshes the Customer’s current token.

An error is returned when the Customer is not logged in or the token has expired and cannot be refreshed.

Declared In

SNRClient.h

Method Name

Client.refreshToken(success:failure:)

Declaration

func refreshToken(success: (() -> ()), failure: ((Error) -> ())) -> Void

Parameters

Parameter Type Mandatory Default Description
success Block/Closure no - Block/closure to be executed when the operation finishes successfully
failure Block/Closure no - Block/closure to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Client.refreshToken(success: { _ in
	Client.retrieveToken(success: { (token) in
		// success
		let tokenString: String = token.tokenString
		let tokenOrigin: TokenOrigin = token.tokenOrigin
	}, failure: { (error) in
		// failure
	})
}, failure: { (error) in
	// failure
})

Retrieve Customer token


Retrieves the Customer’s current, active token.

An error is returned when the Customer is not logged in or the token has expired and cannot be refreshed.

Declared In

SNRClient.h

SNRToken.h SNRTokenOrigin.h

Method Name

Client.retrieveToken(success:failure:)

Declaration

func retrieveToken(success: ((SNRToken) -> ()), failure: ((Error) -> ())) -> Void

Parameters

Parameter Type Mandatory Default Description
success Block/Closure no - Block/closure to be executed when the operation finishes successfully
failure Block/Closure no - Block/closure to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Client.retrieveToken(success: { (token) in
	// success
	let tokenString: String = token.tokenString
	let tokenOrigin: TokenOrigin = token.tokenOrigin
}, failure: { (error) in
	// failure
})

Get Customer token (deprecated)


Retrieves the Customer’s current, active token.

An error is returned when the Customer is not logged in or the token has expired and cannot be refreshed.

Declared In

SNRClient.h

SNRTokenOrigin.h

Method Name

Client.getToken(success:failure:)

Declaration

func getToken(success: ((String, TokenOrigin) -> ()), failure: ((Error) -> ())) -> Void

Parameters

Parameter Type Mandatory Default Description
success Block/Closure no - Block/closure to be executed when the operation finishes successfully
failure Block/Closure no - Block/closure to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Client.getToken(success: { (token, origin) in
	// success
}) { (error) in
	// failure
}

Get current Customer UUID


Retrieve the Customer’s current UUID.

HTTP 403 status code is returned if the provided password is invalid.

Declared In

SNRClient.h

Method Name

Client.getUUID()

Declaration

func getUUID() -> String

Return Value

Method returns NSString/String with the Customer’s UUID.

Example

let clientUUID: String = Client.getUUID()

Regenerate Customer


Regenerate the UUID and clear the authentication token, login session, custom email, and custom identifier.

This operation works only if the Customer is anonymous.

Declared In

SNRClient.h

Method Name

Client.regenerateUUID()

Declaration

func regenerateUUID() -> Void

Return Value

true if the Current Client is anonymous and the operation succeed, false otherwise.

Regenerate Customer with identifier


Regenerate the UUID and clear the authentication token, login session, custom email, and custom identifier.

This operation works only if the Customer is anonymous.

Optional clientIdentifier parameter is a seed for UUID generation.

Declared In

SNRClient.h

Method Name

Client.regenerateUUID(clientIdentifier:)

Declaration

func regenerateUUID(clientIdentifier: String) -> Void

Return Value

true if the current Customer is anonymous and the operation succeeds, false otherwise.

Destroy current session


Destroys the whole session completely.

Declared In

SNRClient.h

Method Name

Client.destroySession())

Declaration

func destroySession()

Return Value

There is no return value.

Example

Client.destroySession()
😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.