Customer authentication

Register Customer account


Registers a new client account.

Note that you should NOT allow signing in again (or signing up) when a customer is already signed in. First, sign the customer out.

Do not create multiple instances nor call this method multiple times before execution.

Declared In

SNRClient.h

ClientRegisterAccountContext

Class Name

Client

Method Name

registerAccount(context:success:failure:)

Declaration

static func registerAccount(context: ClientRegisterAccountContext, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
context ClientRegisterAccountContext yes - Object with the Customer’s email, password, and other optional data
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let agreements: ClientAgreements = ClientAgreements()
agreements.email = true
agreements.sms = true
agreements.push = true
agreements.bluetooth = true
agreements.rfid = true
agreements.wifi = true
let email: String = "YOUR_EMAIL"
let password: String = "YOUR_PASSWORD"
let context: ClientRegisterAccountContext = ClientRegisterAccountContext(email: email, password: password)
context.firstName = "FIRST_NAME"
context.lastName = "LAST_NAME"
context.customId = "CUSTOM_ID"
context.sex = .male
context.phone = "123-456-789"
context.company = "Synerise"
context.address = "Lubostroń 1"
context.city = "Kraków"
context.province = "Małopolskie"
context.zipCode = "30-383"
context.countryCode = "+48"
context.agreements = agreements
context.attributes = ["attribute1": "value1", "attribute2": "value2"]
context.tags = ["tag1", "tag2" "tag3"]
Client.registerAccount(context: context, success: { (success) in
	// success
}, failure: { (error) in
	// failure
})

Confirm Customer account


Confirms a customer’s account.

Declared In

SNRClient.h

Class Name

Client

Method Name

confirmAccount(token:success:failure:)

Declaration

static func confirmAccount(token: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
token String yes - Confirmation token
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let token: String = "TOKEN"
Client.confirmAccount(token: token, success: { (success) in
	// success
}, failure: { (error) in
	// failure
})

Activate Customer account


Activates a customer’s account.

Declared In

SNRClient.h

Class Name

Client

Method Name

activateAccount(email:success:failure:)

Declaration

static func activateAccount(email: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
email String yes - Customer’s email
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let email: String = "EMAIL"
Client.activateAccount(email: email, success: { (success) in
	// success   
}) { (error) in
	// failure 
}

Request Customer account activation by pin


Requests a customer’s account registration process with PIN code.

Declared In

SNRClient.h

Class Name

Client

Method Name

requestAccountActivationByPin(email:success:failure:)

Declaration

static func requestAccountActivationByPin(email: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
email String yes - Client’s email
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let email: String = "EMAIL"
Client.requestAccountActivationByPin(email: email, success: { _ in
	// success
}) { (error) in
	// failure
}

Confirm Customer account activation by pin


Confirms a customer’s account registration process with PIN code.

Declared In

SNRClient.h

Class Name

Client

Method Name

confirmAccountActivationByPin(pinCode:email:success:failure:)

Declaration

static func confirmAccountActivationByPin(pinCode: String, email: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
pinCode String yes - Code sent to client’s email
email String yes - Client’s email
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let pinCode: String = "PIN_CODE"
let email: String = "EMAIL"
Client.confirmAccountActivationByPin(pinCode: pinCode, email: email, success: { _ in
	// success
}) { (error) in
	// failure
}

Sign in a Customer


Signs a customer in to obtain a JSON Web Token (JWT) which can be used in subsequent requests.

The SDK will refresh the token before each call if it is about to expire (but not expired).

Do NOT allow signing in again (or signing up) when a customer is already signed in. First, sign the customer out.

Do NOT create multiple instances nor call this method multiple times before execution.

Declared In

SNRClient.h

Class Name

Client

Method Name

signIn(email:password:success:failure:)

Declaration

static func signIn(email: String, password: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
email String yes - Customer’s email
password String yes - Customer’s password
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let email: String = "EMAIL"
let password: String = "PASSWORD"
Client.signIn(email: email, password: password, success: { (success) in
	// success
}, failure: { (error) in
	// failure
})

Sign in a Customer conditionally


Signs a customer in to obtain a JSON Web Token (JWT) which can be used in subsequent requests.

The SDK will refresh the token before each call if it is about to expire (but not expired).

Do NOT allow signing in again (or signing up) when a customer is already signed in. First, sign the customer out.

Do NOT create multiple instances nor call this method multiple times before execution.

Declared In

SNRClient.h

Class Name

Client

Method Name

signInConditionally(email:password:success:failure:)

Declaration

static func signInConditionally(email: String, password: String, success: ((ClientAuthenticationResult) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
email String yes - Customer’s email
password String yes - Customer’s password
success ((ClientAuthenticationResult) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let email: String = "EMAIL"
let password: String = "PASSWORD"
Client.signInConditionally(email: email, password: password, success: { (result) in
	// success
}, failure: { (error) in
	// failure
})

Authenticate Customer by IdentityProvider


Signs a customer in with an external token.

Declared In

SNRClient.h

ClientAuthenticationContext
ClientIdentityProivider

Class Name

Client

Method Name

authenticate(token:clientIdentityProvider:authID:context:success:failure:)

Declaration

static func authenticate(token: AnyObject, clientIdentityProvider: ClientIdentityProvider, authID: String?, context: ClientAuthenticationContext?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
token AnyObject yes - External Token
clientIdentityProvider ClientIdentityProvider yes - Customer’s identity Provider
authID String no - Custom identity for authorization
context ClientAuthenticationContext no - Object with marketing agreements and optional attributes
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let agreements: ClientAgreements = ClientAgreements()
agreements.email = true
agreements.sms = true
agreements.push = true
agreements.bluetooth = true
agreements.rfid = true
agreements.wifi = true
let context: ClientAuthenticationContext = ClientAuthenticationContext()
context.agreements = agreements
context.attributes = ["attribute1": "value1", "attribute2": "value2"]
let accessToken: String = "ACCESS_TOKEN"
let authID: String = "AUTH_ID"
Client.authenticate(token: token, authID: authID, context: context, success: { (success) in
	// success
}) { (error) in
	// failure   
}

Authenticate Customer conditionally by IdentityProvider


Signs a customer in with an external token.

Declared In

SNRClient.h

ClientConditionalAuthResult
ClientIdentityProvider

Class Name

Client

Method Name

authenticateConditionally(token:clientIdentityProvider:authID:context:success:failure:)

Declaration

static func authenticateConditionally(token: AnyObject, clientIdentityProvider: ClientIdentityProvider, authID: String?, context: ClientConditionalAuthenticationContext?, success: ((ClientAuthenticationResult) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
token AnyObject yes - External Token
clientIdentityProvider ClientIdentityProvider yes - Customer’s identity Provider
authID String no - Custom identity for authorization
context ClientConditionalAuthenticationContext no - Object with marketing agreements and optional attributes
success ((ClientConditionalAuthResult) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let agreements: ClientAgreements = ClientAgreements()
agreements.email = true
agreements.sms = true
agreements.push = true
agreements.bluetooth = true
agreements.rfid = true
agreements.wifi = true
let context: ClientConditionalAuthenticationContext = ClientConditionalAuthenticationContext()
context.agreements = agreements
context.attributes = ["attribute1": "value1", "attribute2": "value2"]
let accessToken: String = "ACCESS_TOKEN"
let authID: String = "AUTH_ID"
Client.authenticateConditionally(token: token, authID: authID, context: context, success: { (success) in
	// success
}) { (error) in
	// failure   
}

Authenticate Customer by OAuth with registration


Signs a customer in with OAuth Access Token.

Declared In

SNRClient.h

ClientOAuthAuthenticationContext

Class Name

Client

Method Name

authenticateByOAuth(accessToken:authID:context:success:failure:)

Declaration

static func authenticateByOAuth(accessToken: String, authID: String?, context: ClientOAuthAuthenticationContext?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
accessToken String yes - OAuth Access Token
authID String no - Custom identity for authorization
context ClientOAuthAuthenticationContext no - Object with marketing agreements and optional attributes
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let agreements: ClientAgreements = ClientAgreements()
agreements.email = true
agreements.sms = true
agreements.push = true
agreements.bluetooth = true
agreements.rfid = true
agreements.wifi = true
let context: ClientOAuthContext = ClientOAuthContext()
context.agreements = agreements
context.attributes = ["attribute1": "value1", "attribute2": "value2"]
let accessToken: String = "ACCESS_TOKEN"
let authID: String = "AUTH_ID"
Client.authenticateByOAuth(accessToken: accessToken, authID: authID, context: context, success: { (success) in
	// success
}) { (error) in
	// failure   
}

Authenticate Customer by OAuth without registration


Signs in a registered customer with OAuth Access Token.

Declared In

SNRClient.h

Class Name

Client

Method Name

authenticateByOAuthIfRegistered(accessToken:authID:success:failure:)

Declaration

static func authenticateByOAuthIfRegistered(accessToken: String, authID: String?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
accessToken String yes - OAuth Access Token
authID String no - Custom identity for authorization
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Authenticate Customer by Facebook with registration


Signs a customer in with Facebook Token.

Declared In

SNRClient.h

ClientFacebookAuthenticationContext

Class Name

Client

Method Name

authenticateByFacebook(facebookToken:authID:success:failure:)

Declaration

static func authenticateByFacebook(facebookToken: String, authID: String?, context: ClientFacebookAuthenticationContext?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
facebookToken String yes - Facebook Access Token
authID String no - Custom identity for authorization
context ClientFacebookAuthenticationContext no - Object with marketing agreements and optional attributes
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let agreements: ClientAgreements = ClientAgreements()
agreements.email = true
agreements.sms = true
agreements.push = true
agreements.bluetooth = true
agreements.rfid = true
agreements.wifi = true

let context: ClientFacebookAuthenticationContext = ClientFacebookAuthenticationContext()
context.agreements = agreements
context.attributes = ["attribute1": "value1", "attribute2": "value2"]

guard let facebookToken = FBSDKAccessToken.current()?.tokenString else {
	return
}
let authID: String = "AUTH_ID"

Client.authenticateByFacebook(facebookToken: fa, authID: authID, context: context, success: { (success) in
	// success
}) { (error) in
	// failure
}

Authenticate Customer by Facebook without registration


Signs in a registered customer with Facebook Token.

Declared In

SNRClient.h

Class Name

Client

Method Name

authenticateByFacebookIfRegistered(facebookToken:authID:success:failure:)

Declaration

static func authenticateByFacebookIfRegistered(facebookToken: String, authID: String?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
facebookToken String yes - Facebook Access Token
authID String no - Custom identity for authorization
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

guard let facebookToken = FBSDKAccessToken.current()?.tokenString else {
	return
}
let authID: String = "AUTH_ID"
Client.authenticateByFacebookIfRegistered(facebookToken: facebookToken, success: { (success) in
	// success
}, failure: { (error) in
	// failure
})

Authenticate Customer by Sign in with Apple with registration


Signs a customer in with Sign In With Apple.

Declared In

SNRClient.h

ClientAppleSignInAuthenticationContext

Class Name

Client

Method Name

authenticateByAppleSignIn(identityToken:authID:context:success:failure:)

Declaration

static func authenticateByAppleSignIn(identityToken: Data, authID: String?, context: ClientAppleSignInAuthenticationContext?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
identityToken Data yes - Custom identity for authorization
context ClientAppleSignInAuthenticationContext no - Object with marketing agreements and optional attributes
authID String no - Custom identity for authorization
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

extension LoginViewController: ASAuthorizationControllerDelegate {
	func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
	    if let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential {
			let agreements: ClientAgreements = ClientAgreements()
			agreements.email = true
			agreements.sms = true
			agreements.push = true
			agreements.bluetooth = true
			agreements.rfid = true
			agreements.wifi = true
			let context: ClientAppleSignInAuthenticationContext = ClientAppleSignInAuthenticationContext(identityToken: appleIdCredential.identityToken!)
			context.agreements = agreements
			context.attributes = ["param": "value"]
			Client.authenticateByAppleSignIn(context: context, authID: authID, success: { (success) in
				// success
			}) { (error) in
				// failure
			}
	    }
	}
}

Authenticate Customer by Sign in with Apple without registration


Signs in a registered customer with Sign In With Apple.

Declared In

SNRClient.h

Class Name

Client

Method Name

authenticateByAppleSignInIfRegistered(identityToken:authID:success:failure:)

Declaration

static func authenticateByAppleSignInIfRegistered(identityToken: String, authID: String?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void

Parameters

Parameter Type Mandatory Default Description
identityToken String yes - Apple Identity Token
authID String no - Custom identity for authorization
success ((Bool) -> Void) yes - Closure/Block to be executed when the operation finishes successfully
failure ((ApiError) -> Void) yes - Closure/Block to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Check if a Customer is signed in


Checks if a customer is signed in (if customer’s token is not expired).

Declared In

SNRClient.h

Class Name

Client

Method Name

isSignedIn()

Declaration

static func isSignedIn() -> Bool

Return Value

true if the customer is signed in, otherwise returns false.

Example

let isSignedIn: Bool = Client.isSignedIn()

Sign out Customer


Signs out a customer.

Declared In

SNRClient.h

Class Name

Client

Method Name

signOut()

Declaration

static func signOut() -> Void

Return Value

There is no return value.

Example

Client.signOut()

Sign out Customer with mode


Signs out a customer with a chosen mode:

  • .signOut mode notifies the backend that the customer is signed out.
  • .signOutWithSessionDestroy mode notifies the backend that the customer is signed out and additionally, clears the anonymous session and regenerates the client UUID.

Declared In

SNRClient.h

Class Name

Client

Method Name

signOut(mode:)

Declaration

static func signOut(mode: ClientSignOutMode) -> Void

Parameters

Parameter Type Mandatory Default Description
mode SNRClientSignOutMode yes - Mode of signing out

Return Value

There is no return value.

Example

Client.signOut(mode: .signOutWithSessionDestroy)
😕

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.

Close modal icon Placeholder alt for modal to satisfy link checker