Set Client State delegate
This method sets an object for a customer's state delegate methods.
Declared In:
Headers/SNRClient.h
Related To:
ClientStateDelegate
Class:
Client
Declaration:
static func setClientStateDelegate(_ delegate: ClientStateDelegate)
+ (void)setClientStateDelegate:(SNRClientStateDelegate *)delegate
Discussion:
Learn more about the methods and the purpose of this listener here.
Register customer account
This method registers a new customer with an email, password, and optional data.
This method requires the context object with a customer’s email, password, and optional data. Omitted fields are not modified.
Depending on the backend configuration, the account may require activation. For details, see customer registration.
Do not allow signing in again (or signing up) when a customer is already signed in. Sign the customer out first.
Do not create multiple instances nor call this method multiple times before execution.
This method is a global operation and doesn't require customer authentication.
The API key must have the SAUTH_REGISTER_CLIENT_CREATE permission from the Client group.
Declared In:
Headers/SNRClient.h
Related To:
ClientRegisterAccountContext
Class:
Client
Declaration:
static func registerAccount(context: ClientRegisterAccountContext, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)registerAccount:(nonnull SNRClientRegisterAccountContext *)context success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| context | ClientRegisterAccountContext | yes | - | Object with the customer's email, password, and other optional data |
| success | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
Since version 5.0.0, the success closure does NOT contain the isSuccess parameter.
Return Value:
No value is returned.
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
}, failure: { (error) in
// failure
})
SNRClientAgreements *agreements = [SNRClientAgreements new];
agreements.email = true;
agreements.sms = true;
agreements.push = true;
agreements.bluetooth = true;
agreements.rfid = true;
agreements.wifi = true;
NSString *email = @"EMAIL";
NSString *password = @"PASSWORD";
SNRClientRegisterAccountContext *context = [SNRClientRegisterAccountContext alloc] initWithEmail:email andPassword:password];
context.firstName = @"FIRST_NAME";
context.lastName = @"LAST_NAME";
context.customId = @"CUSTOM_ID";
context.sex = SNRClientSexMale;
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 = @{@"attribute": @"value"};
context.tags = @[@"tag1", @"tag2" @"tag3"];
[SNRClient registerAccount:context success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Request customer account activation
This method requests sending an email with a URL that confirms the registration and activates the account.
This method is a global operation and doesn't require customer authentication.
The API key must have the SAUTH_CONFIRMATION_CLIENT_CREATE permission from the Client group.
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func requestAccountActivation(email: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)requestAccountActivationWithEmail:(nonnull NSString *)email success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| String | yes | - | Customer's email | |
| success | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
Before version 5.0.0, this method was called Synerise.activateAccount(email:success:failure:).
Since version 5.0.0, the success closure does NOT contain the isSuccess parameter.
Return Value:
No value is returned.
Example:
let email: String = "EMAIL"
Client.requestAccountActivation(email: email, success: {
// success
}) { (error) in
// failure
}
NSString *email = @"EMAIL";
[SNRClient requestAccountActivationWithEmail:email success:^() {
// success
} failure:^(NSError * error) {
// failure
}];
Confirm customer account activation
This method confirms a customer account with the confirmation token.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 400 status code if the account is already confirmed or 404 if the account does not exist.
The API key must have the SAUTH_CONFIRMATION_CLIENT_CREATE permission from the Client group.
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func confirmAccountActivation(token: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)confirmAccountActivationByToken:(nonnull NSString *)token success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| token | String | yes | - | Confirmation token |
| success | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
Before version 5.0.0, this method was called Synerise.confirmAccount(token:success:failure:).
Since version 5.0.0, the success closure does NOT contain the isSuccess parameter.
Return Value:
No value is returned.
Example:
let token: String = "TOKEN"
Client.confirmAccountActivation(token: token, success: {
// success
}, failure: { (error) in
// failure
})
NSString *token = @"TOKEN";
[SNRClient confirmAccountActivationByToken:token success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Request customer account activation by pin
This method requests a customer's account registration process with the PIN code.
This method is a global operation and doesn't require customer authentication.
The API key must have the SAUTH_PIN_CODE_RESEND_CLIENT_CREATE permission from the Client group.
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func requestAccountActivationByPin(email: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)requestAccountActivationByPinWithEmail:(nonnull NSString *)email success:(nonnull void (^)(void))success failure:(nonnull void (^)(SNRApiError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| String | yes | - | Customer's email | |
| success | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
Since version 5.0.0, the success closure does NOT contain the isSuccess parameter.
Return Value:
No value is returned.
Example:
let email: String = "EMAIL"
Client.requestAccountActivationByPin(email: email, success: {
// success
}) { (error) in
// failure
}
NSString *email = @"EMAIL";
[SNRClient requestAccountActivationByPinWithEmail:email success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Confirm customer account activation by pin
This method confirms a customer's account registration process with the PIN code.
This method is a global operation and doesn't require customer authentication.
The API key must have the SAUTH_PIN_CODE_RESEND_CLIENT_CREATE permission from the Client group.
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func confirmAccountActivationByPin(pinCode: String, email: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)confirmAccountActivationByPin:(nonnull NSString *)pinCode email:(nonnull NSString *)email success:(nonnull void (^)(void))success failure:(nonnull void (^)(SNRApiError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| pinCode | String | yes | - | Code sent to a customer's email |
| String | yes | - | Customer's email | |
| success | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
Since version 5.0.0, the success closure does NOT contain the isSuccess parameter.
Return Value:
No value is returned.
Example:
let pinCode: String = "PIN_CODE"
let email: String = "EMAIL"
Client.confirmAccountActivationByPin(pinCode: pinCode, email: email, success: {
// success
}) { (error) in
// failure
}
NSString *pinCode = @"PIN_CODE";
NSString *email = @"EMAIL";
[SNRClient confirmAccountActivationByPin:pinCode email:email success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Sign in a customer
This method 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:
Headers/SNRClient.h
Class:
Client
Declaration:
static func signIn(email: String, password: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)signInWithEmail:(nonnull NSString *)email password:(nonnull NSString *)password success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| String | yes | - | Customer's email | |
| password | String | yes | - | Customer's password |
| success | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
Since version 5.0.0, the success closure does NOT contain the isSuccess parameter.
Return Value:
No value is returned.
Example:
let email: String = "EMAIL"
let password: String = "PASSWORD"
Client.signIn(email: email, password: password, success: {
// success
}, failure: { (error) in
// failure
})
NSString *email = @"EMAIL";
NSString *password = @"PASSWORD";
[SNRClient signInWithEmail:email password:password success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Sign in a customer conditionally
This method 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.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 3.7.6 | 3.8.0 | 0.9.19 | n/a |
| Declared In: | ||||
| Headers/SNRClient.h |
Class:
Client
Declaration:
static func signInConditionally(email: String, password: String, success: ((ClientAuthenticationResult) -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)signInConditionallyWithEmail:(nonnull NSString *)email password:(nonnull NSString *)password success:(nonnull void (^)(SNRClientAuthenticationResult *result))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| String | yes | - | Customer's email | |
| password | String | yes | - | Customer's password |
| success | ((ClientAuthenticationResult) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
let email: String = "EMAIL"
let password: String = "PASSWORD"
Client.signInConditionally(email: email, password: password, success: { (result) in
// success
}, failure: { (error) in
// failure
})
NSString *email = @"EMAIL";
NSString *password = @"PASSWORD";
[SNRClient signInConditionallyWithEmail:email password:password success:^(SNRClientAuthenticationResult *result) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Authenticate customer by IdentityProvider
This method authenticates a customer with OAuth, Facebook, Google, Apple, or Synerise.
If an account for the customer does not exist and the identity provider is different than Synerise, this request creates an account.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 3.7.6 | 3.8.0 | 0.9.19 | 0.3.0 |
| Declared In: | ||||
| Headers/SNRClient.h |
Related To:
ClientAuthenticationContext
ClientIdentityProivider
Class:
Client
Declaration:
static func authenticate(token: AnyObject, clientIdentityProvider: ClientIdentityProvider, authID: String?, context: ClientAuthenticationContext?, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)authenticateWithToken:(id)token clientIdentityProvider:(SNRClientIdentityProvider)clientIdentityProvider authID:(nullable NSString *)authID context:(nullable SNRClientAuthenticationContext *)context success:(void (^)(void))success failure:(void (^)(SNRApiError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| token | AnyObject | yes | - | Token retrieved from provider |
| clientIdentityProvider | ClientIdentityProvider | yes | - | Provider of your token |
| authID | String | no | nil | Optional identifier of authorization |
| context | ClientAuthenticationContext | no | nil | Object which contains agreements and attributes |
| success | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Since version 5.0.0, the success closure does NOT contain the isSuccess parameter.
Return Value:
No value is returned.
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
}) { (error) in
// failure
}
SNRClientAgreements *agreements = [SNRClientAgreements new];
agreements.email = true;
agreements.sms = true;
agreements.push = true;
agreements.bluetooth = true;
agreements.rfid = true;
agreements.wifi = true;
SNRClientAuthenticationContext *context = [SNRClientAuthenticationContext new];
context.agreements = agreements;
context.attributes = @{"attribute1": "value1", "attribute2": "value2"};
NSString *accessToken = @"ACCESS_TOKEN";
NSString *authID = @"AUTH_ID";
[SNRClient authenticateWithToken:token authID:authID context:context success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Authenticate customer conditionally by IdentityProvider
This method authenticates a customer with OAuth, Facebook, Google, Apple, or Synerise.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 3.7.6 | 3.8.0 | 0.9.19 | n/a |
| Declared In: | ||||
| Headers/SNRClient.h |
Related To:
ClientConditionalAuthResult
ClientIdentityProvider
Class:
Client
Declaration:
static func authenticateConditionally(token: AnyObject, clientIdentityProvider: ClientIdentityProvider, authID: String?, context: ClientConditionalAuthenticationContext?, success: ((ClientAuthenticationResult) -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)authenticateConditionallyWithToken:(id)token clientIdentityProvider:(SNRClientIdentityProvider)clientIdentityProvider authID:(nullable NSString *)authID context:(nullable SNRClientConditionalAuthenticationContext *)context success:(void (^)(SNRClientAuthenticationResult *authenticationResult))success failure:(void (^)(SNRApiError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| token | AnyObject | yes | - | Token retrieved from provider |
| clientIdentityProvider | ClientIdentityProvider | yes | - | Provider of your token |
| authID | String | no | nil | Optional identifier of authorization |
| context | ClientConditionalAuthenticationContext | no | nil | Object which contains agreements and attributes |
| success | ((ClientConditionalAuthResult) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Return Value:
No value is returned.
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
}
SNRClientAgreements *agreements = [SNRClientAgreements new];
agreements.email = true;
agreements.sms = true;
agreements.push = true;
agreements.bluetooth = true;
agreements.rfid = true;
agreements.wifi = true;
SNRClientConditionalAuthenticationContext *context = [SNRClientConditionalAuthenticationContext new];
context.agreements = agreements;
context.attributes = @{"attribute1": "value1", "attribute2": "value2"};
NSString *accessToken = @"ACCESS_TOKEN";
NSString *authID = @"AUTH_ID";
[SNRClient authenticateConditionallyWithToken:token authID:authID context:context success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Authenticate customer with token payload
This method signs in a customer in with the provided token payload.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 4.15.0 | 5.15.0 | n/a | n/a |
| Declared In: | ||||
| Headers/SNRClient.h |
Related To:
TokenPayload
Class:
Client
Declaration:
static func authenticate(tokenPayload: TokenPayload, authID: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)authenticateWithTokenPayload:(SNRTokenPayload *)tokenPayload authID:(NSString *)authID success:(void (^)(void))success failure:(void (^)(SNRApiError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| tokenPayload | TokenPayload | yes | - | Object which contains a token's payload |
| authID | String | yes | - | Required customer's identifier of authorization |
| success | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
authID parameter is used for decreasion the number of UUID refreshes so it must be unique for every customer.
Return Value:
No value is returned.
Authenticate customer via Simple Profile Authentication
This method authenticates a customer with Simple Profile Authentication.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 4.14.0 | 5.7.1 | 0.15.0 | 0.7.0 |
When you use this method, you must set a request validation salt by using the Synerise.setRequestValidationSalt(_:) method (if salt is enabled for Simple Profile Authentication).
The API key must have the SAUTH_SIMPLE_AUTH_CREATE from the Auth group.
Declared In:
Headers/SNRClient.h
Related To:
ClientSimpleAuthenticationData
Class:
Client
Declaration:
static func simpleAuthentication(data: ClientSimpleAuthenticationData, authID: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)simpleAuthentication:(SNRClientSimpleAuthenticationData *)data authID:(NSString *)authID success:(void (^)(void))success failure:(void (^)(SNRApiError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| data | ClientSimpleAuthenticationData | yes | - | Object which contains customer data |
| authID | String | yes | - | Required identifier of authorization |
| success | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Return Value:
No value is returned.
Check if a customer is signed in (via RaaS, OAuth, Facebook, Apple)
This method checks if a customer is signed in (via Synerise Authentication - RaaS, OAuth, Facebook, Apple).
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func isSignedIn() -> Bool
+ (BOOL)isSignedIn
Return Value:
true if the customer is signed in, otherwise returns false.
Example:
let isSignedIn: Bool = Client.isSignedIn()
BOOL isSignedIn = [SNRClient isSignedIn];
Check if a customer is signed in (via Simple Profile Authentication)
This method checks if a customer is signed in (via Simple Profile Authentication).
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 4.14.0 | 5.7.1 | 0.15.0 | 0.7.0 |
| Declared In: | ||||
| Headers/SNRClient.h |
Class:
Client
Declaration:
static func isSignedInViaSimpleAuthentication() -> Bool
+ (BOOL)isSignedInViaSimpleAuthentication
Return Value:
true if the customer is signed in (via Simple Profile Authentication), otherwise returns false.
Sign out customer
This method signs out a customer out.
This method works with every authentication type (via Synerise, External Provider, OAuth or Simple Profile Authentication).
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func signOut() -> Void
+ (void)signOut
Return Value:
No value is returned.
Example:
Client.signOut()
[SNRClient signOut];
Sign out customer with mode or from all devices
This method signs out a customer out with a chosen mode and Determines if the method should sign out all devices.
Available modes:
.signOutmode signs out the customer..signOutWithSessionDestroymode signs out the customer and additionally, clears the anonymous session and regenerates the customer UUID.
The fromAllDevices parameter determines whether the method should notify the backend to sign out all devices.
IMPORTANT: It is an asynchronous method.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 4.11.0 | 5.1.0 | 0.14.0 | 1.0.0 |
This method works with every authentication type (via Synerise, External Provider, OAuth or Simple Profile Authentication).
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func signOut(mode: ClientSignOutMode, fromAllDevices: Bool, success: ((Bool) -> Void), failure: ((ApiError) -> Void))
+ (void)signOutWithmode:(SNRClientSignOutMode)mode fromAllDevices:(BOOL)fromAllDevices success:(void (^)(void))success failure:(void (^)(SNRApiError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| mode | ClientSignOutMode | yes | - | Mode of signing out |
| fromAllDevices | Bool | yes | - | Determines if the method should sign out all devices |
| success | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
Return Value:
No value is returned.
Example:
Client.signOut(mode: .signOutWithSessionDestroy, fromAllDevices: true, success: {
// success
}) { (error) in
// failure
}
[SNRClient signOutWithMode:SNRClientSignOutModeSignOutWithSessionDestroy fromAllDevices:YES success:^{
// success
} failure:^(SNRApiError *error) {
// failure
}];
Removed methods
Authenticate customer by OAuth with registration
This method authenticates a customer with OAuth.
If an account for the customer does not exist, this request creates an account.
| Available on | iOS SDK | Android SDK | React Native SDK | Flutter SDK |
|---|---|---|---|---|
| Introduced in: | 3.6.11 | 3.6.13 | 0.9.12 | n/a |
| Deprecated in: | 3.7.6 | 3.8.0 | 0.9.19 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | n/a |
Returns the HTTP 401 status code if the provided access token and/or API Key is invalid.
Replaced By:
Authenticate customer by IdentityProvider
Declared In:
Headers/SNRClient.h
Related To:
ClientOAuthAuthenticationContext
Class:
Client
Declaration:
static func authenticateByOAuth(accessToken: String, authID: String?, context: ClientOAuthAuthenticationContext?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)authenticateByOAuthWithAccessToken:(NSString *)accessToken authID:(nullable NSString *)authID context:(nullable SNRClientOAuthAuthenticationContext *)context success:(nullable void (^)(BOOL isSuccess))success failure:(nullable void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| accessToken | String | yes | - | OAuth Access Token |
| authID | String | no | nil | Optional identifier of authorization |
| context | ClientOAuthAuthenticationContext | no | nil | Object which contains agreements and attributes |
| success | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Return Value:
No value is returned.
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
}
SNRClientAgreements *agreements = [SNRClientAgreements new];
agreements.email = true;
agreements.sms = true;
agreements.push = true;
agreements.bluetooth = true;
agreements.rfid = true;
agreements.wifi = true;
SNRClientOAuthContext *context = [SNRClientOAuthContext new];
context.agreements = agreements;
context.attributes = @{"attribute1": "value1", "attribute2": "value2"};
NSString *accessToken = @"ACCESS_TOKEN";
NSString *authID = @"AUTH_ID";
[SNRClient authenticateByOAuthWithAccessToken:accessToken authID:authID context:context success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Authenticate customer by OAuth without registration
This method authenticates a customer with OAuth.
| Available on | iOS SDK | Android SDK | React Native SDK | Flutter SDK |
|---|---|---|---|---|
| Introduced in: | 3.6.11 | 3.6.13 | 0.9.12 | n/a |
| Deprecated in: | 3.7.6 | 3.8.0 | 0.9.19 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | n/a |
Returns the HTTP 401 status code if the provided access token and/or API Key is invalid.
Replaced By:
Authenticate customer conditionally by IdentityProvider
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func authenticateByOAuthIfRegistered(accessToken: String, authID: String?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)authenticateByOAuthIfRegisteredWithAccessToken:(nonnull NSString *)accessToken authID:(nullable NSString *)authID success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| accessToken | String | yes | - | OAuth Access Token |
| authID | String | no | nil | Optional identifier of authorization |
| success | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Return Value:
No value is returned.
Authenticate customer by Facebook with registration
This method authenticates a customer with Facebook.
If an account for the customer does not exist, this request creates an account.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 3.3.8 | 3.3.0 | 0.9.7 | n/a |
| Deprecated in: | 3.7.6 | 3.8.0 | 0.9.19 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | n/a |
Returns the HTTP 401 status code if the provided Facebook token and/or API Key is invalid.
Replaced By:
Authenticate customer by IdentityProvider
Declared In:
Headers/SNRClient.h
Related To:
ClientFacebookAuthenticationContext
Class:
Client
Declaration:
static func authenticateByFacebook(facebookToken: String, authID: String?, context: ClientFacebookAuthenticationContext?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)authenticateByFacebookWithFacebookToken:(nonnull NSString *)facebookToken authID:(nullable NSString *)authID context:(nullable SNRClientFacebookAuthenticationContext *)context success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| facebookToken | String | yes | - | Facebook Access Token |
| authID | String | no | nil | Optional identifier of authorization |
| context | ClientFacebookAuthenticationContext | no | nil | Object which contains agreements and attributes |
| success | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Return Value:
No value is returned.
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
}
SNRClientAgreements *agreements = [SNRClientAgreements new];
agreements.email = true;
agreements.sms = true;
agreements.push = true;
agreements.bluetooth = true;
agreements.rfid = true;
agreements.wifi = true;
SNRClientFacebookAuthenticationContext *context = [SNRClientFacebookAuthenticationContext new];
context.agreements = agreements;
context.attributes = @{"attribute1": "value1", "attribute2": "value2"};
NSString *facebookToken = [FBSDKAccessToken currentAccessToken].tokenString;
NSString *authID = @"AUTH_ID";
[SNRClient authenticateByFacebookWithFacebookToken:facebookToken authID:authID context:context success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Authenticate customer by Facebook without registration
This method authenticates a customer with Facebook.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 3.3.8 | 3.3.0 | 0.9.7 | n/a |
| Deprecated in: | 3.7.6 | 3.8.0 | 0.9.19 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | n/a |
Returns the HTTP 401 status code if the provided Facebook token and/or API Key is invalid.
Replaced By:
Authenticate customer conditionally by IdentityProvider
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func authenticateByFacebookIfRegistered(facebookToken: String, authID: String?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)authenticateByFacebookIfRegisteredWithFacebookToken:(nonnull NSString *)facebookToken authID:(nullable NSString *)authID success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| facebookToken | String | yes | - | Facebook Access Token |
| authID | String | no | nil | Optional identifier of authorization |
| success | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Return Value:
No value is returned.
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
})
NSString *facebookToken = [FBSDKAccessToken currentAccessToken].tokenString;
NSString *authID = @"AUTH_ID";
[SNRClient authenticateByFacebookIfRegisteredWithFacebookToken:facebookToken authID:authID success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
Authenticate customer by Sign in with Apple with registration
This method authenticates a customer with Sign In With Apple.
If an account for the customer does not exist, this request creates an account.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 3.6.11 | n/a | 0.9.12 | n/a |
| Deprecated in: | 3.7.6 | n/a | 0.9.19 | n/a |
| Removed in: | 5.0.0 | n/a | 1.0.0 | n/a |
| Replaced By: | ||||
| Authenticate customer by IdentityProvider |
Declared In:
Headers/SNRClient.h
Related To:
ClientAppleSignInAuthenticationContext
Class:
Client
Declaration:
static func authenticateByAppleSignIn(identityToken: Data, authID: String?, context: ClientAppleSignInAuthenticationContext?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)authenticateByAppleSignInWithIdentityToken:(nonnull NSData *)identityToken authID:(nullable NSString *)authID context:(nullable SNRClientAppleSignInAuthenticationContext *)context success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| identityToken | Data | yes | - | Apple Identity Token |
| context | ClientAppleSignInAuthenticationContext | no | nil | Object which contains agreements and attributes |
| authID | String | no | nil | Optional identifier of authorization |
| success | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Return Value:
No value is returned.
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
}
}
}
}
#pragma mark - ASAuthorizationControllerDelegate
- (void)authorizationController:(ASAuthorizationController *)controller
didCompleteWithAuthorization:(ASAuthorization *)authorization {
id credential = authorization.credential;
if (credential != nil) {
SNRClientAgreements *agreements = [SNRClientAgreements new];
agreements.email = true;
agreements.sms = true;
agreements.push = true;
agreements.bluetooth = true;
agreements.rfid = true;
agreements.wifi = true;
SNRClientAppleSignInAuthenticationContext*context = [[SNRClientAppleSignInAuthenticationContext alloc] initWithIdentityToken:credential.identityToken];
context.agreements = agreements;
context.attributes = @{"attribute1": "value1", "attribute2": "value2"};
[SNRClient authenticateByAppleSignInWithContext:context authID:authID success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
}
}
Authenticate customer by Sign in with Apple without registration
This method authenticates a customer with Sign In With Apple.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 3.6.11 | 3.6.13 | 0.9.12 | n/a |
| Deprecated in: | 3.7.6 | 3.8.0 | 0.9.19 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | n/a |
| Replaced By: | ||||
| Authenticate customer conditionally by IdentityProvider |
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func authenticateByAppleSignInIfRegistered(identityToken: String, authID: String?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)authenticateByAppleSignInIfRegisteredWithIdentityToken:(nonnull NSData *)identityToken authID:(nullable NSString *)authID success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| identityToken | String | yes | - | Apple Identity Token |
| authID | String | no | nil | Optional identifier of authorization |
| success | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| failure | ((ApiError) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
authID parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Return Value:
No value is returned.
Sign out customer with mode
This method signs out a customer out with a chosen mode:
.signOutmode notifies the backend that the customer is signed out..signOutWithSessionDestroymode notifies the backend that the customer is signed out and additionally, clears the anonymous session and regenerates the customer UUID.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 4.4.0 | 4.6.0 | 0.12.0 | 0.7.0 |
| Deprecated in: | 4.11.0 | 5.1.0 | - | - |
| Removed in: | 5.0.0 | 6.0.0 | 0.14.0 | 1.0.0 |
This method works with every authentication type (via Synerise, External Provider, OAuth or Simple Profile Authentication).
Replaced By:
Sign out with mode or from all devices
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func signOut(mode: ClientSignOutMode) -> Void
+ (void)signOutWithmode:(SNRClientSignOutMode)mode
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| mode | ClientSignOutMode | yes | - | Mode of signing out |
Return Value:
No value is returned.
Example:
Client.signOut(mode: .signOutWithSessionDestroy)
[SNRClient signOutWithMode:SNRClientSignOutModeSignOutWithSessionDestroy];