Refresh customer token
This method refreshes the customer’s current token.
Returns an error if the token has expired and cannot be refreshed.
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func refreshToken(success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)refreshTokenWithSuccess:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| 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.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
})
[SNRClient refreshTokenWithSuccess:^() {
[SNRClient retrieveTokenWithSuccess:^(SNRToken *token) {
// success
NSString *tokenString = token.tokenString;
SNRTokenOrigin tokenOrigin = token.tokenOrigin;
} failure:^(SNRApiError *error) {
// failure
}];
} failure:^(SNRApiError *error) {
// failure
}];
Retrieve customer token
This method retrieves the customer’s current, active token.
Returns an error if the token has expired and cannot be retrieved.
Declared In:
Headers/SNRClient.h
Related To:
Token
Class:
Client
Declaration:
static func retrieveToken(success: ((Token) -> Void), failure: ((ApiError) -> Void)) -> Void
+ (void)retrieveTokenWithSuccess:(nonnull void (^)(SNRToken *token))success failure:(nonnull void (^)(NSError *error))failure
Parameters:
| Parameter | Type | Mandatory | Default | Description |
| success | ((Token) -> 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.retrieveToken(success: { (token) in
// success
let tokenString: String = token.tokenString
let tokenOrigin: TokenOrigin = token.tokenOrigin
}, failure: { (error) in
// failure
})
[SNRClient retrieveTokenWithSuccess:^(SNRToken *token) {
// success
NSString *tokenString = token.tokenString;
SNRTokenOrigin tokenOrigin = token.tokenOrigin;
} failure:^(SNRApiError *error) {
// failure
}];
Get current customer UUID
This method retrieves the customer’s current UUID.
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func getUUID() -> String
+ (NSString *)getUUID;
Return Value:
The method returns the customer's UUID as string.
Example:
let clientUUID: String = Client.getUUID()
NSString *clientUUID = [SNRClient getUUID];
Get customer UUID for use in authentication
This method retrieves the current UUID or generates a new one from a seed.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 4.15.0 | 5.15.0 | n/a | n/a |
This operation doesn't affect the customer session in the SDK.
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func getUUIDForAuthentication(authID: String) -> String
+ (NSString *)getUUIDForAuthenticationWithAuthID:(NSString *)authID
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| authID | String | yes | - | Seed for UUID generation |
Return Value:
The method returns the UUID for use in authentication as a string.
Example:
let clientUUID: String = Client.getUUIDForAuthentication(authID: "AUTH_ID")
NSString *clientUUID = [SNRClient getUUIDForAuthenticationWithAuthID:@"AUTH_ID"];
Regenerate customer
This method regenerates the UUID and clears the authentication token, login session, custom email, and custom identifier.
This operation works only if the customer is anonymous.
This operation clears the authentication token, login (if applicable), custom email, and custom identifier.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 3.3.10 | 3.3.5 | 0.9.0 | 0.7.0 |
| Declared In: | ||||
| Headers/SNRClient.h |
Class:
Client
Declaration:
static func regenerateUUID() -> Void
+ (void)regenerateUUID;
Return Value:
No value is returned.
Regenerate customer with identifier
This method regenerates the UUID and clears the authentication token, login session, custom email, and custom identifier.
This operation works only if the customer is anonymous.
This operation clears the authentication token, login (if applicable), custom email, and custom identifier
The optional clientIdentifier parameter is a seed for UUID generation.
| iOS SDK | Android SDK | React Native SDK | Flutter SDK | |
|---|---|---|---|---|
| Introduced in: | 3.6.5 | 3.6.4 | 0.9.10 | 0.7.2 |
| Declared In: | ||||
| Headers/SNRClient.h |
Class:
Client
Declaration:
static func regenerateUUID(clientIdentifier: String?) -> Void
+ (void)regenerateUUIDWithClientIdentifier:(NSString *)clientIdentifier;
Parameters:
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
| clientIdentifier | String | no | - | Seed for UUID generation |
The clientIdentifier parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Return Value:
No value is returned.
Destroy current session
This method destroys the session completely.
This method clears all session data (both client and anonymous) and removes cached data. Then, it regenerates the UUID and creates the new anonymous session.
Declared In:
Headers/SNRClient.h
Class:
Client
Declaration:
static func destroySession()
+ (void)destroySession
Return Value:
No value is returned.
Example:
Client.destroySession()
[SNRClient destroySession];