/Carthage/Build/iOS`
5. Drag `SyneriseSDK.framework` to **Embedded Binaries**.
6. Make sure the **Copy items if needed** option is selected.
7. Click **Finish**.
### Initialization
---
#### Setting up
1. Go to Xcode project target's **General** section.
2. Find the **Other Linker Flags** property and add the ***-ObjC*** flag.
2. If you are going to use push notifications:
1. Go to `Info.plist`
2. Add a row for **Required background mode** with the following array type value: `App downloads content in response to push notifications` or add the code below directly:
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
3. If you are going to use HTTP addresses (instead of only HTTPS), change the allowlist domains in your app by adding configuration to `Info.plist` in one of the following ways:
- Add configured domain/domains that you need.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourdomain.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
- Give permission for all domains.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
#### Importing Synerise SDK
Import the **Synerise SDK** header into the files that contain code relating to SDK.
Swift Objective-C
```Swift
import SyneriseSDK
```
```Objective-C
#import
```
In Objective-C, you can include it in your Prefix Header (PCH) and Synerise SDK will be imported to all files automatically.
#### Basic initialization
Initialize Synerise SDK and provide the [Profile API Key](/docs/settings/tool/api).
You may initialize it wherever you want and when you need.
Swift Objective-C
```Swift
Synerise.initialize(apiKey: "YOUR_PROFILE_API_KEY") // 1
Synerise.setDebugModeEnabled(false) // 2
Synerise.setCrashHandlingEnabled(true) // 3
Synerise.setDelegate(self) // 4
```
```Objective-C
[SNRSynerise initializeWithApiKey:@"YOUR_PROFILE_API_KEY"]; // 1
[SNRSynerise setDebugModeEnabled:NO]; // 2
[SNRSynerise setCrashHandlingEnabled:YES]; // 3
[SNRSynerise setDelegate:self]; // 4
```
Basic methods you need:
1. [`Synerise.initialize(apiKey:)`](/developers/mobile-sdk/method-reference/ios/lifecycle#initialization) - Initializes Synerise SDK.
2. [`Synerise.setDebugModeEnabled(_:)`](/developers/mobile-sdk/method-reference/ios/lifecycle#enable-debug-mode) - Enables debug mode for Synerise SDK. See [Debug mode](/developers/mobile-sdk/installation-and-configuration/ios#debug-mode) section for more information.
3. [`Synerise.setCrashHandlingEnabled(_:)`](/developers/mobile-sdk/method-reference/ios/lifecycle#enable-crash-handling) - Enables crash handling. Synerise SDK sends a crash event automatically when an uncaught exception occurs.
4. [`Synerise.setDelegate(_:)`](/developers/mobile-sdk/method-reference/ios/lifecycle#set-synerise-delegate)- Sets delegate to handle main actions from Synerise SDK. See [`SyneriseDelegate`](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#synerise-delegate) section for more information.
#### Initialization with custom API environment
To change API base URL for on-premise installations, use the following initialization method:
Swift Objective-C
```Swift
Synerise.initialize(apiKey: "YOUR_PROFILE_API_KEY", baseUrl: "YOUR_API_BASE_URL")
```
```Objective-C
[SNRSynerise initializeWithClientApiKey:@"YOUR_PROFILE_API_KEY" andBaseUrl:@"YOUR_API_BASE_URL"];
```
#### Advanced initialization
This is an example of advanced initialization with:
- custom API base URL for on-premise installations
- request validation salt configured
- debug mode enabled
- crash handling enabled
- most of the settings options available
- main delegate [`SyneriseDelegate`](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#synerise-delegate)
- client's state delegate [`ClientStateDelegate`](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#client-state-delegate)
We highly recommend to configure settings when Synerise SDK is initialized, before invoking the [`Synerise.initialize(apiKey:)`](/developers/mobile-sdk/method-reference/ios/lifecycle#initialization) method. See [Settings](/developers/mobile-sdk/settings) section for more details about settings options.
Secure sensitive keys (for example, `apiKey` and `requestValidationSalt`) with mechanisms like string obfuscation or encryption.
You can find more information about all [Synerise iOS SDK delegates here](/developers/mobile-sdk/listeners-and-delegates/ios-delegates).
Swift Objective-C
```Swift
Synerise.settings.sdk.enabled = true
Synerise.settings.sdk.appGroupIdentifier = "YOUR_APP_GROUP_IDENTIFIER"
Synerise.settings.sdk.keychainGroupIdentifier = "YOUR_KEYCHAIN_GROUP_IDENTIFIER"
Synerise.settings.sdk.minTokenRefreshInterval = 1800
Synerise.settings.sdk.shouldDestroySessionOnApiKeyChange = false
Synerise.settings.notifications.enabled = true
Synerise.settings.notifications.disableInAppAlerts = true
Synerise.settings.notifications.encryption = false
Synerise.settings.tracker.autotracking.enabled = true
Synerise.settings.tracker.autotracking.mode = AutoTrackMode.Fine
Synerise.settings.tracker.autotracking.excludedClasses = [SampleViewController.self]
Synerise.settings.tracker.autotracking.excludedViewTags = [0, 1, 2]
Synerise.settings.tracker.tracking.enabled = true
Synerise.settings.tracker.minBatchSize = 10
Synerise.settings.tracker.maxBatchSize = 100
Synerise.settings.tracker.autoFlushTimeout = 5.0
Synerise.settings.tracker.autoTracking.mode = .fine
Synerise.settings.tracker.locationAutomatic = true
Synerise.settings.injector.automatic = true
Synerise.initialize(apiKey: "YOUR_PROFILE_API_KEY", baseUrl: "YOUR_API_BASE_URL")
Synerise.setRequestValidationSalt("YOUR_REQUEST_VALIDATION_SALT")
Synerise.setDebugModeEnabled(false)
Synerise.setCrashHandlingEnabled(true)
Synerise.setDelegate(self)
Client.setClientStateDelegate(self)
```
```Objective-C
SNRSynerise.settings.sdk.enabled = @YES;
SNRSynerise.settings.sdk.appGroupIdentifier = @"YOUR_APP_GROUP_IDENTIFIER";
SNRSynerise.settings.sdk.keychainGroupIdentifier = @"YOUR_KEYCHAIN_GROUP_IDENTIFIER";
SNRSynerise.settings.sdk.minTokenRefreshInterval = 1800;
SNRSynerise.settings.sdk.shouldDestroySessionOnApiKeyChange = NO;
SNRSynerise.settings.notifications.enabled = YES;
SNRSynerise.settings.notifications.disableInAppAlerts = YES;
SNRSynerise.settings.notifications.encryption = NO;
SNRSynerise.settings.tracker.autotracking.enabled = YES;
SNRSynerise.settings.tracker.autotracking.mode = SNRTrackerAutoTrackModeFine;
SNRSynerise.settings.tracker.autotracking.excludedClasses = [SampleViewController.class];
SNRSynerise.settings.tracker.autotracking.excludedViewTags = [@0, @2, @3];
SNRSynerise.settings.tracker.tracking.enabled = YES;
SNRSynerise.settings.tracker.minBatchSize = 10;
SNRSynerise.settings.tracker.maxBatchSize = 100;
SNRSynerise.settings.tracker.autoFlushTimeout = 5.0;
SNRSynerise.settings.tracker.autoTracking.mode = SNRTrackerAutoTrackModeFine;
SNRSynerise.settings.tracker.locationAutomatic = YES;
SNRSynerise.settings.injector.automatic = YES;
[SNRSynerise initializeWithApiKey:@"YOUR_PROFILE_API_KEY" andBaseUrl:@"YOUR_API_BASE_URL"];
[SNRSynerise setRequestValidationSalt:@"YOUR_REQUEST_VALIDATION_SALT"];
[SNRSynerise setDebugModeEnabled:NO];
[SNRSynerise setCrashHandlingEnabled:YES];
[SNRSynerise setDelegate:self];
[SNRClient setClientStateDelegate:self];
```
#### Initialization process
During initialization, the library starts and when it is ready or an error occurs, the SDK notifies you.
When the delegate method is called, Synerise is ready to use.
Swift Objective-C
```Swift
// MARK: - SyneriseDelegate
// This method is called when the Synerise SDK is initialized.
func snr_initialized() {
//...
}
// This method is called when an error occurs while initializing the Synerise SDK.
func snr_initializationError(error: Error) {
//...
}
```
```Objective-C
#pragma mark - SNRSyneriseDelegate
// This method is called when the Synerise SDK is initialized.
- (void)SNR_initialized {
//...
}
// This method is called when an error occurs while initializing the Synerise SDK.
- (void)SNR_initializationError:(NSError *)error {
//...
}
```
### Debug Mode
---
You can enable debug logs for Synerise SDK by method [`Synerise.setDebugModeEnabled(_:)`](/developers/mobile-sdk/method-reference/ios/lifecycle#enable-debug-mode).
Do not use Debug Mode in a release version of your application.
Swift Objective-C
```Swift
Synerise.setDebugModeEnabled(true) // Enables logging for all modules
```
```Objective-C
[SNRSynerise setDebugModeEnabled:YES]; // Enables logging for all modules
```
You can receive some logs about:
- **Core**: push notifications
- **Tracker**: auto-tracked events, declarative events, sending process
- **Client**: customer state, authorization
- **Injector**: campaigns, UI
- **Promotions**: promotions, vouchers
- **Content**: content widget, documents, recommendations
### Background Tasks
---
[Background Tasks](https://developer.apple.com/documentation/backgroundtasks) is a mechanism to schedule and run code in the background to keep your app up to date.
Synerise supports using Background Tasks since SDK version **4.23.0**. You can pass configured identifiers for Synerise SDK by using the [`Synerise.setBackgroundTaskIdentifiers(_:)`](/developers/mobile-sdk/method-reference/ios/lifecycle#set-background-task-identifiers) method. The identifiers that you are going to pass have to be configured properly in the host app.
##### Benefits
Currently, the SDK uses Background Tasks only to refresh the registration token for Push Notifications every 20 days. In these situations, the SDK invokes the [snr_registerForPushNotificationsIsNeeded(origin:)](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#synerise-delegate-register-for-push-notifications-is-needed-by-origin) method or [snr_registerForPushNotificationsIsNeeded()](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#synerise-delegate-register-for-push-notifications-is-needed) method.
##### Setting up
To configure Background Tasks in your app:
1. Go to Xcode project's target's **Signing & Capabilities** section.
2. In the **Background Modes** capability (you may need to add it), enable **Background fetch** and **Background processing**.
3. Go to `Info.plist`.
4. Add a row with the following array type value: `Permitted background task scheduler identifiers`.
5. Add string identifiers, each as a separate item to declare possible Background Tasks identifiers in your app.
6. Pass these Background Tasks identifiers to SDK by using the [`Synerise.setBackgroundTaskIdentifiers(_:)`](/developers/mobile-sdk/method-reference/ios/lifecycle#set-background-task-identifiers) method. You must invoke the method **BEFORE** your app is launched (before the `application(_ application:didFinishLaunchingWithOptions launchOptions:)` method finishes).
Sample `\*.plist` configuration for Background Tasks:
Sample *.plist configuration for Background Tasks
Example code for passing Background Tasks identifiers to the SDK:
Swift Objective-C
```Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// ...
Synerise.setBackgroundTaskIdentifiers(["YOUR_BACKGROUND_TASK_IDENTIFIER"])
return true
}
```
```Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ...
[SNRSynerise setBackgroundTaskIdentifiers:@[@"YOUR_BACKGROUND_TASK_IDENTIFIER"]];
return YES;
}
```
The method's parameter is an array because of possible future purposes.
Do not use those identifiers for other Background Tasks in your app.
Documentation is available at [Apple Developer - Using background tasks to update your app](https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app).
**IMPORTANT: To configure Background Tasks properly, you must set `SyneriseDelegate` before the SDK initialization.**
Swift Objective-C
```Swift
Synerise.setDelegate(self)
Synerise.initialize(apiKey: "YOUR_PROFILE_API_KEY")
// ...
```
```Objective-C
[SNRSynerise setDelegate:self];
[SNRSynerise initializeWithApiKey:@"YOUR_PROFILE_API_KEY"];
// ...
```
### Privacy manifest
---
From **1 May 2024**, Apple requires you to add a privacy manifest. It's a file in your project that describes your reason and method for collecting data.
Third-party frameworks that track data should have a privacy manifest. When you create the application privacy report, these privacy manifest files are automatically aggregated into a single file.
Synerise supports privacy manifests since SDK version **4.17.0**. When you use an SDK version older than **4.17.0**, refer to the Synerise API usage requirements defined below when creating an Apple privacy manifest.
##### APIs usage
| API | Reason | Description |
| --- | --- | --- |
| User defaults APIs | **CA92.1** **1C8F.1** | Synerise uses User Defaults to persist the SDK data and share them between the application and extensions |
##### Tracking
Synerise does not track any data that is protected by the [App Tracking Transparency](https://developer.apple.com/documentation/apptrackingtransparency) framework.
##### Collected Data
| Data type | Value | Purpose |
| --- | --- | --- |
| User ID | **NSPrivacyCollectedDataTypeUserID** | Analytics, Product Personalization |
| Other usage data | **NSPrivacyCollectedDataTypeOtherUsageData** | Analytics, Product Personalization, App Functionality |
| Product interaction | **NSPrivacyCollectedDataTypeProductInteraction** | Analytics |
| Advertising data | **NSPrivacyCollectedDataTypeAdvertisingData** | Other Purposes, App Functionality |
| Crash data | **NSPrivacyCollectedDataTypeOtherUserContent** | Analytics |
### Warnings and limitations
---
Be careful with keychain deletion operations due to the possibility of deleting Synerise data. All the SDK library data keys are named `snr.[KEY_NAME]`.
# iOS
## Class reference - iOS
# iOS
## Configuring push notifications (iOS)
### Prerequisites
---
- Configure handling push notifications in your application. See [Apple Developer - Notifications](https://developer.apple.com/notifications/).
- Google Firebase Cloud Messaging is necessary to handle [Mobile Campaigns](/docs/campaign/Mobile) sent from Synerise.
1. Follow the instructions in [Firebase - Get Started on iOS](https://firebase.google.com/docs/storage/ios/start).
2. Integrate the Firebase with Synerise. See [Integration](/docs/settings/tool/firebase) section.
### Set up Firebase Cloud Messaging for Synerise SDK
---
Extend the Firebase Messaging Delegate so our SDK can receive the Firebase token that is required to deliver push notifications from Synerise:
Swift Objective-C
```Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Messaging.messaging().delegate = self
if #available(iOS 10, *) {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in
if granted {
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
guard let fcmToken = Messaging.messaging().fcmToken else {
return
}
let mobilePushAgreement = true // true or false, should depend on device permissions and customer's agreement in the application
Client.registerForPush(registrationToken:fcmToken, mobilePushAgreement:mobilePushAgreement, success: { (success) in
// success
}) { (error) in
// failure
}
}
} else {
let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
}
// MARK: - MessagingDelegate
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
if let registrationToken = fcmToken {
let mobilePushAgreement = true // true or false, should depend on device permissions and customer's agreement in the application
Client.registerForPush(registrationToken:registrationToken, mobilePushAgreement:mobilePushAgreement, success: { (success) in
// success
}) { (error) in
// failure
}
}
}
```
```Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
[FIRMessaging messaging].delegate = self;
if (@available(iOS 10, *)) {
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
UNAuthorizationOptions authOptions = (UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge);
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError *error) {
if (granted == YES) {
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
NSString *fcmToken = [FIRMessaging messaging].FCMToken;
if (fcmToken == nil) {
return;
}
BOOL mobilePushAgreement = YES; // YES or NO, should depend on device permissions and customer's agreement in the application
[SNRClient registerForPush:fcmToken mobilePushAgreement:mobilePushAgreement success:^(BOOL isSuccess) {
// success
} failure:^(NSError *error) {
// failure
}];
}];
} else {
UIUserNotificationType allNotificationTypes = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}
#pragma mark - FIRMessagingDelegate
- (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken {
if (fcmToken != nil) {
BOOL mobilePushAgreement = YES; // YES or NO, should depend on device permissions and customer's agreement in the application
[SNRClient registerForPush:fcmToken mobilePushAgreement:mobilePushAgreement success:^(BOOL isSuccess) {
// success
} failure:^(NSError *error) {
// failure
}];
}
}
```
The second parameter of the registration method is the agreement for mobile push campaigns. In the Profile's card in Synerise, you can find it in the **Subscriptions** section (if you have the required access permission). Learn more about the [Client.registerForPush(registrationToken:mobilePushAgreement:success:failure:) method in the method reference](/developers/mobile-sdk/method-reference/ios/campaigns#register-for-push-notifications).
### Keep Firebase token always up-to-date
---
You must always keep the Firebase token updated. In many cases in the application lifecycle, such as authorization, destroyed sessions, user context change, periodic jobs ([Background Tasks](/developers/mobile-sdk/installation-and-configuration/ios#background-tasks)), and so on, the registration needs to be updated. In these situations, the SDK invokes the [snr_registerForPushNotificationsIsNeeded(origin:)](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#synerise-delegate-register-for-push-notifications-is-needed-by-origin) method or [snr_registerForPushNotificationsIsNeeded()](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#synerise-delegate-register-for-push-notifications-is-needed) method.
[Background Tasks](/developers/mobile-sdk/installation-and-configuration/ios#background-tasks)) allows you to keep the Firebase token updated even if the host application is not launched for a long time. It launches your app in the background approximately every 20 days and refreshes the token so it stays up to date.
Swift Objective-C
```Swift
// MARK: - SyneriseDelegate
func snr_registerForPushNotificationsIsNeeded(origin: PushNotificationsRegistrationOrigin) -> Void {
guard let fcmToken = Messaging.messaging().fcmToken else {
return
}
let mobilePushAgreement = true // true or false, depending to customer's agreement in the application
Client.registerForPush(registrationToken:fcmToken, mobilePushAgreement:mobilePushAgreement, success: { (success) in
// success
}) { (error) in
// failure
}
}
```
```Objective-C
#pragma mark - SNRSyneriseDelegate
- (void)SNR_registerForPushNotificationsIsNeededByOrigin:(SNRPushNotificationsRegistrationOrigin)origin {
NSString *fcmToken = [FIRMessaging messaging].FCMToken;
if (fcmToken == nil) {
return;
}
BOOL mobilePushAgreement = YES; // YES or NO, depending to customer's agreement in the application
[SNRClient registerForPush:fcmToken mobilePushAgreement:mobilePushAgreement success:^(BOOL isSuccess) {
// success
} failure:^(NSError *error) {
// failure
}];
}
```
### Configure Notification Encryption
---
To enable encrypted push notifications, you must change the configuration of your workspace in the Synerise portal. See [Google Firebase](/docs/settings/tool/firebase).
iOS 10 or higher version is required for this feature.
Set your Keychain Group Identifier (see [this section](/developers/mobile-sdk/settings#set-up-keychain-group-identifier)) and enable `Synerise.settings.notifications.encryption` in SDK settings:
Swift Objective-C
```Swift
Synerise.settings.sdk.keychainGroupIdentifier = "YOUR_KEYCHAIN_GROUP_IDENTIFIER"
Synerise.settings.notifications.encryption = true
```
```Objective-C
SNRSynerise.settings.sdk.keychainGroupIdentifier = @"YOUR_KEYCHAIN_GROUP_IDENTIFIER";
SNRSynerise.settings.notifications.encryption = YES;
```
**Next:** Configure [Synerise Notification Service Extension](/developers/mobile-sdk/configuring-push-notifications/ios#synerise-notification-service-extension).
### Synerise Notification Service Extension {id=synerise-notification-service-extension}
---
**Synerise Notification Service Extension** is an object that adds the notification functionality to the SDK. It works by implementing the [`UNNotificationServiceExtension`](https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension) that cooperates with the host application.
The Synerise Notification Service Extension facilitates some operations by automating them. This means a one-time implementation provides new functionalities, changes, and fixes, along with new versions of the SDK.
It implements the following operations:
- Decrypting **Simple Push** communication data (if encryption is enabled).
- Tracking events from **Simple Push** communication (e.g. `push.view`).
- Tracking `push.dismiss` when the notification is cleared from the notification center.
- Adding action buttons to **Simple Push** communication (if the communication contains any).
- Improving the appearance of **Simple Push** communication (Rich Media - Single Image) with an image thumbnail.
From version 4.24.0, the SDK started tracking `push.dismiss` events when clearing from the notification center. You can enable tracking this event by setting **kSNRNotificationServiceExtensionOptionsPushDismissProcessing** to true ([see implementation below](/developers/mobile-sdk/configuring-push-notifications/ios#synerise-notification-service-extension-implementation)). If you enable this option, it can cause a noticeable amount of generated events.
#### Configuration {id=synerise-notification-service-extension-configuration}
1. Configure **App Group Identifier** (see [this section](/developers/mobile-sdk/settings#set-up-app-group-identifier)).
2. Configure **Keychain Group Identifier** (see [this section](/developers/mobile-sdk/settings#set-up-keychain-group-identifier)).
3. Add the **Notification Service Extension** to your iOS project ([Apple Developer - UNNotificationServiceExtension](https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension)).
4. Configure the SDK both in the host application and in the notification service extension.
- Configuring **App Group Identifier** and **Keychain Group Identifier** both in the host application and in the notification service extension is required for proper functioning of all **Notification Service Extension** features.
- Your host application and the **Notification Service Extension** must have the same **iOS Deployment Target** version (newer than iOS 10).
- If you want to enable processing the campaign by **Notification Service Extension**, select the [Mutable-Content](/developers/mobile-sdk/configuring-push-notifications/ios#mutable-content-parameter) option.
#### Implementation {id=synerise-notification-service-extension-implementation}
Swift Objective-C
```Swift
import UserNotifications
import SyneriseSDK
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = self.bestAttemptContent {
Synerise.settings.sdk.appGroupIdentifier = "YOUR_APP_GROUP_IDENTIFIER"
Synerise.settings.sdk.keychainGroupIdentifier = "YOUR_KEYCHAIN_GROUP_IDENTIFIER"
NotificationServiceExtension.setDelegate(self)
NotificationServiceExtension.setNotificationDelegate(self)
#if DEBUG
NotificationServiceExtension.setDebugModeEnabled(true)
#endif
NotificationServiceExtension.setDecryptionFallbackNotificationTitleAndBody(title: "(Encrypted))", body: "(Encrypted)")
NotificationServiceExtension.didReceiveNotificationExtensionRequest(request, withMutableNotificationContent: bestAttemptContent, options: [
kSNRNotificationServiceExtensionOptionsPushDismissProcessing: true
])
contentHandler(bestAttemptContent)
}
}
override func serviceExtensionTimeWillExpire() {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler = self.contentHandler, let bestAttemptContent = self.bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
}
extension NotificationService: NotificationServiceExtensionDelegate {
func notificationServiceExtensionDidFailProcessingWithError(_ error: Error) {
#if DEBUG
self.bestAttemptContent?.title = error.localizedDescription
#endif
}
func notificationServiceExtensionDidFailDecryptionWithError(_ error: Error) {
#if DEBUG
self.bestAttemptContent?.title = error.localizedDescription
#endif
}
}
extension NotificationService: NotificationDelegate {
// This method is called when a Synerise notification is received.
func snr_notificationDidReceive(notificationInfo: NotificationInfo) {
//...
}
}
```
```Objective-C
#import "NotificationService.h"
#import
#import
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
SNRSynerise.settings.sdk.appGroupIdentifier = @"YOUR_APP_GROUP_IDENTIFIER";
SNRSynerise.settings.sdk.keychainGroupIdentifier = @"YOUR_KEYCHAIN_GROUP_IDENTIFIER";
[SNRNotificationServiceExtension setDelegate:self];
[SNRNotificationServiceExtension setNotificationDelegate:self];
#ifdef DEBUG
[SNRNotificationServiceExtension setDebugModeEnabled:YES];
#endif
[SNRNotificationServiceExtension setDecryptionFallbackNotificationTitle:@"(Encrypted)" andBody:@"(Encrypted)"];
[SNRNotificationServiceExtension didReceiveNotificationExtensionRequest:request withMutableNotificationContent:self.bestAttemptContent options:@{
kSNRNotificationServiceExtensionOptionsPushDismissProcessing: @(YES) // if true, tracking `push.dismiss` by clearing from the notification center is enabled
}];
self.contentHandler(self.bestAttemptContent);
}
- (void)serviceExtensionTimeWillExpire {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
self.contentHandler(self.bestAttemptContent);
}
#pragma mark - SNRNotificationServiceExtensionDelegate
- (void)notificationServiceExtensionDidFailProcessingWithError:(NSError *)error {
#ifdef DEBUG
self.bestAttemptContent.body = error.localizedDescription;
#endif
}
- (void)notificationServiceExtensionDidFailDecryptionWithError:(NSError *)error {
#ifdef DEBUG
self.bestAttemptContent.body = error.localizedDescription;
#endif
}
#pragma mark - SNRNotificationDelegate
// This method is called when a Synerise notification is received.
- (void)SNR_notificationDidReceive:(SNRNotificationInfo *)notificationInfo {
//...
}
@end
```
Examples of Notification Service Extensions:
- [Notification Service Extension in Swift](https://github.com/Synerise/synerise-ios-sdk/tree/master/SampleAppSwift/4.10.0/SyneriseNotificationServiceExtension)
- [Notification Service Extension in Objective-C](https://github.com/Synerise/synerise-ios-sdk/tree/master/SampleAppSwift/4.10.0/SyneriseNotificationServiceExtensionObjC)
#### Debug Mode {id=synerise-notification-service-extension-debug-mode}
You can enable the debug mode for Notification Service Extension logging and testing purposes.
Do not use the debug mode in a release version of your application.
Swift Objective-C
```Swift
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
//...
NotificationServiceExtension.setDebugModeEnabled(true)
//...
}
```
```Objective-C
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
//...
[SNRNotificationServiceExtension setDebugModeEnabled:YES];
//...
}
```
In the debug mode, decryption process is considered successful even if it fails. Your best attempt content (`UNNotificationContent` object) is modified - the notification displays the title and body with the problem that occurred during decryption. It may help you debug and find problems with the configuration.
### Handling incoming push notifications
---
You may disable handling push notifications in the SDK at any time. See [Enable/disable notifications](/developers/mobile-sdk/settings#enabledisable-notifications).
Documentation on how to prepare push notifications in [app.synerise.com](https://app.synerise.com) is available in our [user guide](/docs/campaign/Mobile).
In order to handle Synerise push notifications, you must pass the incoming push payload to the Synerise SDK.
#### Synerise payload
The following code shows how to handle push notifications in the `AppDelegate`:
Swift Objective-C
```Swift
// Support for Push Notifications on iOS 9
// Support for Silent Notifications
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
let isSyneriseNotification: Bool = Synerise.isSyneriseNotification(userInfo)
if isSyneriseNotification {
Synerise.handleNotification(userInfo)
completionHandler(.noData)
}
}
func application(_ application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [AnyHashable : Any], completionHandler: @escaping () -> Void) {
let isSyneriseNotification: Bool = Synerise.isSyneriseNotification(userInfo)
if isSyneriseNotification {
Synerise.handleNotification(userInfo, actionIdentifier: identifier)
completionHandler()
}
}
// Support for Push Notifications on iOS 10 and above
// MARK: - UNUserNotificationCenterDelegate
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
let isSyneriseNotification: Bool = Synerise.isSyneriseNotification(userInfo)
if isSyneriseNotification {
Synerise.handleNotification(userInfo, actionIdentifier: response.actionIdentifier)
completionHandler()
}
}
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
let isSyneriseNotification: Bool = Synerise.isSyneriseNotification(userInfo)
if isSyneriseNotification {
Synerise.handleNotification(userInfo)
completionHandler(UNNotificationPresentationOptions.init(rawValue: 0))
}
}
```
```Objective-C
// Support for Push Notifications on iOS 9
// Support for Silent Notifications
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
BOOL isSyneriseNotification = [SNRSynerise isSyneriseNotification:userInfo];
if (isSyneriseNotification) {
[SNRSynerise handleNotification:userInfo];
completionHandler(UIBackgroundFetchResultNoData);
}
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler {
BOOL isSyneriseNotification = [SNRSynerise isSyneriseNotification:userInfo];
if (isSyneriseNotification) {
[SNRSynerise handleNotification:userInfo actionIdentifier:identifier];
completionHandler();
}
}
// Support for Push Notifications on iOS 10 and above
// pragma mark - UNUserNotificationCenterDelegate
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler NS_AVAILABLE_IOS(10) {
NSDictionary *userInfo = response.notification.request.content.userInfo;
BOOL isSyneriseNotification = [SNRSynerise isSyneriseNotification:userInfo];
if (isSyneriseNotification) {
[SNRSynerise handleNotification:userInfo actionIdentifier:response.actionIdentifier];
completionHandler();
}
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler NS_AVAILABLE_IOS(10) {
NSDictionary *userInfo = notification.request.content.userInfo;
BOOL isSyneriseNotification = [SNRSynerise isSyneriseNotification:userInfo];
if (isSyneriseNotification) {
[SNRSynerise handleNotification:userInfo];
completionHandler(UNNotificationPresentationOptionNone);
}
}
```
All of these methods must be implemented to ensure proper handling of push notifications.
Displaying the notification banner on top of the screen in foreground state depends on values passed in `completionHandler` in the [UNUserNotificationCenterDelegate.userNotificationCenter(_:willPresent:completionHandler:)](https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter) method.
#### Custom payload
You may send both custom push notifications and custom campaigns in [Synerise](https://app.synerise.com). The code below of one sample delegate method checks if the notification origin and then handles it.
Swift Objective-C
```Swift
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
let isSyneriseNotification: Bool = Synerise.isSyneriseNotification(userInfo)
if isSyneriseNotification {
Synerise.handleNotification(userInfo)
completionHandler(UNNotificationPresentationOptions.init(rawValue: 0))
} else {
// Handle other notification in your own way
}
}
```
```Objective-C
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler NS_AVAILABLE_IOS(10) {
NSDictionary *userInfo = notification.request.content.userInfo;
BOOL isSyneriseNotification = [SNRSynerise isSyneriseNotification:userInfo];
if (isSyneriseNotification) {
[SNRSynerise handleNotification:userInfo];
completionHandler(UNNotificationPresentationOptionNone);
} else {
// Handle other notification in your own way
}
}
```
#### Encrypted payloads
If you handle the Synerise push notification, you do not have to do anything. The SDK decrypts Synerise push notification's payload:
- In [Notification Service Extension](#synerise-notification-service-extension) for push notifications
- In the SDK, after invoking [`Synerise.handleNotification(_:)`](/developers/mobile-sdk/method-reference/ios/campaigns#handle-synerise-push-notification) for silent push notifications
Otherwise, if it is a custom encrypted push notification sent by Synerise, or you need decrypt data from the push notification, there are two methods for dealing with them:
- [`Synerise.isNotificationEncrypted(_:)`](/developers/mobile-sdk/method-reference/ios/campaigns#check-if-push-notification-is-encrypted) - checks if the notification payload is encrypted by Synerise.
- [`Synerise.decryptNotification(_:)`](/developers/mobile-sdk/method-reference/ios/campaigns#decrypt-push-notification) - decrypts a notification payload.
Swift Objective-C
```Swift
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
let isSyneriseNotification: Bool = Synerise.isSyneriseNotification(userInfo)
if isSyneriseNotification {
let isNotificationEncrypted: Bool = Synerise.isNotificationEncrypted(userInfo)
if isNotificationEncrypted == true {
if let userInfoDecrypted = Synerise.decryptNotification(userInfo) {
// Handle decrypted payload in your own way
}
Synerise.handleNotification(userInfo)
completionHandler(UNNotificationPresentationOptions.init(rawValue: 0))
}
}
```
```Objective-C
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler NS_AVAILABLE_IOS(10) {
NSDictionary *userInfo = notification.request.content.userInfo;
BOOL isSyneriseNotification = [SNRSynerise isSyneriseNotification:userInfo];
if (isSyneriseNotification) {
BOOL isNotificationEncrypted = [SNRSynerise isNotificationEncrypted:userInfo];
if (isNotificationEncrypted == YES) {
NSDictionary *userInfoDecrypted = [SNRSynerise decryptNotification:userInfo];
if (userInfoDecrypted != nil) {
// Handle decrypted payload in your own way
}
[SNRSynerise handleNotification:userInfo];
completionHandler(UNNotificationPresentationOptionNone);
}
}
```
Remember, if you want to send custom push notifications by Synerise (and it is not a silent push notification), you must implement the code in your [Notification Service Extension](/developers/mobile-sdk/configuring-push-notifications/ios#synerise-notification-service-extension):
Swift Objective-C
```Swift
import UserNotifications
import SyneriseSDK
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = self.bestAttemptContent {
var userInfo = notification.request.content.userInfo
let isSyneriseNotification: Bool = Synerise.isSyneriseNotification(userInfo)
if isSyneriseNotification == true {
//...
} else {
let isNotificationEncrypted: Bool = Synerise.isNotificationEncrypted(userInfo)
if isNotificationEncrypted == true {
if let userInfoDecrypted = Synerise.decryptNotification(userInfo) {
bestAttemptContent.title = userInfoDecrypted["aps"]?["alert"]?["title"]
bestAttemptContent.body = userInfoDecrypted["aps"]?["alert"]?["body"]
bestAttemptContent.userInfo = userInfoDecrypted;
} else {
bestAttemptContent.title = "YOUR_FALLBACK_TITLE"
bestAttemptContent.body = "YOUR_FALLBACK_BODY"
}
}
}
contentHandler(bestAttemptContent)
}
}
}
```
```Objective-C
#import "NotificationService.h"
#import
#import
@interface NotificationService ()
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
NSDictionary *userInfo = notification.request.content.userInfo;
BOOL isSyneriseNotification = [SNRSynerise isSyneriseNotification:userInfo];
if (isSyneriseNotification == YES) {
//...
} else {
BOOL isNotificationEncrypted = [SNRSynerise isNotificationEncrypted:userInfo];
if (isNotificationEncrypted == YES) {
NSDictionary *userInfoDecrypted = [SNRSynerise decryptNotification:userInfo];
if (userInfoDecrypted != nil) {
bestAttemptContent.title = userInfoDecrypted[@"aps"][@"alert"][@"title"];
bestAttemptContent.body = userInfoDecrypted[@"aps"][@"alert"][@"body"];
bestAttemptContent.userInfo = userInfoDecrypted;
} else {
bestAttemptContent.title = "YOUR_FALLBACK_TITLE"
bestAttemptContent.body = "YOUR_FALLBACK_BODY"
}
}
}
self.contentHandler(self.bestAttemptContent);
}
@end
```
#### 'Content-Available' parameter
If you want to receive push notification in the background and foreground states, enable the `Content-Available` option while creating a push notification in Synerise ([Creating mobile push templates](/docs/campaign/Mobile/creating-mobile-push-templates/mobile-push-visual-builder)).
Enabled `Content-Available` option in a visual builder
When you want support this option, you must add the capability to your application. In the **Signing and Capability** tab, in the **Background Modes** capability, select the **Remote notifications** checkbox:
Remote notifications capability in the Xcode
Your application will be notified of the notification delivery when it's in the foreground or background (the app will be woken up). This ensures that the necessary method and code responsible for receiving background notifications are executed. On iOS, it calls your app delegate’s [application(_:didReceiveRemoteNotification:fetchCompletionHandler:)](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623013-application) method. On watchOS, it calls your extension delegate’s [didReceiveRemoteNotification(_:fetchCompletionHandler:)](https://developer.apple.com/documentation/watchkit/wkextensiondelegate/3152235-didreceiveremotenotification) method.
For more details, see [Apple Developer - Pushing Background Updates to Your App](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app).
#### 'Mutable-Content' parameter
If you want your notification to be processed by the Notification Service Extension, enable the `Mutable-Content` option while creating a push notification in Synerise ([Creating mobile push templates](/docs/campaign/Mobile/creating-mobile-push-templates/mobile-push-visual-builder)).
Enabled `Mutable-Content` option in a visual builder
If you want to have full support for **Simple Push** communication, and to make `Mutable-Content` relevant and functional, you must configure [Synerise Notification Service Extension](/developers/mobile-sdk/configuring-push-notifications/ios#synerise-notification-service-extension). This extension is required to fully support Simple Push communication for iOS, such as gathering the view events.
For more details, see [Apple Developer - Modifying content in newly delivered notifications](https://developer.apple.com/documentation/usernotifications/modifying-content-in-newly-delivered-notifications).
#### Delegate methods
[NotificationDelegate](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#notification-delegate) is available from SDK version 4.10.0.
A [NotificationDelegate](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#notification-delegate) handles events from Synerise notifications.
- To handle "receive" events when an application is disabled or in background state: set the delegate in the notification service extension by using the `NotificationServiceExtension.setNotificationDelegate(_:)` method. See [this section](/developers/mobile-sdk/configuring-push-notifications/ios#synerise-notification-service-extension-implementation) to get a sample code for the notification service extension.
- **SDK version 4.14.3 or newer:** To handle "receive" events when an application is launched by the notification or in foreground state: set the delegate in the application by using the `Synerise.setNotificationDelegate(_:)` method.
- To handle "dismiss" and "click" events: set the delegate in the application by using the `Synerise.setNotificationDelegate(_:)` method.
See a sample code from the application below:
Swift Objective-C
```Swift
extension SyneriseManager: NotificationDelegate {
// This method is called when a Synerise notification is received.
func snr_notificationDidReceive(notificationInfo: NotificationInfo) {
//...
}
// This method is called when a Synerise notification is dismissed.
func snr_notificationDidDissmis(notificationInfo: NotificationInfo) {
//...
}
// This method is called when a Synerise notification is clicked.
func snr_notificationClicked(notificationInfo: NotificationInfo) {
//...
}
// This method is called when an action button is clicked in a Synerise notification.
func snr_notificationClicked(notificationInfo: NotificationInfo, actionButton: String) {
//...
}
}
```
```Objective-C
#pragma mark - SNRNotificationDelegate
// This method is called when a Synerise notification is received.
- (void)SNR_notificationDidReceive:(SNRNotificationInfo *)notificationInfo {
//...
}
// This method is called when a Synerise notification is dismissed.
- (void)SNR_notificationDidDissmis:(SNRNotificationInfo *)notificationInfo {
//...
}
// This method is called when a Synerise notification is clicked.
- (void)SNR_notificationClicked:(SNRNotificationInfo *)notificationInfo {
//...
}
// This method is called when an action button is clicked in a Synerise notification.
- (void)SNR_notificationActionButtonClicked:(SNRNotificationInfo *)notificationInfo actionButton:(NSString *)actionButton {
//...
}
```
### Handling actions from push notifications
---
- [Read more about types of actions in campaigns](/developers/mobile-sdk/campaigns/action-handling#types-of-actions-in-campaigns)
- [Read more about handling actions from push notifications](/developers/mobile-sdk/campaigns/action-handling#handling-actions-from-campaigns-in-ios)
### Additional in-app alert from push notifications
---
The iOS SDK can display an additional alert in the application after a push notification is received. See [this article](/developers/mobile-sdk/campaigns/simple-push#additional-in-app-alert-when-simple-push-is-received) to read more about this feature.
Simple Push campaign with in-app alert
### Rich Media in push notifications
---
**Notification Content Extension** is an object that allows rendering your own appearance of a push notification when the notification is expanded (by tapping the notification). It works by implementing the UNNotificationContentExtension that cooperates with the host application.
Synerise SDK does most of the work needed and provides classes for the Notification Content Extensions. When you create an extension, you only need to make it inherit from a suitable Synerise SDK class.
#### Prerequisites {id=rich-media-in-push-notifications-prerequisites}
1. Configure **App Group Identifier** (see [this section](/developers/mobile-sdk/settings#set-up-app-group-identifier)).
2. Configure **Keychain Group Identifier** (see [this section](/developers/mobile-sdk/settings#set-up-keychain-group-identifier)).
#### Configuration {id=rich-media-in-push-notifications-configuration}
To add this feature in your [Simple Push Campaigns](/developers/mobile-sdk/campaigns/simple-push), you must:
1. Add the **Notification Content Extensions** in your iOS project - separately for each type of our Rich Media extensions.
2. Configure the host application and the notification content extensions with the SDK.
- Configuring **App Group Identifier** and **Keychain Group Identifier** both in the host application and in the notification service extension is required for proper functioning of all **Notification Content Extensions** features.
- Your host application and all the **Notification Content Extensions** must have the same **iOS Deployment Target** version (higher than iOS 10).
#### Application implementation {id=rich-media-in-push-notifications-application-implementation}
You must create push notification categories with the right identifiers, correlating with **Content Extensions** that you added before. The identifiers must be taken from the Synerise SDK constants (they are used in the code sample below). This does not affect button names.
Swift Objective-C
```Swift
Synerise.settings.sdk.appGroupIdentifier = "YOUR_APP_GROUP_IDENTIFIER"
Synerise.settings.sdk.keychainGroupIdentifier = "YOUR_KEYCHAIN_GROUP_IDENTIFIER"
let singleMediaCategory = UNNotificationCategory(identifier: SNRSingleMediaContentExtensionViewControllerCategoryIdentifier, actions: [], intentIdentifiers: [], options: [])
let carouselPrevious = UNNotificationAction(identifier: SNRCarouselContentExtensionViewControllerPreviousItemIdentifier, title: "Previous", options: [])
let carouselAction = UNNotificationAction(identifier: SNRCarouselContentExtensionViewControllerChooseItemIdentifier, title: "Go!", options: UNNotificationActionOptions.foreground)
let carouselNext = UNNotificationAction(identifier: SNRCarouselContentExtensionViewControllerNextItemIdentifier, title: "Next", options: [])
let carouselCategory = UNNotificationCategory(identifier: SNRCarouselContentExtensionViewControllerCategoryIdentifier, actions: [carouselPrevious, carouselAction, carouselNext], intentIdentifiers: [], options: [])
// Use this method when you use SDK 4.21.0 or higher
Synerise.setNotificationCategories([singleMediaCategory, carouselCategory])
// or
// Use this method when you use SDK lower than 4.21.0
UNUserNotificationCenter.current().setNotificationCategories([singleMediaCategory, carouselCategory])
```
```Objective-C
SNRSynerise.settings.notifications.appGroupIdentifier = @"YOUR_APP_GROUP_IDENTIFIER";
SNRSynerise.settings.sdk.keychainGroupIdentifier = @"YOUR_KEYCHAIN_GROUP_IDENTIFIER";
UNNotificationCategory *singleMediaCategory = [UNNotificationCategory categoryWithIdentifier:SNRSingleMediaContentExtensionViewControllerCategoryIdentifier actions:@[] intentIdentifiers:@[] options:0];
UNNotificationAction *carouselPreviousAction = [UNNotificationAction actionWithIdentifier:SNRCarouselContentExtensionViewControllerPreviousItemIdentifier title:@"Previous" options:0];
UNNotificationAction *carouselGoAction = [UNNotificationAction actionWithIdentifier:SNRCarouselContentExtensionViewControllerChooseItemIdentifier title:@"Go" options:0];
UNNotificationAction *carouselNextAction = [UNNotificationAction actionWithIdentifier:SNRCarouselContentExtensionViewControllerNextItemIdentifier title:@"Next" options:0];
UNNotificationCategory *carouselCategory = [UNNotificationCategory categoryWithIdentifier:SNRCarouselContentExtensionViewControllerCategoryIdentifier actions:@[carouselPreviousAction, carouselGoAction, carouselNextAction] intentIdentifiers:@[] options:0];
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObjects:singleMediaCategory, carouselCategory, nil]];
```
| Method | Description |
| --- | --- |
| [`Synerise.setNotificationCategories(_:)`](/developers/mobile-sdk/method-reference/ios/campaigns#set-notification-categories) | Sets the notification categories (including Synerise categories) that your app supports. Use this method when you use SDK 4.21.0 or higher. |
| [`UNUserNotificationCenter.current().setNotificationCategories(_:)`](https://developer.apple.com/documentation/usernotifications/unusernotificationcenter/setnotificationcategories(_:)) | Sets the notification categories by using the standard iOS SDK method. Use this method when you use SDK lower than 4.21.0. |
#### Single Media implementation {id=rich-media-in-push-notifications-single-media-implementation}
Swift Objective-C
```Swift
import UIKit
import UserNotifications
import UserNotificationsUI
import SyneriseSDK
class NotificationViewController: SingleMediaContentExtensionViewController, UNNotificationContentExtension {
func didReceive(_ notification: UNNotification) {
Synerise.settings.sdk.appGroupIdentifier = "YOUR_APP_GROUP_IDENTIFIER"
Synerise.settings.sdk.keychainGroupIdentifier = "YOUR_KEYCHAIN_GROUP_IDENTIFIER"
self.contentViewIsScrollable = false
self.imageContentMode = .scaleAspectFit
setSyneriseNotification(notification)
}
func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) {
setSyneriseNotificationResponse(response, completionHandler: completion)
}
}
```
```Objective-C
#import
#import
#import
#import
@interface SingleMediaNotificationViewController : SNRSingleMediaContentExtensionViewController
@end
#import "SingleMediaNotificationViewController.h"
@implementation SingleMediaNotificationViewController
- (void)didReceiveNotification:(UNNotification *)notification {
SNRSynerise.settings.notifications.appGroupIdentifier = @"YOUR_APP_GROUP_IDENTIFIER";
SNRSynerise.settings.sdk.keychainGroupIdentifier = @"YOUR_KEYCHAIN_GROUP_IDENTIFIER";
self.contentViewIsScrollable = NO;
self.imageContentMode = UIViewContentModeScaleAspectFit;
[self setSyneriseNotification:notification];
}
- (void)didReceiveNotificationResponse:(UNNotificationResponse *)response completionHandler:(void (^)(UNNotificationContentExtensionResponseOption))completion {
[self setSyneriseNotificationResponse:response completionHandler:completion];
}
@end
```
##### Properties {id=rich-media-in-push-notifications-single-media-properties}
| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| contentViewIsScrollable | `Bool` | true | This parameter specifies if vertical scroll is enabled. If false, content is adjusted to the screen height. |
| imageContentMode | `UIViewContentMode` | `UIViewContentModeScaleAspectFill` | This parameter sets the rendering mode of an image |
##### Info.plist {id=rich-media-in-push-notifications-single-media-info-plist}
The configuration for your **Content Extension** in `\*.plist` file must be:
- correlated with Synerise SDK constants for notification category
*NSExtension->NSExtensionAttributes->UNNotificationExtensionCategory->0* must be **synerise.notifications.category.single-media**.
- configured without a storyboard (by, default a storyboard is set).
*NSExtensionMainStoryboard* key and its values must be removed from `\*.plist` file.
- correlated with the principal class
*NSextensionPrincipalClass* key must have value with the name of the main class for the notification extension you have created. For **Content Extension** written in Swift, the prefix `$(PRODUCT_MODULE_NAME).` is required. For Objective-C, it is not.
Example `\*.plist` file for single media:
Sample *.plist configuration in Single Image Notification Content Extension
##### Example {id=rich-media-in-push-notifications-single-media-example}
Examples of Single Media Notification Content Extension:
- [Single Media Notification Content Extension in Swift](https://github.com/Synerise/synerise-ios-sdk/tree/master/SampleAppSwift/4.10.0/SyneriseSingleMediaNotificationContentExtension)
- [Single Media Notification Content Extension in Objective-C](https://github.com/Synerise/synerise-ios-sdk/tree/master/SampleAppSwift/4.10.0/SyneriseSingleMediaNotificationContentExtensionObjC)
#### Carousel implementation {id=rich-media-in-push-notifications-carousel-implementation}
Swift Objective-C
```Swift
import UIKit
import UserNotifications
import UserNotificationsUI
import SyneriseSDK
class NotificationViewController: CarouselContentExtensionViewController, UNNotificationContentExtension {
func didReceive(_ notification: UNNotification) {
Synerise.settings.sdk.appGroupIdentifier = "YOUR_APP_GROUP_IDENTIFIER"
Synerise.settings.sdk.keychainGroupIdentifier = "YOUR_KEYCHAIN_GROUP_IDENTIFIER"
self.imageContentMode = .scaleAspectFit
setSyneriseNotification(notification)
}
func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) {
setSyneriseNotificationResponse(response, completionHandler: completion)
}
}
```
```Objective-C
#import
#import
#import
#import
@interface CarouselNotificationViewController : SNRCarouselContentExtensionViewController
@end
#import "CarouselNotificationViewController.h"
@implementation CarouselNotificationViewController
- (void)didReceiveNotification:(UNNotification *)notification {
SNRSynerise.settings.notifications.appGroupIdentifier = @"YOUR_APP_GROUP_IDENTIFIER";
SNRSynerise.settings.sdk.keychainGroupIdentifier = @"YOUR_KEYCHAIN_GROUP_IDENTIFIER";
[self setSyneriseNotification:notification];
}
- (void)didReceiveNotificationResponse:(UNNotificationResponse *)response completionHandler:(void (^)(UNNotificationContentExtensionResponseOption))completion {
[self setSyneriseNotificationResponse:response completionHandler:completion];
}
@end
```
##### Properties {id=rich-media-in-push-notifications-carousel-properties}
| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| imageContentMode | `UIViewContentMode` | `UIViewContentModeScaleAspectFill` | This parameter sets the rendering mode of images |
##### Info.plist {id=rich-media-in-push-notifications-carousel-info-plist}
The configuration for your **Content Extension** in `\*.plist` file must be:
- correlated with Synerise SDK constants for notification category.
*NSExtension->NSExtensionAttributes->UNNotificationExtensionCategory->0* must be **synerise.notifications.category.carousel**.
- configured without storyboard (it is set by default).
*NSExtensionMainStoryboard* key and its values must be removed from `\*.plist` file.
- correlated with the principal class.
*NSextensionPrincipalClass* key must have value with name of your main class for the notification extension you have created. For **Content Extension** written in Swift, the prefix `$(PRODUCT_MODULE_NAME).` is required. For Objective-C, it is not.
See proper `\*.plist` file example for single media below:
Sample *.plist configuration in Carousel Notification Content Extension
##### Example {id=rich-media-in-push-notifications-carousel-example}
Examples of Carousel Notification Content Extension:
- [Carousel Notification Content Extension in Swift](https://github.com/Synerise/synerise-ios-sdk/tree/master/SampleAppSwift/4.10.0/SyneriseCarouselNotificationContentExtension)
- [Carousel Notification Content Extension in Objective-C](https://github.com/Synerise/synerise-ios-sdk/tree/master/SampleAppSwift/4.10.0/SyneriseCarouselNotificationContentExtensionObjC)
# Modules
### BaseModule
**Declared In:**
lib/modules/base/base_module.dart
**Declaration:**
class BaseModule
---
---
### Settings
**Declared In:**
lib/modules/notifications/settings_impl.dart
**Declaration:**
class SettingsImpl
**Properties:**
| Property | Type | Description |
| --- | --- | --- |
| **sdk** | GeneralSettings | [General settings](/developers/mobile-sdk/settings#general) - This group contains options related to the general functioning of mobile SDK |
| **notifications** | NotificationsSettings | [Notifications settings](/developers/mobile-sdk/settings#notifications) - This group contains options related to push notifications |
| **tracker** | TrackerSettings | [Tracker](/developers/mobile-sdk/settings#tracker) - This group contains options related to tracking the customer activities in a mobile application |
| **inAppMessaging** | InAppMessagingSettings | [In-app messaging](/developers/mobile-sdk/settings#in-app-messaging) - This group contains options related to the [in-app messages](/docs/campaign/in-app-messages) feature |
| **injector** | InjectorSettings | [Injector](/developers/mobile-sdk/settings#injector) - This group contains options related to displaying [campaigns](/docs/campaign/Mobile) |
**Note:**
Learn more about settings [here](/developers/mobile-sdk/settings)
---
---
### Notifications
**Declared In:**
lib/modules/notifications/notifications_impl.dart
**Declaration:**
class NotificationsImpl
**Listeners:**
[NotificationsListener](/developers/mobile-sdk/listeners-and-delegates/flutter-listeners#notifications-listener)
**Methods:**
This method passes the Firebase Token to Synerise for notifications.
Future<void> registerForNotifications(String registrationToken, {bool? mobileAgreement, required void Function() onSuccess, required void Function(SyneriseError error) onError})
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#register-for-push-notifications)
---
This method handles a notification payload and starts activity.
Future<bool> handleNotification(Map notification) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#handle-synerise-push-notification)
---
This method handles a notification payload with a user interaction and starts activity.
Future<bool> handleNotificationClick(Map notification) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#handle-synerise-push-notification-click)
---
This method verifies if a notification was sent by Synerise.
Future<bool> isSyneriseNotification(Map notification) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#check-if-push-notification-is-from-synerise)
---
This method verifies if a notification’s sender is Synerise and if the notification is a Simple Push campaign
Future<bool> isSyneriseSimplePush(Map notification) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#check-if-push-notification-is-a-simple-push-campaign)
---
This method verifies if a notification’s sender is Synerise and if the notification is a Banner campaign.
Future<bool> isSyneriseBanner(Map notification) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#check-if-push-notification-is-a-banner-campaign) - **REMOVED in version 2.0.0**
---
This method verifies if a notification's sender is Synerise and if the notification is a Silent Command.
Future<bool> isSilentCommand(Map notification) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#check-if-push-notification-is-a-silent-command)
---
This method verifies if a notification's sender is Synerise and if the notification is a Silent SDK Command.
Future<bool> isSilentSDKCommand(Map notification) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#check-if-push-notification-is-a-silent-sdk-command)
---
---
### Client
**Declared In:**
lib/modules/client/client_impl.dart
**Related To:**
[ClientAccountRegisterContext](/developers/mobile-sdk/class-reference/flutter/client#clientaccountregistercontext)
[ClientIdentityProvider](/developers/mobile-sdk/class-reference/flutter/client#clientidentityprovider)
[ClientAuthContext](/developers/mobile-sdk/class-reference/flutter/client#clientauthcontext)
[ClientConditionalAuthContext](/developers/mobile-sdk/class-reference/flutter/client#clientconditionalauthcontext)
[ClientAccountInformation](/developers/mobile-sdk/class-reference/flutter/client#clientaccountinformation)
[ClientAccountUpdateContext](/developers/mobile-sdk/class-reference/flutter/client#clientaccountupdatecontext)
[ClientConditionalAuthResult](/developers/mobile-sdk/class-reference/flutter/client#clientconditionalauthresult)
[ClientPasswordResetRequestContext](/developers/mobile-sdk/method-reference/flutter/client-account#request-password-reset-for-customer-account)
[ClientPasswordResetConfirmationContext](/developers/mobile-sdk/method-reference/flutter/client-account#confirm-password-reset-for-customer-account)
[Token](/developers/mobile-sdk/class-reference/flutter/client#token)
**Inherits From:**
[BaseModule](/developers/mobile-sdk/class-reference/flutter/modules#basemodule)
**Declaration:**
class ClientImpl extends BaseModule
**Methods:**
This method registers a new customer with an email, password, and optional data.
Future<void> registerAccount(ClientAccountRegisterContext context, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#register-customer-account)
---
This method confirms a customer account with the confirmation token.
Future<void> confirmAccountActivation(String token, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#confirm-customer-account-activation)
---
This method activates a customer with email.
Future<void> requestAccountActivation(String email, {required void Function() onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#request-customer-account-activation)
---
This method requests a customer's account registration process with the PIN code.
Future<void> requestAccountActivationByPin(String email, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#request-customer-account-activation-by-pin)
---
This method confirms a customer's account registration process with the PIN code.
Future<void> confirmAccountActivationByPin(String email, String pinCode, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#confirm-customer-account-activation-by-pin)
---
This method signs a customer in to obtain a JSON Web Token (JWT) which can be used in subsequent requests.
Future<void> signIn(String email, String password, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#sign-in-a-customer)
---
This method signs a customer in to obtain a JSON Web Token (JWT) which can be used in subsequent requests.
Future<void> signInConditionally(String email, String password, {required void Function(ClientConditionalAuthResult) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#sign-in-a-customer-conditionally)
---
This method authenticates a customer with OAuth, Facebook, Google, Apple, or Synerise.
Future<void> authenticate(ClientAuthContext clientAuthContext, IdentityProvider identityProvider, String tokenString, {required void Function(bool) onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#authenticate-customer-by-identityprovider)
---
This method authenticates a customer with OAuth, Facebook, Google, Apple, or Synerise.
Future<void> authenticateConditionally(ClientConditionalAuthContext clientAuthContext, IdentityProvider identityProvider, String tokenString, {String? authID, required void Function(ClientConditionalAuthResult) onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#authenticate-customer-conditionally-by-identityprovider)
---
This method authenticates a customer with Simple Profile Authentication.
Future<void> simpleAuthentication(ClientSimpleAuthenticationData data, String authID, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#authenticate-customer-via-simple-profile-authentication)
---
This method checks if a customer is signed in (via Synerise Authentication - RaaS, OAuth, Facebook, Apple).
Future<bool> isSignedIn() async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#check-if-a-customer-is-signed-in-via-raas-oauth-facebook-apple)
---
This method checks if a customer is signed in (via Simple Profile Authentication).
Future<bool> isSignedInViaSimpleAuthentication() async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#check-if-a-customer-is-signed-in-via-simple-profile-authentication)
---
This method signs out a customer out.
Future<void> signOut() async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#sign-out-a-customer)
---
This method signs out a customer out with a chosen mode and Determines if the method should sign out all devices
Future<void> signOutWithMode(ClientSignOutMode mode, bool fromAllDevices, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-authentication#sign-out-customer-with-mode-or-from-all-devices)
---
This method refreshes the customer’s current token.
Future<void> refreshToken({required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-session#refresh-customer-token)
---
This method retrieves the customer’s current, active token.
Future<void> retrieveToken({required void Function(Token) onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-session#retrieve-customer-token)
---
This method retrieves the customer’s current UUID.
Future<String> getUUID() async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-session#get-current-customer-uuid)
---
This method regenerates the UUID and clears the authentication token, login session, custom email, and custom identifier.
Future<void> regenerateUUID() async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-session#regenerate-customer)
---
This method regenerates the UUID and clears the authentication token, login session, custom email, and custom identifier.
Future<void> regenerateUUIDWithClientIdentifier(String clientIdentifier) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-session#regenerate-customer-with-identifier)
---
This method destroys the session completely.
Future<void> destroySession({required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-session#destroy-current-session)
---
This method gets a customer’s account information.
Future<void> getAccount({required void Function(ClientAccountInformation) onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#get-customer-account-information)
---
This method updates a customer’s account’s basic information (without identification data: uuid, customId, email).
Future<void> updateAccountBasicInformation(ClientAccountUpdateBasicInformationContext context, {required void Function() onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#update-customer-account-basic-information)
---
This method updates a customer’s account information.
Future<void> updateAccount(ClientAccountUpdateContext context, {required void Function() onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#update-customer-account-information)
---
This method requests a customer’s password reset with email.
Future<void> requestPasswordReset(String email, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#request-password-reset-for-customer-account)
---
This method confirm a customer’s password reset with the new password and token provided by password reset request.
Future<void> confirmPasswordReset(String password, String token, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#confirm-password-reset-for-customer-account)
---
This method changes a customer’s password.
Future<void> changePassword(String oldPassword, String newPassword, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#change-customers-account-password)
---
This method requests a customer's email change.
Future<void> requestEmailChange(String email, String password, {String? externalToken, String? authID, required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#request-email-change-for-customer-account)
---
This method confirms an email change.
Future<void> confirmEmailChange(String token, bool newsletterAgreement, {required void Function() onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#confirm-email-change-for-customer-account)
---
Requests a customer's phone update. A confirmation code is sent to the phone number.
Future<void> requestPhoneUpdate(String phone, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#request-phone-update-on-customer-account)
---
This method confirms a phone number update. This action requires the new phone number and confirmation code as parameters.
Future<void> confirmPhoneUpdate(String phone, String confirmationCode, bool smsAgreement, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#confirm-phone-update-on-customer-account)
---
This method deletes a customer's account.
Future<void> deleteAccount(String clientAuthFactor, IdentityProvider identityProvider, {String? authId, required void Function() onSuccess, required void Function(SyneriseError) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/client-account#delete-customer-account)
---
---
---
### Tracker
**Declared In:**
lib/modules/tracker/tracker_impl.dart
**Related To:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Inherits From:**
[BaseModule](/developers/mobile-sdk/class-reference/flutter/modules#basemodule)
**Declaration:**
class TrackerImpl extends BaseModule
**Methods:**
This method sets a custom identifier in the parameters of every event.
Future<void> setCustomIdentifier(String customIdentifier) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/tracking#set-custom-identifier-for-events)
---
This method sets a custom email in the parameters of every event.
Future<void> setCustomEmail(String customEmail) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/tracking#set-custom-email-for-events)
---
This method sends an event.
Future<void> send(Event event) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/tracking#send-event)
---
This method forces sending the events from the queue to the server.
Future<void> flush() async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/tracking#flush-events-from-tracker)
---
---
### Injector
**Declared In:**
lib/modules/injector/injector_impl.dart
**Inherits From:**
[BaseModule](/developers/mobile-sdk/class-reference/flutter/modules#basemodule)
**Declaration:**
class InjectorImpl extends BaseModule
**Listeners:**
[InjectorListener](/developers/mobile-sdk/listeners-and-delegates/flutter-listeners#injector-listener)
[InjectorInAppMessageListener](/developers/mobile-sdk/listeners-and-delegates/flutter-listeners#injector-in-app-message-listener)
**Methods:**
Closes an in-app message and sends an `inApp.discard` event.
Usage examples:
- Closing a top bar or bottom bar when the user taps outside the in-app area.
- Automatically dismissing messages when navigating away from a screen.
- Controlling in-app visibility based on app logic for a smoother user experience.
void closeInAppMessage(String campaignHash)
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#close-in-app-message)
---
This method fetches a walkthrough.
void getWalkthrough() async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#get-walkthrough) - **REMOVED in version 2.0.0**
---
This method shows a walkthrough when it is loaded.
void showWalkthrough() async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#show-walkthrough)- **REMOVED in version 2.0.0**
---
This method checks if a walkthrough is loaded.
Future<bool> isWalkthroughLoaded() async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#check-if-walkthrough-is-loaded)- **REMOVED in version 2.0.0**
---
This method checks if the walkthrough is unique compared to the previous one.
Future<bool> isLoadedWalkthroughUnique() async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/campaigns#check-if-is-loaded-walkthrough-unique)- **REMOVED in version 2.0.0**
---
---
### Promotions
The module for handling promotions and vouchers from Synerise SDK.
**Declared In:**
lib/modules/promotions/promotions_impl.dart
**Related To:**
[PromotionResponse](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotionresponse)
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
[AssignVoucherResponse](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#assignvoucherresponse)
[VoucherCodesResponse](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#vouchercodesresponse)
**Inherits From:**
[Module](/developers/mobile-sdk/class-reference/flutter/modules#basemodule)
**Declaration:**
class PromotionsImpl extends BaseModule
**Methods:**
This method retrieves all available promotions that are defined for a customer.
Future<void> getAllPromotions({required void Function(PromotionResponse promotionResponse) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#get-all-promotions-of-a-customer)
---
This method retrieves promotions that match the parameters defined in an API query.
Future<void> getPromotions(PromotionsApiQuery apiQuery, {required void Function(PromotionResponse promotionResponse) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#get-promotions-with-query-parameters)
---
This method retrieves the promotion with the specified UUID.
Future<void> getPromotionByUUID(String uuid, {required void Function(Promotion promotion) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#get-promotion-by-uuid)
---
This method retrieves the promotion with the specified code.
Future<void> getPromotionByCode(String code, {required void Function(Promotion promotion) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#get-promotion-by-code)
---
This method activates the promotion with the specified UUID.
Future<void> activatePromotionByUUID(String uuid, {required void Function() onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#activate-promotion-by-uuid)
---
This method activates the promotion with the specified code.
Future<void> activatePromotionByCode(String code, {required void Function() onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#activate-promotion-by-code)
---
This method activates promotions with a code or with UUID in a batch.
Future<void> activatePromotionsBatch(List<PromotionIdentifier> promotionsToActivate, {required void Function() onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#activate-promotions-in-a-batch)
---
This method deactivates the promotion with the specified UUID.
Future<void> deactivatePromotionByUUID(String uuid, {required void Function() onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#deactivate-promotion-by-uuid)
---
This method deactivates the promotion with the specified code.
Future<void> deactivatePromotionByCode(String code, {required void Function() onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#deactivate-promotion-by-code)
---
This method deactivates promotions with a code or with UUID in a batch.
Future<void> deactivatePromotionsBatch(List<PromotionIdentifier> promotionsToDeactivate, {required void Function() onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#deactivate-promotions-in-a-batch)
---
This method retrieves an assigned voucher code or assigns a voucher from a pool identified by UUID to the profile.
When the voucher is assigned for the first time, a [voucherCode.assigned](/docs/assets/events/event-reference/loyalty#vouchercodeassigned) event is produced.
Future<void> getOrAssignVoucher(String poolUuid, {required void Function(AssignVoucherResponse assignVoucherResponse) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#get-or-assign-voucher-from-pool)
---
This method assigns a voucher from a pool identified by UUID to the profile.
A [voucherCode.assigned](/docs/assets/events/event-reference/loyalty#vouchercodeassigned) event is produced.
Future<void> assignVoucherCode(String poolUuid, {required void Function(AssignVoucherResponse response) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#assign-voucher-code-from-pool)
---
This method retrieves voucher codes for a customer.
Future<void> getAssignedVoucherCodes({required void Function(VoucherCodesResponse voucherCodesResponse) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/promotions#get-voucher-codes-assigned-to-customer)
---
---
### Content
The module for handling content from Synerise backend such as documents, recommendations, and so on.
**Declared In:**
lib/modules/content/content_impl.dart
**Related To:**
[DocumentsApiQuery](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#documentsapiquery)
[Document](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#document)
[RecommendationResponse](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendationresponse)
[RecommendationOptions](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendationoptions)
[Recommendation](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendation)
[ScreenView](/developers/mobile-sdk/class-reference/flutter/miscellaneous#screenview)
[ScreenViewAudienceInfo](/developers/mobile-sdk/class-reference/flutter/miscellaneous#screenviewaudienceinfo)
[ScreenViewApiQuery](/developers/mobile-sdk/class-reference/flutter/miscellaneous#screenviewapiquery)
[BrickworksApiQuery](/developers/mobile-sdk/class-reference/flutter/miscellaneous#brickworksapiquery)
**Inherits From:**
[BaseModule](/developers/mobile-sdk/class-reference/flutter/modules#basemodule)
**Declaration:**
class ContentImpl extends BaseModule
**Methods:**
This method generates the document assigned to a slug.
Future<void> getDocuments(DocumentsApiQuery documentsApiQuery, {required void Function(List<Map<String, Object>> documentsList) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/content#get-document) - **REMOVED in version 2.0.0 **
---
This method generates the document that is defined for the provided slug.
Future<void> generateDocument(String slug, {required void Function(Document document) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/content#generate-document)
---
This method generates the document that is defined for parameters provided in the query object.
Future<void> generateDocumentWithApiQuery(DocumentApiQuery apiQuery, {required void Function(Document document) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/content#generate-document-with-query-parameters)
---
This method generates documents that are defined for parameters provided in the query object.
Future<List<Map<String, Object>>> getDocuments(DocumentsApiQuery documentsApiQueryModel) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/content#get-documents) - **REMOVED in version 2.0.0 **
---
This method generates recommendations that are defined for the options provided. The recommendations are generated by using a document with an insert.
For instructions, see ["Displaying AI recommendations > With documents and screen views"](/developers/mobile-sdk/displaying-recommendations/documents).
Future<void> getRecommendations(RecommendationOptions recommendationOptions, {required void Function(RecommendationResponse recommendationResponse) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/content#get-recommendations) - **REMOVED in version 2.0.0 **
---
This method generates recommendations that are defined for the options provided. The recommendations are generated by using a document with an insert.
For instructions, see ["Displaying AI recommendations > With documents and screen views"](/developers/mobile-sdk/displaying-recommendations/documents).
Future<void> getRecommendationsV2(RecommendationOptions recommendationOptions, {required void Function(RecommendationResponse recommendationResponse) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/content#get-recommendations-v2)
---
This method generates the customer's highest-priority screen view campaign.
Future<void> getScreenView({required void Function(ScreenViewResponse screenViewResponse) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/content#get-screen-view) - **REMOVED in version 2.0.0 **
---
This method generates a customer's highest-priority screen view campaign from the feed with the provided feed slug.
Future<void> generateScreenView(String feedSlug, {required void Function(ScreenView screenView) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/content#generate-screen-view)
---
This method generates customer's highest-priority screen view campaign that is defined for parameters provided in the query object.
Future<void> generateScreenViewWithApiQuery(ScreenViewApiQuery apiQuery, {required void Function(ScreenView screenView) onSuccess, required void Function(SyneriseError error) onError}) async
[(Click for more details)](/developers/mobile-sdk/method-reference/flutter/content#generate-screen-view-with-query-parameters)
---
# Public interfaces
## IDataApiCall
---
IDataApiCall is a public interface used to execute requests with parameterized objects.
**Java**:
public interface IDataApiCall<T> {
/**
* It is recommended to call the {@link #cancel()} method before next execution.
*
* @param onSuccessListener callback with response
* @param onFailureListener callback with Throwable instance
*/
void execute(@NonNull DataActionListener<T> onSuccessListener, @NonNull DataActionListener<ApiError> onFailureListener);
/**
* Cancels the API request, therefore no response will be provided nor callback fired. <br>
* It is recommended to call this method when an activity/fragment is being stopped.
*/
void cancel();
/**
* Specify a reactive Scheduler for your request. <br>
* By default, all internal methods use the {@link Schedulers#io()} scheduler.
* See {@link io.reactivex.schedulers.Schedulers} factory for more info.
*
* @param scheduler reactive scheduler.
*/
BasicDataApiCall<T> subscribeOn(Scheduler scheduler);
/**
* Specify your action when the request is being subscribed. This action will be fired just before calling the API.
*
* @param onSubscribeListener callback
*/
BasicDataApiCall<T> onSubscribe(ActionListener onSubscribeListener);
/**
* Specify your action when the request succeeds, fails, or is cancelled.
*
* @param doFinallyListener callback
*/
BasicDataApiCall<T> doFinally(ActionListener doFinallyListener);
/**
* Get the original reactive observable to chain your requests.<br>
* Note that some of the SDK methods not only wrap observables in IDataApiCall,
* but also add some extra logic, which shouldn't be skipped.<br>
*
* @return original reactive observable.
*/
Observable<T> getObservable();
}
## IApiCall
---
IApiCall is a public interface used to execute requests.
**Java**:
public interface IApiCall<T> {
/**
* It is recommended to call the {@link #cancel()} method before next execution.
*
* @param onSuccessListener successful callback with no response
* @param onFailureListener callback with Throwable instance
*/
void execute(@NonNull ActionListener onSuccessListener, @NonNull DataActionListener<ApiError> onFailureListener);
/**
* Cancels the API request, therefore no response will be provided nor callback fired. <br>
* It is recommended to call this method when an activity/fragment is being stopped.
*/
void cancel();
/**
* Specify a reactive Scheduler for your request. <br>
* By default, all internal methods use the {@link Schedulers#io()} scheduler.
* See {@link io.reactivex.schedulers.Schedulers} factory for more info.
*
* @param scheduler reactive scheduler.
*/
BasicApiCall<T> subscribeOn(Scheduler scheduler);
/**
* Specify your action when the request is being subscribed. This action will be fired just before calling API.
*
* @param onSubscribeListener callback.
*/
BasicApiCall<T> onSubscribe(ActionListener onSubscribeListener);
/**
* Specify your action when the request succeeds, fails, or is cancelled.
*
* @param doFinallyListener callback.
*/
BasicApiCall<T> doFinally(ActionListener doFinallyListener);
/**
* Get the original reactive observable to chain your requests.<br>
* Note that some of SDK methods not only wrap observables in IApiCall,
* but also add some extra logic, which shouldn't be skipped.<br>
*
* @return original reactive observable.
*/
Observable<T> getObservable();
}
# iOS
## Content Widget (iOS)
Content widget is a feature in the Software Development Kit that allows you to embed an easily customizable view with [recommendations](/docs/ai-hub/recommendations-v2) in your application.
Two view layouts are available:
- Horizontal slider - a single row view that slides horizontally on the screen.
- Grid view - can be displayed as full- or half-screen grid layout within your app.
Both views offer a number of configuration options that allow you to style the view consistently in the app. Additionally, the Content widget automatically tracks 4 events:
- `recommendation.seen` or `recommendation.view` (depending on configuration) sent when a recommended item is visible to the customer.
Recommendation.seen event
- `recommendation.click` sent when a customer clicks the recommended item.
Recommendation.click event
- `product.like` sent when a customer clicks a selectable button in the recommendation. (The button must be added)
Event sent when a user clicks the "like" button on an item
- `product.dislike` sent when a customer clicks a selectable button in the recommendation a second time. (The button must be added)
Product.dislike event
Currently, the widget can only be used for displaying AI recommendations.
### Prerequisites
---
To use the content widget feature, you must:
- Obtain a customer token from [Customer Authentication](/developers/mobile-sdk/user-identification-and-authorization/overview#authenticated-customers).
- [Create an AI Recommendation](/docs/ai-hub/recommendations-v2).
- [Create a document](/docs/assets/documents).
Such a document should contain the following content:
{
"name": "Similar Products",
"recommendations": "{% recommendations_json3 campaignId=COhsCCOdu8Cg %} {% endrecommendations_json3 %}"
}
- In the notepad, save the document's slug and the ID of the recommendation for later use.
It's a good practice to name slugs based on the area of the app that you want to place the content in, for example `product-details`, `menu`, and so on.
### Basic implementation
---
Configure the [`ContentWidgetOptions`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetoptions) and [`ContentWidgetAppearance`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetappearance) settings first.
| Class | Description |
| --- | --- |
| [`ContentWidgetOptions`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetoptions) | [`ContentWidgetOptions`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetoptions) contains options for business logic, such as the slug, product identifier, and so on. [Read more](#options). |
| [`ContentWidgetAppearance`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetappearance) | [`ContentWidgetAppearance`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetappearance) contains the UI configuration. [Read more](#options). |
The example below is the most basic implementation.
swift objective-c
```swift
let options = ContentWidgetOptions()
options.slug = "similar"
options.mapping = { model in
guard let imageURLString = model.attributes["imageLink"] as? String,
let imageURL = URL(string: imageURLString),
let title = model.attributes["title"] as? String,
let priceDictionary = model.attributes["price"] as? [AnyHashable: Any],
let priceValue = priceDictionary["value"] as? Double
else {
return nil
}
let dataModel = ContentWidgetRecommendationDataModel(imageURL: imageURL, title: title, priceCurrency: "PLN", price: NSNumber(value: priceValue), salePrice: nil)
if let salePriceDictionary = model.attributes["salePrice"] as? [AnyHashable: Any],
let salePriceValue = salePriceDictionary["value"] as? Double {
dataModel.salePriceValue = NSNumber(floatLiteral: salePriceValue)
}
let badgeDataModel = ContentWidgetBadgeDataModel(backgroundColor: UIColor.black, textColor: UIColor.white, text: "Black Week")
dataModel.badge = badgeDataModel
return dataModel
}
let gridLayout = ContentWidgetGridLayout()
let itemLayout = ContentWidgetBasicProductItemLayout()
let appearance = ContentWidgetAppearance(widgetLayout: gridLayout, itemLayout: itemLayout)
let widget = ContentWidget(options: options, appearance: appearance)
let widgetView = widget.getView()
widgetView.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height)
view.addSubview(widgetView)
```
```objective-c
SNRContentWidgetOptions *options = [SNRContentWidgetOptions new];
options.slug = @"similar";
options.mapping = ^(SNRContentWidgetRecommendationModel *model) {
NSString *imageURLString = model.attributes[@"imageLink"];
NSString *imageURL = [[NSURL alloc] initWithString:imageURLString];
NSString *title = model.attributes[@"title"];
NSDictionary *priceDictionary = model.attributes[@"price"];
NSNumber *priceValue = priceDictionary[@"value"];
if (imageURL == nil || title == nil || priceValue == nil) {
return nil;
}
SNRContentWidgetRecommendationDataModel *dataModel = [[SNRContentWidgetRecommendationDataModel alloc] initWithimageURL:imageURL title:title priceCurrency:@"PLN" price:priceValue salePrice:nil];
NSDictionary *salePriceDictionary = model.attributes[@"salePrice"];
NSNumber *salePriceValue = salePriceDictionary[@"value"];
if (salePrice != nil) {
dataModel.salePriceValue = salePriceValue;
}
SNRContentWidgetBadgeDataModel *badgeDataModel = [[SNRContentWidgetBadgeDataModel alloc] initWithBackgroundColor:backgroundColor textColor:textColor text:text];
dataModel.badge = badgeDataModel;
return dataModel;
}
SNRContentWidgetGridLayout *gridLayout = [SNRContentWidgetGridLayout new];
SNRContentWidgetBasicProductItemLayout *itemLayout = [SNRContentWidgetBasicProductItemLayout new];
SNRContentWidgetAppearance *appearance = [[SNRContentWidgetAppearance alloc] initWithLayout:gridLayout andItemLayout:itemLayout];
SNRContentWidget *widget = [[SNRContentWidget alloc] initWithOptions:options andAppearance:appearance];
UIView *widgetView = [widget getView];
widgetView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
[self.view addSubview:widgetView];
```
### Options
---
The [`ContentWidgetRecommendationsOptions`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetoptions) class is responsible for defining the business logic options of the widget, for example:
- slug of the document
- product identifier
- recommendation data model mapper
The table explains the parameters that can be configured in [`ContentWidgetRecommendationsOptions`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetoptions).
| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| slug | `String` | nil | Slug of a document |
| productID | `String` | nil | Product identifier for generating data |
| mapping | `((ContentWidgetRecommendationModel) -> (ContentWidgetRecommendationDataModel?))` | nil | Mapping block responsible for mapping data from the feed to a `ContentWidgetRecommendationDataModel` |
| recommendationEventType | `ContentWidgetRecommendationEventType` | - | Recommendation event type. **.view** sends all products in one event. We highly recommend using this type of event in content widget. **.seen** sends each event as a separate event. |
swift objective-c
```swift
let widgetOptions = ContentWidgetRecommendationsOptions()
widgetOptions.slug = "similar"
widgetOptions.productID = "12345"
widgetOptions.mapping = { model in
guard let imageURLString = model.attributes["imageLink"] as? String,
let imageURL = URL(string: imageURLString),
let title = model.attributes["title"] as? String,
let priceDictionary = model.attributes["price"] as? [AnyHashable: Any],
let priceValue = priceDictionary["value"] as? Double
else {
return nil
}
let dataModel = ContentWidgetRecommendationDataModel(imageURL: imageURL, title: title, priceCurrency: "PLN", price: NSNumber(value: priceValue), salePrice: nil)
if let salePriceDictionary = model.attributes["salePrice"] as? [AnyHashable: Any],
let salePriceValue = salePriceDictionary["value"] as? Double {
dataModel.salePriceValue = NSNumber(floatLiteral: salePriceValue)
}
let badgeDataModel = ContentWidgetBadgeDataModel(backgroundColor: UIColor.black, textColor: UIColor.white, text: "Black Week")
dataModel.badge = badgeDataModel
return dataModel
}
```
```objective-c
SNRContentWidgetRecommendationsOptions *widgetOptions = [SNRContentWidgetRecommendationsOptions new];
widgetOptions.slug = @"similar";
widgetOptions.productID = @"12345";
widgetOptions.mapping = ^(SNRContentWidgetRecommendationModel *model) {
NSString *imageURLString = model.attributes[@"imageLink"];
NSString *imageURL = [[NSURL alloc] initWithString:imageURLString];
NSString *title = model.attributes[@"title"];
NSDictionary *priceDictionary = model.attributes[@"price"];
NSNumber *priceValue = priceDictionary[@"value"];
if (imageURL == nil || title == nil || priceValue == nil) {
return nil;
}
SNRContentWidgetRecommendationDataModel *dataModel = [[SNRContentWidgetRecommendationDataModel alloc] initWithimageURL:imageURL title:title priceCurrency:@"PLN" price:priceValue salePrice:nil];
NSDictionary *salePriceDictionary = model.attributes[@"salePrice"];
NSNumber *salePriceValue = salePriceDictionary[@"value"];
if (salePrice != nil) {
dataModel.salePriceValue = salePriceValue;
}
SNRContentWidgetBadgeDataModel *badgeDataModel = [[SNRContentWidgetBadgeDataModel alloc] initWithBackgroundColor:backgroundColor textColor:textColor text:text];
dataModel.badge = badgeDataModel;
return dataModel;
}
```
### Appearance
---
The [`ContentWidgetAppearance`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetappearance) class is responsible for defining the appearance of the widget.
The class consists of parameters that define the widget's appearance, however, two of them are the most important:
- **Main layout class**: defines the way of distributing elements in the widget. Currently, two layouts are provided: [`ContentWidgetHorizontalSliderLayout`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgethorizontalsliderlayout) and [`ContentWidgetGridLayout`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetgridlayout).
- **Item layout class**: defines appearance and parameters for the item in the widget. Currently, there is only one layout provided: [`ContentWidgetBasicProductItemLayout`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetbasicproductitemlayout).
The table explains the parameters that can be configured in [`ContentWidgetAppearance`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetappearance).
| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| layout | [`ContentWidgetLayout`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetlayout) | - | Class that inherits from [`ContentWidgetLayout`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetlayout) contains the UI details of `widgetLayout` |
| itemLayout | [`ContentWidgetItemLayout`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetitemlayout) | - | Class that inherits from [`ContentWidgetItemLayout`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetitemlayout) contains the UI details of a single item in a widget |
### Widget layouts
---
#### Horizontal Slider
This layout is intended to present recommendations in a fixed-hight horizontal scrollable slider.
**Example widget configuration with horizontal slider:**
##### Parameters
The table explains the parameters of `SNRContentWidgetHorizontalLayout`.
| Property | Type | Default | Description |
| --- | --- | --- | --- |
| backgroundColor | `UIColor` | UIColor.clearColor | Background color of a widget |
| insets | `UIEdgeInsets` | (8.0, 8.0, 8.0, 8.0) | Inner widget margins in pt |
| itemSize | `CGSize` | (150.0, 200.0) | Size of a single item in pt |
| itemSpacing | `CGFloat` | 16.0 | Horizontal spacing between items in pt |
| numberOfItems | `Int` | - | A **read-only** property. It returns the number of items after a widget is loaded |
##### Example
swift objective-c
```swift
let horizontalSliderLayout = ContentWidgetHorizontalSliderLayout()
horizontalSliderLayout.insets = UIEdgeInsets(top: 16.0, left: 16.0, bottom: 16.0, right: 16.0)
horizontalSliderLayout.itemSize = CGSize(width: 150, height: 350)
horizontalSliderLayout.itemSpacing = 8.0
```
```objective-c
SNRContentWidgetHorizontalSliderLayout *horizontalSliderLayout = [SNRContentWidgetHorizontalSliderLayout new];
horizontalSliderLayout.insets = UIEdgeInsetsMake(16.0f, 16.0f, 16.0f, 16.0f);
horizontalSliderLayout.itemSize = CGSizeMake(150.0f, 350.0f);
horizontalSliderLayout.itemSpacing = 8.0f;
```
#### Grid View
This layout presents recommendations in a vertical scrollable grid, with elements organized into columns and rows. You can create a full- or half-screen widget.
**Example widget configuration with grid layout:**
##### Parameters
The table explains the parameters of the grid layout.
| Property | Type | Default | Description |
| --- | --- | --- | --- |
| backgroundColor | `UIColor` | UIColor.clearColor | Background color of a widget |
| insets | `UIEdgeInsets` | (8.0, 8.0, 8.0, 8.0) | Inner widget margins in pt |
| itemSize | `CGSize` | (150.0, 200.0) | Size of a single item in pt|
| itemHorizontalSpacing | `CGFloat` | 16.0 | Horizontal spacing between items in pt |
| itemVerticalSpacing | `CGFloat` | 16.0 | Vertical spacing between items in pt |
| numberOfItems | `Int` | - | A **read-only** property. It returns the number of items after the widget is loaded |
##### Example
swift objective-c
```swift
let gridLayout = ContentWidgetGridLayout()
gridLayout.insets = UIEdgeInsets(top: 16.0, left: 16.0, bottom: 16.0, right: 16.0)
gridLayout.itemSize = CGSize(width: 150, height: 350)
gridLayout.horizontalItemSpacing = 8.0
gridLayout.verticalItemSpacing = 8.0
```
```objective-c
SNRContentWidgetGridLayout *gridLayout = [SNRContentWidgetGridLayout new];
gridLayout.insets = UIEdgeInsetsMake(16.0f, 16.0f, 16.0f, 16.0f);
gridLayout.itemSize = CGSizeMake(150.0f, 350.0f);
gridLayout.horizontalItemSpacing = 8.0f;
gridLayout.verticalItemSpacing = 8.0f;
```
### Widget Item layouts
---
#### Basic Product Item Layout
This is the basic layout for items. It contains: the image, the title, and the price from the uploaded data.
##### Parameters
The table below contains all parameters you can configure in the basic item layout.
| Property | Type | Default | Description |
| --- | --- | --- | --- |
| backgroundColor | `UIColor` | UIColor.whiteColor | Background color of an item |
| cornerRadius | `CGFloat` | 0.0 | Radius of the item corners |
| borderWidth | `CGFloat` | 0.0 | Width of the item's border |
| borderColor | `CGFloat` | nil | Color of the item's border |
| shadowColor | `UIColor` | nil | Color of the item's shadow |
| imageWidthRatio | `CGFloat` | 1.0 | Image width. A ratio of `1.0` means that the image width equals to 100% of the entire height of the item |
| imageHeightRatio | `CGFloat` | 0.35 | Image height. A ratio of `0.35` means that image height equals to 35% of the entire height of the item |
| imageBackground | `UIColor` | UIColor.clearColor | Background color of the image |
| imageContentMode | `UIViewContentMode` | UIViewContentMode.scaleToFill | Display content mode of the image |
| topTextInsets | `UIEdgeInsets` | (8.0, 8.0, 8.0, 8.0) | Inner margins of the top text label |
| topTextFont | `UIFont` | UIFont.systemFont(ofSize: 16.0) | Font of the top text label |
| topTextFontColor | `UIColor` | UIColor.blackColor | Color of the top text label |
| topTextAlignment | `NSTextAlignment` | NSTextAlignment.center | Alignment of the top text label |
| titleInsets | `UIEdgeInsets` | (8.0, 8.0, 8.0, 8.0) | Inner margins of the title label |
| titleFont | `UIFont` | UIFont.systemFont(ofSize: 16.0) | Font of the title label |
| titleFontColor | `UIColor` | UIColor.blackColor | Color of the title label |
| titleAlignment | `NSTextAlignment` | NSTextAlignment.center | Alignment of the title label |
| subtitleInsets | `UIEdgeInsets` | (8.0, 8.0, 8.0, 8.0) | Inner margins of the subtitle label |
| subtitleFont | `UIFont` | UIFont.systemFont(ofSize: 16.0) | Font of the subtitle label |
| subtitleFontColor | `UIColor` | UIColor.blackColor | Color of the subtitle label |
| subtitleAlignment | `NSTextAlignment` | NSTextAlignment.center | Alignment of the subtitle label |
| identifierInsets | `UIEdgeInsets` | (8.0, 8.0, 8.0, 8.0) | Inner margins of the identifier label |
| identifierFont | `UIFont` | UIFont.systemFont(ofSize: 16.0) | Font of the identifier label |
| identifierFontColor | `UIColor` | UIColor.blackColor | Color of the identifier label |
| identifierAlignment | `NSTextAlignment` | NSTextAlignment.center | Alignment of the identifier label |
| priceInsets | `UIEdgeInsets` | (8.0, 8.0, 8.0, 8.0) | Inner margins of the price label |
| priceFont | `UIFont` | UIFont.systemFont(ofSize: 14.0) | Font of the price label |
| priceFontColor | `UIColor` | UIColor.blackColor | Color of the price label |
| priceAlignment | `NSTextAlignment` | NSTextAlignment.center | Alignment of the price label |
| priceGroupSeparator | `String` | nil | Separator of price group |
| priceDecimalSeparator | `String` | nil | Separator of price decimal |
| priceCurrencyPosition | `ContentWidgetPriceCurrencyPosition` | .right | Determines the side on which the price currency is |
| isSalePriceVisible | `Bool` | true | Flag determining whether to show the sale price label or not |
| salePriceOrientation | `UILayoutConstraintAxis` | UILayoutConstraintAxis.Horizontal | Orientation of the sale price label |
| isDiscountPercentageVisible | `Bool` | true | Flag determining whether to show the discount percentage label or not |
| discountPercentageFont | `UIFont` | UIFont.systemFont(ofSize: 10.0) | Font of the discount percentage label |
| discountPercentageFontColor | `UIColor` | UIColor.blackColor | Font of the discount percentage label |
| regularPriceFont | `UIFont` | nil | Font of the regular price label |
| regularPriceFontColor | `UIColor` | nil | Color of the sale regular label |
| salePriceFont | `UIFont` | nil | Font of the sale price label |
| salePriceFontColor | `UIColor` | nil | Color of the sale price label |
| loyaltyPointsInsets | `UIEdgeInsets` | (8.0, 8.0, 8.0, 8.0) | Inner margins of the loyalty points label |
| loyaltyPointsAlignment | `NSTextAlignment` | NSTextAlignment.left | Alignment of the loyalty points label |
| loyaltyPointsNumberFont | `UIFont` | UIFont.systemFont(ofSize: 16.0) | Font of the loyalty points number label |
| loyaltyPointsNumberFontColor | `UIColor` | UIColor.blackColor | Color of the loyalty points number label |
| loyaltyPointsTextFont | `UIFont` | UIFont.systemFont(ofSize: 16.0) | Font of the loyalty points text label |
| loyaltyPointsTextFontColor | `UIColor` | UIColor.blackColor | Color of the loyalty points text label |
| loyaltyPointsText | `UIFont` | 'Loyalty points' | Text after the number of loyalty points |
| badge | `SNRContentWidgetBadgeItemLayoutPartial` | nil | Optional badge view |
| actionButton | `SNRContentWidgetImageButtonCustomAction` | nil | Optional button for your own custom action |
##### Example
swift objective-c
```swift
let itemLayout = ContentWidgetBasicProductItemLayout()
itemLayout.imageWidthRatio = 1.0
itemLayout.imageHeightRatio = 0.4
itemLayout.borderWidth = 2.0
itemLayout.borderColor = UIColor.black
itemLayout.shadowColor = UIColor.black
itemLayout.cornerRadius = 12.0
```
```objective-c
SNRContentWidgetBasicProductItemLayout *itemLayout = [SNRContentWidgetBasicProductItemLayout new];
itemLayout.imageWidthRatio = 1.0f;
itemLayout.imageHeightRatio = 0.4f;
itemLayout.borderWidth = 2.0f;
itemLayout.borderColor = [UIColor blackColor];
itemLayout.shadowColor = [UIColor blackColor];
itemLayout.cornerRadius = 12.0f;
```
### Interaction with the Widget
---
#### Public Interface
`load()` - Starts fetching data and creates a view structure of the widget.
`isLoaded()` - Checks whether the widget is successfully loaded.
`getView()` - Gets the root view of the whole widget view structure.
#### Delegation
[`ContentWidgetDelegate`](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#content-widget-delegate) is used to inform developers about the state of a widget.
- `snr_widgetIsLoading(widget:isLoading:)` - Called when the widget’s loading state changes. It's an **optional** method.
- `snr_widgetDidLoad(widget:)` - Called after the widget is loaded. It's a **required** method.
- `snr_widgetDidNotLoad(widget:error:)` - Called when an error occurs while loading. It's a **required** method.
- `snr_widgetDidChangeSize(widget:size:)` - Called when the widget size changes. It's an **optional** method.
- `snr_widgetDidReceiveClickAction(widget:model:)` - Called when the customer clicks a widget item. It's a **required** method.
Check the [`ContentWidgetDelegate`](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#content-widget-delegate) section for more details.
#### Image Button Custom Action
[`ContentWidgetImageButtonCustomAction`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetbasecustomaction) is used to add an image button to your widget (only if the item layout allows). You can add a button with a single state or make it selectable.
##### Parameters
| Property | Type | Default | Description |
| --- | --- | --- | --- |
| predefinedActionType | [`ContentWidgetBaseCustomActionPredefiniedActionType`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetbasecustomactionpredefiniedactiontype) | .none | It determines which event is sent on click |
| size | `CGSize` | CGSize.Zero | Button size |
| position | `CGPoint` | CGPoint.Zero | Position |
| backgroundColor | `UIColor` | UIColor.clearColor | Background color of the button |
| tintColor | `UIColor` | UIColor.blackColor | Fill color of the button's image, if an asset supports it |
| image | `UIImage` | nil | Button image |
| isSelectable | `Bool` | nil | Flag determining whether the button is selectable |
| selectedImage | `UIImage` | nil | Image of the button when the button is selected |
| isSelected | `SNRContentWidgetImageButtonCustomActionIsSelectedBlock` | nil | Block/closure to be executed when the widget needs to determine the state of a button in the cell |
| onReceiveClickAction | `SNRContentWidgetImageButtonCustomActionReceiveClickActionBlock` | nil | Block/closure to be executed when the button is clicked |
##### Block/Closures
- `isSelected` - Called when the widget tries to determine button's state. The only one parameter is model of data for the cell (for example [`Recommendation`](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#recommendation)). It's an **optional** property.
- `onReceiveClickAction` - Called when the button was clicked. Parameters are model of data for the cell (for example [`Recommendation`](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#recommendation)) and current state of button. It's an **optional** property.
### Sample Implementations
---
#### Horizontal Slider
This is an example with [`ContentWidgetHorizontalSliderLayout`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgethorizontalsliderlayout). It always has fixed height, so after the widget is loaded, its content height can be calculated.
That is why it is done in the `snr_widgetDidLoad(widget:)` method.
The widget content size in a horizontal slider layout can be calculated by the `getSize()` method.
swift objective-c
```swift
class ContentWidgetHorizontalSliderSampleViewController: UIViewController, ContentWidgetDelegate {
var widget: ContentWidget!
@IBOutlet weak var widgetContainerView: UIView!
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setupWidget()
}
// MARK: - Private
func setupWidget() -> Void {
let options = ContentWidgetRecommendationsOptions()
options.slug = "similar"
options.productID = "12345"
options.mapping = { model in
guard let imageURLString = model.attributes["imageLink"] as? String,
let imageURL = URL(string: imageURLString),
let title = model.attributes["title"] as? String,
let priceDictionary = model.attributes["price"] as? [AnyHashable: Any],
let priceValue = priceDictionary["value"] as? Double
else {
return nil
}
let dataModel = ContentWidgetRecommendationDataModel(imageURL: imageURL, title: title, priceCurrency: "PLN", price: NSNumber(value: priceValue), salePrice: nil)
if let salePriceDictionary = model.attributes["salePrice"] as? [AnyHashable: Any],
let salePriceValue = salePriceDictionary["value"] as? Double {
dataModel.salePriceValue = NSNumber(floatLiteral: salePriceValue)
}
let badgeDataModel = ContentWidgetBadgeDataModel(backgroundColor: UIColor.black, textColor: UIColor.white, text: "Black Week")
dataModel.badge = badgeDataModel
return dataModel
}
let horizontalSliderLayout = ContentWidgetHorizontalSliderLayout()
horizontalSliderLayout.insets = UIEdgeInsets(top: 16.0, left: 16.0, bottom: 16.0, right: 16.0)
horizontalSliderLayout.itemSize = CGSize(width: 150, height: 350)
horizontalSliderLayout.itemSpacing = 8.0
let itemLayout = ContentWidgetBasicProductItemLayout()
itemLayout.imageWidthRatio = 1.0
itemLayout.imageHeightRatio = 0.4
itemLayout.borderWidth = 2.0
itemLayout.borderColor = UIColor.black
itemLayout.shadowColor = UIColor.black
itemLayout.cornerRadius = 12.0
let actionButton = ContentWidgetImageButtonCustomAction()
actionButton.backgroundColor = UIColor.clear
actionButton.tintColor = UIColor.black
actionButton.image = UIImage(imageLiteralResourceName: "Shop Flow/icon_favorite_add")
actionButton.isSelectable = true
actionButton.selectedImage = UIImage(imageLiteralResourceName: "Shop Flow/icon_favorite_remove")
actionButton.size = CGSize(width: 40, height: 40)
actionButton.predefinedActionType = .sendLikeEvent
actionButton.onReceiveClickAction = {
model, isSelected in
if let recommendationModel = model as? Recommendation {
print("Content Widget did receive click action for action button \(recommendationModel.title)")
}
}
actionButton.isSelected = {
model in
return false
}
itemLayout.actionButton = actionButton
itemLayout.actionButtonPosition = CGPoint(x: (150.0 - 40 - 8), y: 8)
let appearance = ContentWidgetAppearance(widgetLayout: horizontalSliderLayout, itemLayout: itemLayout)
widget = ContentWidget(options: options, appearance: appearance)
widget.delegate = self
widget.load()
}
// MARK: - ContentWidgetDelegate
func snr_widgetIsLoading(widget: ContentWidget, isLoading: Bool) {
print("Content Widget is loading: \(isLoading)")
}
func snr_widgetDidLoad(widget: ContentWidget) {
print("Content Widget did load")
let widgetView: UIView = widget.getView()
let widgetSize: CGSize = (widget.layout as! ContentWidgetHorizontalSliderLayout).getSize()
widgetContainerView.addSubview(widgetView)
widgetView.translatesAutoresizingMaskIntoConstraints = false
widgetView.topAnchor.constraint(equalTo: widgetContainerView.topAnchor).isActive = true
widgetView.bottomAnchor.constraint(equalTo: widgetContainerView.bottomAnchor).isActive = true
widgetView.leftAnchor.constraint(equalTo: widgetContainerView.leftAnchor).isActive = true
widgetView.rightAnchor.constraint(equalTo: widgetContainerView.rightAnchor).isActive = true
widgetContainerView.heightAnchor.constraint(equalToConstant: widgetSize.height).isActive = true
}
func snr_widgetDidNotLoad(widget: ContentWidget, error: Error) {
print("Content Widget did not load. Error: \(error.localizedDescription)")
}
func snr_widgetDidChangeSize(widget: ContentWidget, size: CGSize) {
print("Content Widget did change size to: \(size)")
}
func snr_widgetDidReceiveClickAction(widget: ContentWidget, model: BaseModel) {
if let recommendationModel = model as? Recommendation {
print("Content Widget did receive click action for \(recommendationModel.title)")
}
}
}
```
```objective-c
@interface ContentWidgetHorizontalSliderSampleViewController : UIViewController
@property (weak, nonatomic, nonnull, readwrite) IBOutlet UIView *widgetContainerView;
@end
@@implementation ContentWidgetHorizontalSliderSampleViewController ()
@property (strong, nonatomic, nullable, readwrite) SNRContentWidget *widget;
@end
@@implementation ContentWidgetHorizontalSliderSampleViewController
#pragma mark - Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
[self setupWidget];
}
#pragma mark - Private
- (void)setupWidget {
SNRContentWidgetOptions *options = [SNRContentWidgetOptions new];
options.slug = @"similar";
options.productID = @"12345";
options.mapping = ^(SNRContentWidgetRecommendationModel *model) {
NSString *imageURLString = model.attributes[@"imageLink"];
NSString *imageURL = [[NSURL alloc] initWithString:imageURLString];
NSString *title = model.attributes[@"title"];
NSDictionary *priceDictionary = model.attributes[@"price"];
NSNumber *priceValue = priceDictionary[@"value"];
if (imageURL == nil || title == nil || priceValue == nil) {
return nil;
}
SNRContentWidgetRecommendationDataModel *dataModel = [[SNRContentWidgetRecommendationDataModel alloc] initWithimageURL:imageURL title:title priceCurrency:@"PLN" price:priceValue salePrice:nil];
NSDictionary *salePriceDictionary = model.attributes[@"salePrice"];
NSNumber *salePriceValue = salePriceDictionary[@"value"];
if (salePrice != nil) {
dataModel.salePriceValue = salePriceValue;
}
SNRContentWidgetBadgeDataModel *badgeDataModel = [[SNRContentWidgetBadgeDataModel alloc] initWithBackgroundColor:backgroundColor textColor:textColor text:text];
dataModel.badge = badgeDataModel;
return dataModel;
}
SNRContentWidgetHorizontalSliderLayout *horizontalSliderLayout = [SNRContentWidgetHorizontalSliderLayout new];
horizontalSliderLayout.insets = UIEdgeInsetsMake(16.0f, 16.0f, 16.0f, 16.0f);
horizontalSliderLayout.itemSize = CGSizeMake(150.0f, 350.0f);
horizontalSliderLayout.itemSpacing = 8.0f;
SNRContentWidgetBasicProductItemLayout *itemLayout = [SNRContentWidgetBasicProductItemLayout new];
itemLayout.imageWidthRatio = 1.0f;
itemLayout.imageHeightRatio = 0.4f;
itemLayout.borderWidth = 2.0f;
itemLayout.borderColor = [UIColor blackColor];
itemLayout.shadowColor = [UIColor blackColor];
itemLayout.cornerRadius = 12.0f;
SNRContentWidgetImageButtonCustomAction *actionButton = [SNRContentWidgetImageButtonCustomAction new];
actionButton.backgroundColor = [UIColor clearColor];
actionButton.tintColor = [UIColor blackColor];
actionButton.image = [UIImage imageNamed:@"Shop Flow/icon_favorite_add"];
actionButton.isSelectable = YES
actionButton.selectedImage = [UIImage imageNamed:@"Shop Flow/icon_favorite_remove"];
actionButton.size = CGSizeMake(40.0f, 40.0f);
actionButton.predefinedActionType = SNRContentWidgetBaseCustomActionPredefiniedActionTypeSendLikeEvent;
actionButton.onReceiveClickAction = ^(SNRBaseModel *model, BOOL isSelected) {
NSLog(@"Content Widget did receive click action for action button %@", ((SNRRecommednation *)recommendationModel.title));
};
actionButton.isSelected = ^(SNRBaseModel *model) {
return NO;
};
itemLayout.actionButton = actionButton
itemLayout.actionButtonPosition = CGPointMake((150.0f - 40.0f - 8), 8.0f)
SNRContentWidgetAppearance *appearance = [[SNRContentWidgetAppearance alloc] initWithLayout:horizontalSliderLayout andItemLayout:itemLayout];
SNRContentWidget *widget = [[SNRContentWidget alloc] initWithOptions:options andAppearance:appearance];
widget.delegate = self
[widget load];
self.widget = widget;
}
#pragma mark - SNRContentWidgetDelegate
- (void)SNR_widget:(SNRContentWidget *)widget isLoading:(BOOL)isLoading {
NSLog(@"Content Widget is loading: %@", isLoading ?? @"true" : @"false");
}
- (void)SNR_widgetDidLoad:(SNRContentWidget *)widget {
NSLog(@"Content Widget did load");
UIView *widgetView = [widget getView];
CGSize widgetSize = [((SNRContentWidgetHorizontalSliderLayout *)widget.layout getSize];
[self.widgetContainerView addSubview:widgetView];
widgetView.translatesAutoresizingMaskIntoConstraints = NO;
[widgetView.topAnchor constraintEqualTo:widgetContainerView.topAnchor].active = YES;
[widgetView.bottomAnchor constraintEqualTo:widgetContainerView.bottomAnchor].active = YES;
[widgetView.leftAnchor constraintEqualTo:widgetContainerView.leftAnchor].active = YES;
[widgetView.rightAnchor constraintEqualTo:widgetContainerView.rightAnchor].active = YES;
[widgetContainerView.heightAnchor constraintEqualToConstant:widgetSize.height].active = YES;
}
- (void)SNR_widget:(SNRContentWidget *)widget didNotLoadWithError:(NSError *)error {
NSLog(@"Content Widget did not load. Error: %@", error.localizedDescription);
}
- (void)SNR_widget:(SNRContentWidget *)widget didChangeToSize:(CGSize)size {
NSLog(@"Content Widget did change size to %@", NSStringFromCGSize(size));
}
- (void)SNR_widget:(SNRContentWidget *)widget didReceiveClickActionForModel:(SNRBaseModel *)model {
if ([model isKindOfClass:[SNRRecommendation class]] == YES) {
SNRRecommendation *recommendationModel = ((SNRRecommendation *)model);
NSLog(@"Content Widget did receive click action for %@", recommendationModel.title);
}
}
@end
```
#### Grid View
A basic example with [`ContentWidgetGridLayout`](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidgetgridlayout) and `UITableViewController`. Remember that cells are prototyped.
Initially, the height of the tenth row equals zero, because there is no possibility of getting the correct height of the widget. Before the widget is loaded, we don't know how many items it's going to contain.
The widget view is flexible, so it fits the dimensions that you set up. If the height of the widget that you set is smaller than the total height of the generated grid, the content can be scrolled vertically.
The grid's content height depends on:
- The widget width that you set up
- The number of items that have been loaded
That is why the code below reloads the tenth row after the widget is loaded. Earlier, it was impossible to calculate the height correctly.
In addition, the widget row is reloaded when the `snr_widgetDidChangeSize(widget:size:)` method is called. In this case, it's a required action, because the widget has pinned constraints to superview in a prototyped cell.
The widget's content size changes with the tableview size, for example when the screen orientation changes, the widget's height needs to be re-calculated. Otherwise, the cell height may be larger that necessary.
The total widget content size in a grid layout can be calculated by the `getSize(preferredWidth:)` method.
swift objective-c
```swift
class ContentWidgetGridViewSampleViewController: UITableViewController, ContentWidgetDelegate {
var widget: ContentWidget!
@IBOutlet weak var widgetContainerView: UIView!
// MARK: - Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
setupWidget()
}
func setupWidget() -> Void {
let options = ContentWidgetRecommendationsOptions()
options.slug = "similar"
options.productID = "12345"
options.mapping = { model in
guard let imageURLString = model.attributes["imageLink"] as? String,
let imageURL = URL(string: imageURLString),
let title = model.attributes["title"] as? String,
let priceDictionary = model.attributes["price"] as? [AnyHashable: Any],
let priceValue = priceDictionary["value"] as? Double
else {
return nil
}
let dataModel = ContentWidgetRecommendationDataModel(imageURL: imageURL, title: title, priceCurrency: "PLN", price: NSNumber(value: priceValue), salePrice: nil)
if let salePriceDictionary = model.attributes["salePrice"] as? [AnyHashable: Any],
let salePriceValue = salePriceDictionary["value"] as? Double {
dataModel.salePriceValue = NSNumber(floatLiteral: salePriceValue)
}
let badgeDataModel = ContentWidgetBadgeDataModel(backgroundColor: UIColor.black, textColor: UIColor.white, text: "Black Week")
dataModel.badge = badgeDataModel
return dataModel
}
let gridLayout = ContentWidgetGridLayout()
gridLayout.insets = UIEdgeInsets(top: 16.0, left: 16.0, bottom: 16.0, right: 16.0)
gridLayout.itemSize = CGSize(width: 150.0, height: 350.0)
gridLayout.horizontalItemSpacing = 8.0
gridLayout.verticalItemSpacing = 8.0
let itemLayout = ContentWidgetBasicProductItemLayout()
itemLayout.imageWidthRatio = 1.0
itemLayout.imageHeightRatio = 0.4
itemLayout.borderWidth = 2.0
itemLayout.borderColor = UIColor.black
itemLayout.shadowColor = UIColor.black
itemLayout.cornerRadius = 12.0
actionButton.onReceiveClickAction = {
model, isSelected in
if let recommendationModel = model as? Recommendation {
print("Content Widget did receive click action for action button \(recommendationModel.title)")
}
}
actionButton.isSelected = {
model in
return false
}
itemLayout.actionButton = actionButton
itemLayout.actionButtonPosition = CGPoint(x: (150.0 - 40.0 - 8.0), y: 8.0)
let appearance = ContentWidgetAppearance(widgetLayout: gridLayout, itemLayout: itemLayout)
widget = ContentWidget(options: options, appearance: appearance)
widget.delegate = self
widget.load()
}
// MARK: - UITableViewDataSource, UITableViewDelegate
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 10 {
if widget != nil && widget.isLoaded() {
return (widget.layout as! ContentWidgetGridLayout).getSize(preferredWidth: tableView.bounds.size.width).height
} else {
return 0
}
}
return 100.0
}
// MARK: - ContentWidgetDelegate
func snr_widgetIsLoading(widget: ContentWidget, isLoading: Bool) {
print("Content Widget is loading: \(isLoading)")
}
func snr_widgetDidLoad(widget: ContentWidget) {
print("Content Widget did load")
view.addSubview(widgetView)
widgetView = widget.getView()
widgetContainerView.addSubview(widgetView)
widgetView.translatesAutoresizingMaskIntoConstraints = false
widgetView.topAnchor.constraint(equalTo: widgetContainerView.topAnchor).isActive = true
widgetView.bottomAnchor.constraint(equalTo: widgetContainerView.bottomAnchor).isActive = true
widgetView.leftAnchor.constraint(equalTo: widgetContainerView.leftAnchor).isActive = true
widgetView.rightAnchor.constraint(equalTo: widgetContainerView.rightAnchor).isActive = true
tableView.reloadData()
}
func snr_widgetDidNotLoad(widget: ContentWidget, error: Error) {
print("Content Widget did not load. Error: \(error.localizedDescription)")
}
func snr_widgetDidChangeSize(widget: ContentWidget, size: CGSize) {
print("Content Widget did change size to: \(size)")
tableView.reloadData()
}
func snr_widgetDidReceiveClickAction(widget: ContentWidget, model: BaseModel) {
if let recommendationModel = model as? Recommendation {
print("Content Widget did receive click action for \(recommendationModel.title)")
}
}
}
```
```objective-c
@interface ContentWidgetGridViewSampleViewController : UITableViewController
@property (weak, nonatomic, nonnull, readwrite) IBOutlet UIView *widgetContainerView;
@end
@@implementation ContentWidgetGridViewSampleViewController ()
@property (strong, nonatomic, nullable, readwrite) SNRContentWidget *widget;
@end
@@implementation ContentWidgetGridViewSampleViewController
#pragma mark - Lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
[self setupWidget];
}
#pragma mark - Private
- (void)setupWidget {
SNRContentWidgetOptions *options = [SNRContentWidgetOptions new];
options.slug = @"similar";
options.productID = @"12345";
options.mapping = ^(SNRContentWidgetRecommendationModel *model) {
NSString *imageURLString = model.attributes[@"imageLink"];
NSString *imageURL = [[NSURL alloc] initWithString:imageURLString];
NSString *title = model.attributes[@"title"];
NSDictionary *priceDictionary = model.attributes[@"price"];
NSNumber *priceValue = priceDictionary[@"value"];
if (imageURL == nil || title == nil || priceValue == nil) {
return nil;
}
SNRContentWidgetRecommendationDataModel *dataModel = [[SNRContentWidgetRecommendationDataModel alloc] initWithimageURL:imageURL title:title priceCurrency:@"PLN" price:priceValue salePrice:nil];
NSDictionary *salePriceDictionary = model.attributes[@"salePrice"];
NSNumber *salePriceValue = salePriceDictionary[@"value"];
if (salePrice != nil) {
dataModel.salePriceValue = salePriceValue;
}
SNRContentWidgetBadgeDataModel *badgeDataModel = [[SNRContentWidgetBadgeDataModel alloc] initWithBackgroundColor:backgroundColor textColor:textColor text:text];
dataModel.badge = badgeDataModel;
return dataModel;
}
SNRContentWidgetGridLayout *gridLayout = [SNRContentWidgetGridLayout new];
gridLayout.insets = UIEdgeInsetsMake(16.0f, 16.0f, 16.0f, 16.0f);
gridLayout.itemSize = CGSizeMake(150.0f, 350.0f);
gridLayout.horizontalItemSpacing = 8.0f;
gridLayout.verticalItemSpacing = 8.0f;
SNRContentWidgetImageButtonCustomAction *actionButton = [SNRContentWidgetImageButtonCustomAction new];
actionButton.backgroundColor = [UIColor clearColor];
actionButton.tintColor = [UIColor blackColor];
actionButton.image = [UIImage imageNamed:@"Shop Flow/icon_favorite_add"];
actionButton.isSelectable = YES
actionButton.selectedImage = [UIImage imageNamed:@"Shop Flow/icon_favorite_remove"];
actionButton.size = CGSizeMake(40.0f, 40.0f);
actionButton.predefinedActionType = SNRContentWidgetBaseCustomActionPredefiniedActionTypeSendLikeEvent;
actionButton.onReceiveClickAction = ^(SNRBaseModel *model, BOOL isSelected) {
NSLog(@"Content Widget did receive click action for action button %@", ((SNRRecommednation *)recommendationModel.title));
};
actionButton.isSelected = ^(SNRBaseModel *model) {
return NO;
};
itemLayout.actionButton = actionButton
itemLayout.actionButtonPosition = CGPointMake((150.0f - 40.0f - 8), 8.0f)
SNRContentWidgetAppearance *appearance = [[SNRContentWidgetAppearance alloc] initWithLayout:gridLayout andItemLayout:itemLayout];
SNRContentWidget *widget = [[SNRContentWidget alloc] initWithOptions:options andAppearance:appearance];
widget.delegate = self;
[widget load];
}
#pragma mark - UITableViewDataSource, UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 10) {
if (self.widget != nil && [self.widget isLoaded] == YES) {
return [((ContentWidgetGridLayout *)widget.layout) getSizeForPreferredWidth:tableView.bounds.size.width].height;
} else {
return 0;
}
}
return 100.0f;
}
#pragma mark - SNRContentWidgetDelegate
- (void)SNR_widget:(SNRContentWidget *)widget isLoading:(BOOL)isLoading {
NSLog(@"Content Widget is loading: %@", isLoading ?? @"true" : @"false");
}
- (void)SNR_widgetDidLoad:(SNRContentWidget *)widget {
NSLog(@"Content Widget did load");
UIView *widgetView = [self.widget getView];
CGSize widgetSize = [((SNRContentWidgetHorizontalSliderLayout *)widget.layout getSize];
[self.widgetContainerView addSubview:widgetView];
widgetView.translatesAutoresizingMaskIntoConstraints = NO;
[widgetView.topAnchor constraintEqualTo:widgetContainerView.topAnchor].active = YES;
[widgetView.bottomAnchor constraintEqualTo:widgetContainerView.bottomAnchor].active = YES;
[widgetView.leftAnchor constraintEqualTo:widgetContainerView.leftAnchor].active = YES;
[widgetView.rightAnchor constraintEqualTo:widgetContainerView.rightAnchor].active = YES;
[widgetContainerView.heightAnchor constraintEqualToConstant:widgetSize.height].active = YES;
}
- (void)SNR_widget:(SNRContentWidget *)widget didNotLoadWithError:(NSError *)error {
NSLog(@"Content Widget did not load. Error: %@", error.localizedDescription);
}
- (void)SNR_widget:(SNRContentWidget *)widget didChangeToSize:(CGSize)size {
NSLog(@"Content Widget did change size to %@", NSStringFromCGSize(size));
}
- (void)SNR_widget:(SNRContentWidget *)widget didReceiveClickActionForModel:(SNRBaseModel *)model {
if ([model isKindOfClass:[SNRRecommendation class]] == YES) {
SNRRecommendation *recommendationModel = ((SNRRecommendation *)model);
NSLog(@"Content Widget did receive click action for %@", recommendationModel.title);
}
}
@end
```
### More information
---
You can find more information under the following links:
- [Sample App on GitHub](https://github.com/Synerise/ios-sdk/tree/master/SampleAppSwift/4.1.0)
- [Horizontal Slider implementation in the Sample App on GitHub](https://github.com/Synerise/synerise-ios-sdk/blob/master/SampleAppSwift/4.1.0/SampleAppSwift/Main/Developer%20Tools%20Flow/ViewControllers/ContentAPI/RecommendationsWidgetAsSliderTableViewController.swift)
- [Grid implementation in the Sample App on GitHub](https://github.com/Synerise/synerise-ios-sdk/blob/master/SampleAppSwift/4.1.0/SampleAppSwift/Main/Developer%20Tools%20Flow/ViewControllers/ContentAPI/RecommendationsWidgetAsGridTableViewController.swift)
# Huawei integration in Android SDK
## Enable integration in the Synerise platform
Before you start integrating Huawei services in your app, you must configure the integration in Synerise platform. For instructions, see ["Huawei integration"](/docs/settings/tool/huawei-integration).
## Configuration
In order to integrate Huawei Mobile Services with Synerise, you must add `.mesaggingServiceType(MessagingServiceType)` to your `Synerise.Builder`.
We recommend passing `MessagingServiceType.HMS` as an argument when you build the app for AppGallery.
More information about `Synerise.Builder` is available in ["Configuration"](/developers/mobile-sdk/installation-and-configuration/android#configuration).
## Implementing Huawei notifications in applications
1. Register your service in the AndroidManifest:
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
...
<service
android:name=".service.MyPushService"
android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
2. In `onRegisterForPush`, pass the huaweiToken using the [`Client.registerForPush(token, pushAgreement)` method](/developers/mobile-sdk/method-reference/android/campaigns#register-for-push-notifications).
3. Add the Huawei registration method:
kotlin
```kotlin
override fun onNewToken(p0: String?, p1: Bundle?) {
super.onNewToken(p0, p1)
val call = Client.registerForPush(p0!!, true)
call.execute(
{
Log.i(TAG, "Register for Push succeed: $p0")
}
) { apiError: Any? ->
Log.i(TAG, "Register for push failed:" + apiError.toString())
}
Log.i(TAG, p0!!)
Log.i(TAG, "receive token: $p0")
}
```
1. Pass the incoming push notification payload to the `Injector` in your `HmsMessageService` implementation:
kotlin
```kotlin
val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
override fun onMessageReceived(p0: RemoteMessage?) {
super.onMessageReceived(p0)
val data: Map = p0!!.dataOfMap
scope.launch {
Injector.handlePushPayload(data)
}
}
```
For more information, visit [Huawei Codelab](https://developer.huawei.com/consumer/en/codelab/HMSPushKit/index.html#0).
## Links and Deep Links
In order to implement links and deep links, refer to [this](/developers/mobile-sdk/campaigns/action-handling#handling-actions-from-campaigns-in-android) instruction.
## Configuring notification encryption
Instructions for encrypting push notifications are available [here](/developers/mobile-sdk/configuring-push-notifications/android#configure-notification-encryption).
# Customer authentication
---
## Set Client State listener
---
This method sets callbacks for a customer's state changes.
**Declared In:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientStateChangeListener](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#client-state-listener)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public setClientStateChangeListener(listener: IClientStateChangeListener)
**Discussion:**
Learn more about the methods and the purpose of this listener [here](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#client-state-listener).
## 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](/developers/mobile-sdk/user-identification-and-authorization/overview).
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:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientAccountRegisterContext](/developers/mobile-sdk/class-reference/react-native/client#clientaccountregistercontext)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public registerAccount(context: ClientAccountRegisterContext, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientAccountRegisterContext](/developers/mobile-sdk/class-reference/react-native/client#clientaccountregistercontext) | yes | - | Object with the customer's email, password, and other optional data |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
let email = "EMAIL";
let password = "PASSWORD";
let context = new ClientAccountRegisterContext(email, password);
context.phone = '123456789';
context.customId = '000111';
context.firstName = 'John';
context.lastName = 'Rise';
context.sex = ClientSex.Male;
context.company = 'Synerise';
context.address = 'Marszałkowska';
context.city = 'Warszawa';
context.province = 'Mazowieckie';
context.zipCode = '00-000';
context.countryCode = 'PL';
context.agreements = new ClientAgreements({
email: true,
sms: false,
push: true,
bluetooth: false,
rfid: true,
wifi: false
});
context.attributes = { ATTRIBUTE_1: 'ATTRIBUTE_1' }
context.tags = ['TAG_1', 'TAG_2']
Synerise.Client.registerAccount(context, function() {
// success
}, function(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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public requestAccountActivation(email: string, onSuccess: () => void, onError: (error: Error) => void)
Before version 1.0.0, this method was called `activateAccount`.
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | string | yes | - | Customer's email |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
TypeScript
```TypeScript
Synerise.Client.requestAccountActivation("EMAIL", function() {
// success
}, function(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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public confirmAccountActivation(token: string, onSuccess: () => void, onError: (error: Error) => void)
Before version 1.0.0, this method was called `confirmAccount`.
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | string | yes | - | Customer's token provided by email |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.confirmAccountActivation("TOKEN", function() {
// success
}, function(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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public requestAccountActivationByPin(email: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | string | yes | - | Customer's email |
| **onSuccess** | Function | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
## 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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public confirmAccountActivationByPin(pinCode: string, email: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **pinCode** | string | yes | - | Code sent to a customer's email |
| **email** | string | yes | - | Customer's email |
| **onSuccess** | Function | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
## 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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public signIn(email: string, password: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | string | yes | - | Customer's email |
| **password** | string | yes | - | Customer's password |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
let email = "EMAIL";
let password = "PASSWORD";
Synerise.Client.signIn(email, password, function() {
// success
}, function(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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public signInConditionally(email: string, password: string, onSuccess: (authResult: ClientConditionalAuthResult) => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | string | yes | - | Customer's email |
| **password** | string | yes | - | Customer's password |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
let email = "EMAIL";
let password = "PASSWORD";
Synerise.Client.signInConditionally(email, password, function(clientConditionalAuthResult) {
// success
}, function(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:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientAuthContext](/developers/mobile-sdk/class-reference/react-native/client#clientauthcontext)
[ClientIdentityProvider](/developers/mobile-sdk/class-reference/react-native/client#clientidentityprovider)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public authenticate(token: string, provider: ClientIdentityProvider, context: ClientAuthContext, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | string | yes | - | Token retrieved from provider |
| **clientIdentityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/react-native/client#clientidentityprovider) | yes | - | Provider of your token |
| **context** | [ClientAuthContext](/developers/mobile-sdk/class-reference/react-native/client#clientauthcontext) | yes | - | Object which wraps around agreements, attributes and authId |
| **onSuccess** | Function | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.authenticate(token, ClientIdentityProvider.Oauth, context, function() {
// success
}, function(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:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientAuthContext](/developers/mobile-sdk/class-reference/react-native/client#clientauthcontext)
[ClientIdentityProvider](/developers/mobile-sdk/class-reference/react-native/client#clientidentityprovider)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public authenticateConditionally(token: string, provider: ClientIdentityProvider, context: ClientAuthContext, onSuccess: (authResult: ClientConditionalAuthResult) => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | string | yes | - | Token retrieved from provider |
| **clientIdentityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/react-native/client#clientidentityprovider) | yes | - | Provider of your token |
| **context** | [ClientAuthContext](/developers/mobile-sdk/class-reference/react-native/client#clientauthcontext) | no | - | Object which contains agreements, attributes, and identifier of authorization |
| **onSuccess** | Function | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.authenticateConditionally(token, ClientIdentityProvider.Oauth, context, function(clientConditionalAuthResult) {
// success
}, function(error) {
// failure
})
```
## 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:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientSimpleAuthenticationData](/developers/mobile-sdk/class-reference/react-native/client#clientsimpleauthenticationdata)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public simpleAuthentication(data: ClientSimpleAuthenticationData, authID: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **data** | [ClientSimpleAuthenticationData](/developers/mobile-sdk/class-reference/react-native/client#clientsimpleauthenticationdata) | yes | - | Object which contains customer data |
| **authID** | string | yes | - | Required identifier of authorization |
| **onSuccess** | Function | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
TypeScript
```TypeScript
let data: ClientSimpleAuthenticationData = new ClientSimpleAuthenticationData();
context.email = "EMAIL";
context.firstName = "FIRST_NAME";
let authID: String = "AUTH_ID"
Synerise.Client.simpleAuthentication(data, authID, function() {
// success
}, function(error) {
// failure
})
```
## 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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public isSignedIn(): boolean
**Return Value:**
**true** if the customer is signed in, otherwise returns **false**.
**Example:**
JavaScript
```JavaScript
let isSignedIn = Synerise.Client.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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public isSignedInViaSimpleAuthentication(): boolean
**Return Value:**
**true** if the customer is signed in (via Simple Profile Authentication), otherwise returns **false**.
**Example:**
JavaScript
```JavaScript
let isSignedIn = Synerise.Client.isSignedInViaSimpleAuthentication();
```
## Sign out a 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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public signOut()
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.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:
- `.signOut` mode signs out the customer.
- `.signOutWithSessionDestroy` mode 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:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientSignOutMode](/developers/mobile-sdk/class-reference/react-native/client#clientsignoutmode)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public signOutWithMode(mode: ClientSignOutMode, fromAllDevices: boolean, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **mode** | [ClientSignOutMode](/developers/mobile-sdk/class-reference/react-native/client#clientsignoutmode) | yes | - | Mode of signing out |
| **fromAllDevices** | Bool | yes | - | Determines if the method should sign out all devices |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.signOutWithMode(
ClientSignOutMode.SignOutWithSessionDestroy,
true,
() => {
this.setState({
isLoading: false,
isSignedIn: true,
})
},
(error) => {
this.setState({
isLoading: false,
isSignedIn: false,
})
console.log('ERROR: ' + error.message);
}
)
```
## Deprecated 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.
**Declared In:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientOAuthAuthenticationContext](/developers/mobile-sdk/class-reference/react-native/client#clientoauthauthenticationcontext)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public authenticateByOAuth(accessToken: string, context: ClientOAuthAuthenticationContext, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **accessToken** | string | yes | - | OAuth Access Token |
| **clientOAuthContext** | [ClientOAuthAuthenticationContext](/developers/mobile-sdk/class-reference/react-native/client#clientoauthauthenticationcontext) | yes | - | Object which contains agreements, attributes, and identifier of authorization |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.authenticateByOAuth(token, context, function() {
// success
}, function(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.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public authenticateByOAuthIfRegistered(accessToken: string, authID: string | null, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **accessToken** | string | yes | - | OAuth Access Token |
| **authID** | string | no | null | Optional identifier of authorization |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function 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:**
JavaScript
```JavaScript
Synerise.Client.authenticateByOAuthIfRegistered(accessToken, authID, function() {
// success
}, function(error) {
// failure
})
```
### 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.
**Declared In:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientFacebookAuthenticationContext](/developers/mobile-sdk/class-reference/react-native/client#clientfacebookauthenticationcontext)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public authenticateByFacebook(facebookToken: string, context: ClientFacebookAuthenticationContext, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **facebookToken** | string | yes | - | Facebook Access Token |
| **clientFacebookAuthenticationContext** | [ClientFacebookAuthenticationContext](/developers/mobile-sdk/class-reference/react-native/client#clientfacebookauthenticationcontext) | yes | - | Object which contains agreements, attributes, and identifier of authorization |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.authenticateByFacebook(token, clientFacebookAuthenticationContext, function(clientConditionalAuthResult) {
// success
}, function(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.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public authenticateByFacebookIfRegistered(facebookToken: string, authID: string | null, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **facebookToken** | string | yes | - | Facebook Access Token |
| **authID** | string | no | null | Optional identifier of authorization |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function 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:**
JavaScript
```JavaScript
Synerise.Client.authenticateByFacebookIfRegistered(facebookToken, authID, function() {
// success
}, function(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 |
**Declared In:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientAppleSignInAuthenticationContext](/developers/mobile-sdk/class-reference/react-native/client#clientapplesigninauthenticationcontext)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public authenticateByAppleSignIn(identityToken: string, context: ClientAppleSignInAuthenticationContext, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **identityToken** | string | yes | - | Apple Identity Token |
| **context** | [ClientAppleSignInAuthenticationContext](/developers/mobile-sdk/class-reference/react-native/client#clientapplesigninauthenticationcontext) | yes | - | Object which contains agreements, attributes, and identifier of authorization |
| **success** | Function | no | - | Function to be executed when the operation is completed successfully |
| **failure** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
### 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 |
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public authenticateByAppleSignInIfRegistered(identityToken: string, authID: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **identityToken** | string | yes | - | Apple Identity Token |
| **authID** | string | no | null | Optional identifier of authorization |
| **success** | Function | no | - | Function to be executed when the operation is completed successfully |
| **failure** | Function | no | - | Function 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.
# Client
### ClientIdentityProvider
**Declared In:**
Headers/SNRClientIdentityProvider.h
**Declaration:**
Swift Objective-C
```Swift
enum ClientIdentityProvider: Int {
synerise,
oauth,
simpleAuth,
facebook,
apple,
google
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRClientIdentityProvider) {
SNRClientIdentityProviderSynerise,
SNRClientIdentityProviderOAuth,
SNRClientIdentityProviderSimpleAuth,
SNRClientIdentityProviderFacebook,
SNRClientIdentityProviderApple,
SNRClientIdentityProviderGoogle
}
```
**Functions:**
Converts from **ClientIdentityProvider** to **String**.
Swift Objective-C
```Swift
func SNR_ClientIdentityProviderToString(_: ClientIdentityProvider) -> String
```
```Objective-C
NSString * SNR_ClientIdentityProviderToString(SNRClientIdentityProvider type)
```
---
Converts from **String** to **ClientIdentityProvider**.
Swift Objective-C
```Swift
func SNR_StringToClientIdentityProvider(_: String) -> ClientIdentityProvider
```
```Objective-C
SNRClientIdentityProvider SNR_StringToClientIdentityProvider(NSString * _Nullable string)
```
---
---
### ClientConditionalAuthenticationContext
**Declared In:**
Headers/SNRClientConditionalAuthContext.h
**Related To:**
[ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientConditionalAuthContext: BaseModel
```
```Objective-C
@interface SNRClientConditionalAuthContext : SNRBaseModel
```
**Properties:**
Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements) | yes | nil | Object that stores all agreements of a customer |
| **attributes** | [AnyHashable: Any] | yes | [] | Additional custom attributes of a customer |
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
---
---
### ClientAuthenticationContext
**Declared In:**
Headers/SNRClientAuthenticationContext.h
**Related To:**
[ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientAuthenticationContext: BaseModel
```
```Objective-C
@interface SNRClientAuthenticationContext : SNRBaseModel
```
**Properties:**
Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements) | yes | nil | Object that stores all agreements of a customer |
| **attributes** | [AnyHashable: Any] | yes | [] | Additional custom attributes of a customer |
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
---
---
### ClientConditionalAuthResult
**Declared In:**
Headers/SNRClientConditionalAuthResult.h
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientConditionalAuthResult: BaseModel
```
```Objective-C
@interface SNRClientConditionalAuthResult : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **isSuccess** | Bool | no | Result of authentication operation |
| **token** | String | yes | Token as a raw string |
| **status** | [ClientConditionalAuthStatus](/developers/mobile-sdk/class-reference/ios/client#clientconditionalauthstatus) | no | Status of the authentication |
| **conditions** | [AnyObject] | yes | Authentication conditions |
All properties are read-only.
---
---
### ClientConditionalAuthStatus
**Declared In:**
Headers/SNRClientConditionalAuthStatus.h
**Declaration:**
Swift Objective-C
```Swift
enum ClientConditionalAuthStatus: Int {
success,
unauthorized,
activationRequired,
registrationRequired,
approvalRequired,
termsAcceptanceRequired,
mfaRequired,
unknown
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRClientConditionalAuthStatus) {
SNRClientConditionalAuthStatusSuccess,
SNRClientConditionalAuthStatusUnauthorized,
SNRClientConditionalAuthStatusActivationRequired,
SNRClientConditionalAuthStatusRegistrationRequired,
SNRClientConditionalAuthStatusApprovalRequired,
SNRClientConditionalAuthStatusTermsAcceptanceRequired,
SNRClientConditionalAuthStatusMFARequired,
SNRClientConditionalAuthStatusUnknown
}
```
**Functions:**
Converts from **ClientConditionalAuthStatus** to **String**.
Swift Objective-C
```Swift
func SNR_ClientConditionalAuthStatusToString(_: ClientConditionalAuthStatus) -> String
```
```Objective-C
NSString * SNR_ClientConditionalAuthStatusToString(SNRClientConditionalAuthStatus status)
```
---
Converts from **String** to **ClientConditionalAuthStatus**.
Swift Objective-C
```Swift
func SNR_StringToClientConditionalAuthStatus(_: String) -> ClientConditionalAuthStatus
```
```Objective-C
SNRClientConditionalAuthStatus SNR_StringToClientConditionalAuthStatus(NSString * _Nullable string)
```
---
---
### ClientSimpleAuthenticationData
**Declared In:**
Headers/SNRClientSimpleAuthenticationData.h
**Related To:**
[ClientSex](/developers/mobile-sdk/class-reference/ios/client#clientsex)
[ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientSimpleAuthenticationData: BaseModel
```
```Objective-C
@interface SNRClientSimpleAuthenticationData : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **email** | String | yes | Customer's email |
| **phone** | String | yes | Customer's phone |
| **customId** | String | yes | Customer's custom ID |
| **uuid** | String | yes | Customer's UUID |
| **firstName** | String | yes | Customer's first name |
| **lastName** | String | yes | Customer's last name |
| **displayName** | String | yes | Customer's display name |
| **sex** | [ClientSex](/developers/mobile-sdk/class-reference/ios/client#clientsex) | yes | Customer's sex |
| **company** | String | yes | Customer's company |
| **address** | String | yes | Customer's address |
| **city** | String | yes | Customer's city |
| **province** | String | yes | Customer's province |
| **zipCode** | String | yes | Customer's ZIP code |
| **countryCode** | String | yes | Customer's country code |
| **birthDate** | String | yes | Customer's birthdate |
| **avatarUrl** | String | yes | Customer's avatar URL |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements) | yes | Customer's agreements |
| **attributes** | [AnyHashable: Any] | yes | Customer's attributes |
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
---
---
### ClientSessionEndReason
**Declared In:**
Headers/SNRClientSessionEndReason.h
**Declaration:**
Swift Objective-C
```Swift
enum ClientSessionEndReason: Int {
userSignOut,
systemSignOut,
sessionExpiration,
securityException,
clientRejected,
userAccountDeleted
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRClientSessionEndReason) {
SNRClientSessionEndReasonUserSignOut,
SNRClientSessionEndReasonSystemSignOut,
SNRClientSessionEndReasonSessionExpiration,
SNRClientSessionEndReasonSessionDestroyed,
SNRClientSessionEndReasonSecurityException,
SNRClientSessionEndReasonClientRejected,
SNRClientSessionEndReasonUserAccountDeleted
}
```
---
---
### ClientSignOutMode
**Declared In:**
Headers/SNRClientSignOutMode.h
**Declaration:**
Swift Objective-C
```Swift
enum ClientSignOutMode: Int {
.signOut,
.signOutWithSessionDestroy
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRClientSignOutMode) {
SNRClientSignOutModeSignOut,
SNRClientSignOutModeSignOutWithSessionDestroy
}
```
---
---
### ClientAccountInformation
**Declared In:**
Headers/SNRClientAccountInformation.h
**Related To:**
[ClientSex](/developers/mobile-sdk/class-reference/ios/client#clientsex)
[ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Conforms To:**
[NSSecureCoding](https://developer.apple.com/documentation/foundation/nssecurecoding)
**Declaration:**
Swift Objective-C
```Swift
class ClientAccountInformation: BaseModel
```
```Objective-C
@interface SNRClientAccountInformation : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **clientId** | Int | no | Customer's ID |
| **email** | String | no | Customer's email |
| **phone** | String | yes | Customer's phone |
| **customId** | String | yes | Customer's custom ID |
| **uuid** | String | no | Customer's UUID |
| **firstName** | String | yes | Customer's first name |
| **lastName** | String | yes | Customer's last name |
| **displayName** | String | yes | Customer's display name |
| **sex** | [ClientSex](/developers/mobile-sdk/class-reference/ios/client#clientsex) | no | Customer's sex |
| **company** | String | yes | Customer's company |
| **address** | String | yes | Customer's address |
| **city** | String | yes | Customer's city |
| **province** | String | yes | Customer's province |
| **zipCode** | String | yes | Customer's ZIP code |
| **countryCode** | String | yes | Customer's country code |
| **birthDate** | String | yes | Customer's birthdate |
| **lastActivityDate** | Date | no | Customer's last activity date |
| **avatarUrl** | String | yes | Customer's avatar URL |
| **anonymous** | Bool | no | Customer's anonymous flag |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements) | no | Customer's agreements |
| **attributes** | [AnyHashable: Any] | yes | Customer's attributes |
| **tags** | [String] | yes | Customer's tags |
All properties are read-only.
---
---
### ClientUpdateAccountBasicInformationContext
**Declared In:**
Headers/SNRClientUpdateAccountBasicInformationContext.h
**Related To:**
[ClientSex](/developers/mobile-sdk/class-reference/ios/client#clientsex)
[ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Conforms To:**
[NSSecureCoding](https://developer.apple.com/documentation/foundation/nssecurecoding)
**Declaration:**
Swift Objective-C
```Swift
class ClientUpdateAccountBasicInformationContext: BaseModel
```
```Objective-C
@interface SNRClientUpdateAccountBasicInformationContext : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **firstName** | String | yes | Customer's first name |
| **lastName** | String | yes | Customer's last name |
| **displayName** | String | yes | Customer's display name |
| **sex** | [ClientSex](/developers/mobile-sdk/class-reference/ios/client#clientsex) | yes | Customer's sex |
| **phone** | String | yes | Customer's phone |
| **company** | String | yes | Customer's company |
| **address** | String | yes | Customer's address |
| **city** | String | yes | Customer's city |
| **province** | String | yes | Customer's province |
| **zipCode** | String | yes | Customer's ZIP code |
| **countryCode** | String | yes | Customer's country code |
| **birthDate** | String | yes | Customer's birthdate |
| **avatarUrl** | String | yes | Customer's avatar URL |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements) | no | Customer's agreements |
| **attributes** | [AnyHashable: Any] | yes | Customer's attributes |
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
---
---
### ClientUpdateAccountContext
**Declared In:**
Headers/SNRClientUpdateAccountContext.h
**Related To:**
[ClientSex](/developers/mobile-sdk/class-reference/ios/client#clientsex)
[ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Conforms To:**
[NSSecureCoding](https://developer.apple.com/documentation/foundation/nssecurecoding)
**Declaration:**
Swift Objective-C
```Swift
class ClientUpdateAccountContext: BaseModel
```
```Objective-C
@interface SNRClientUpdateAccountContext : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **email** | String | yes | Customer's email |
| **phone** | String | yes | Customer's phone |
| **customId** | String | yes | Customer's custom ID |
| **uuid** | String | yes | Customer's UUID |
| **firstName** | String | yes | Customer's first name |
| **lastName** | String | yes | Customer's last name |
| **displayName** | String | yes | Customer's display name |
| **sex** | [ClientSex](/developers/mobile-sdk/class-reference/ios/client#clientsex) | yes | Customer's sex |
| **company** | String | yes | Customer's company |
| **address** | String | yes | Customer's address |
| **city** | String | yes | Customer's city |
| **province** | String | yes | Customer's province |
| **zipCode** | String | yes | Customer's ZIP code |
| **countryCode** | String | yes | Customer's country code |
| **birthDate** | String | yes | Customer's birthdate |
| **avatarUrl** | String | yes | Customer's avatar URL |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements) | no | Customer's agreements |
| **attributes** | [AnyHashable: Any] | yes | Customer's attributes |
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
---
---
### ClientRegisterAccountContext
**Declared In:**
Headers/SNRClientRegisterAccountContext.h
**Related To:**
[ClientSex](/developers/mobile-sdk/class-reference/ios/client#clientsex)
[ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientRegisterAccountContext: BaseModel
```
```Objective-C
@interface SNRClientRegisterAccountContext : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **email** | String | no | Customer's email |
| **password** | String | no | Customer's password |
| **firstName** | String | yes | Customer's first name |
| **lastName** | String | yes | Customer's last name |
| **customId** | String | yes | Customer's custom ID |
| **sex** | [ClientSex](/developers/mobile-sdk/class-reference/ios/client#clientsex) | yes | Customer's sex |
| **phone** | String | yes | Customer's phone |
| **company** | String | yes | Customer's company |
| **address** | String | yes | Customer's address |
| **city** | String | yes | Customer's city |
| **province** | String | yes | Customer's province code |
| **zipCode** | String | yes | Customer's ZIP code |
| **countryCode** | String | yes | Customer's country code |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements) | yes | Customer's agreements |
| **attributes** | [AnyHashable: Any] | yes | Customer's attributes |
**Initializers:**
Swift Objective-C
```Swift
init(email: String, password: String)
```
```Objective-C
- (instancetype)initWithEmail:(nonnull NSString *)email andPassword:(nonnull NSString *)password
```
---
---
### ClientPasswordResetRequestContext
**Declared In:**
Headers/SNRClientPasswordResetRequestContext.h
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientPasswordResetRequestContext: BaseModel
```
```Objective-C
@interface SNRClientPasswordResetRequestContext : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **email** | Bool | no | Customer's email |
**Initializers:**
Swift Objective-C
```Swift
init(email: String)
```
```Objective-C
- (instancetype)initWithEmail:(nonnull NSString *)email
```
---
---
### ClientPasswordResetConfirmationContext
**Declared In:**
Headers/SNRClientPasswordResetConfirmationContext.h
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientPasswordResetConfirmationContext: BaseModel
```
```Objective-C
@interface SNRClientPasswordResetConfirmationContext : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **password** | String | no | Customer's password |
| **token** | String | no | Customer's token |
**Initializers:**
Swift Objective-C
```Swift
init(password: String, token: String)
```
```Objective-C
- (instancetype)initWithPassword:(nonnull NSString *)password andToken:(nonnull NSString *)token
```
---
---
### ClientSex
**Declared In:**
Headers/SNRClientSex.h
**Declaration:**
Swift Objective-C
```Swift
enum ClientSex: Int {
notSpecified,
male,
female,
other
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRClientSex) {
SNRClientSexNotSpecified = 0,
SNRClientSexMale,
SNRClientSexFemale,
SNRClientSexOther,
}
```
**Functions:**
Converts from **ClientSex** to **String**.
Swift Objective-C
```Swift
func SNR_ClientSexToString(_: ClientSex) -> String
```
```Objective-C
NSString * SNR_ClientSexToString(SNRClientSex type)
```
Converts from **String** to **ClientSex**.
Swift Objective-C
```Swift
func SNR_StringToClientSex(_: String) -> ClientSex
```
```Objective-C
SNRClientSex SNR_StringToClientSex(NSString * _Nullable string)
```
---
---
### ClientAgreements
**Declared In:**
Headers/SNRClientAgreements.h
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Conforms To:**
[NSSecureCoding](https://developer.apple.com/documentation/foundation/nssecurecoding)
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class ClientAgreements: BaseModel
```
```Objective-C
@interface SNRClientAgreements : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **email** | Bool | no | Email agreement |
| **sms** | Bool | no | SMS agreement |
| **push** | Bool | no | Push notifications agreement |
| **bluetooth** | Bool | no | Bluetooth agreement |
| **rfid** | Bool | no | RFID agreement |
| **wifi** | Bool | no | WIFI agreement |
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
---
---
### ClientEventData
**Declared In:**
Headers/SNRClientEventData.h
**Related To:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientEventData: BaseModel
```
```Objective-C
@interface SNRClientEventData : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **time** | String | no | Event's time |
| **label** | String | no | Event's label |
| **action** | String | no | Event's action |
| **client** | [AnyHashable: Any] | no | Event's customer identification |
| **params** | [AnyHashable: Any] | no | Event's parameters |
All properties are read-only.
**Methods:**
This method retrieves a customer ID.
Swift Objective-C
```Swift
func getClientID() -> Int
```
```Objective-C
- (NSInteger)getClientID
```
---
This method retrieves a customer UUID.
Swift Objective-C
```Swift
func getClientUUIDString() -> String?
```
```Objective-C
- (nullable NSString *)getClientUUIDString
```
---
This method retrieves a customer email.
Swift Objective-C
```Swift
func getClientEmail() -> String?
```
```Objective-C
- (nullable NSString *)getClientEmail
```
---
---
### ClientEventsApiQuery
The object to set parameters easily for fetching client events from API.
**Declared In:**
Headers/SNRClientEventsApiQuery.h
**Inherits From:**
[NSObject](https://developer.apple.com/documentation/objectivec/nsobject)
**Declaration:**
Swift Objective-C
```Swift
class ClientEventsApiQuery: NSObject
```
```Objective-C
@interface SNRClientEventsApiQuery : NSObject
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **actions** | [String] | no | [] | Specifies event actions for query |
| **timeFrom** | String | yes | nil | Specifies time from for query |
| **timeTo** | String | yes | nil | Specifies time to for query |
| **limit** | String | no | 100 | Limit of items in the response |
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
---
---
### TokenPayload
**Declared In:**
Headers/SNRTokenPayload.h
**Related To:**
[TokenOrigin](/developers/mobile-sdk/class-reference/ios/client#tokenorigin)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class TokenPayload: BaseModel
```
```Objective-C
@interface SNRTokenPayload : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **tokenString** | String | no | Token as a raw string |
| **expirationDate** | Date | no | Token's expiration time |
| **creationDate** | Date | no | Token's creation time |
| **rlm** | String | no | Token's RLM |
| **origin** | [TokenOrigin](/developers/mobile-sdk/class-reference/ios/client#tokenorigin) | no | Token's origin |
| **uuid** | String | no | Customer's UUID |
| **clientId** | String | no | Customer's ID |
| **customId** | String | yes | Customer's custom ID |
**Initializers:**
Swift Objective-C
```Swift
init(tokenString: String, expirationDate: Date, creationDate: Date, rlm: String, origin: TokenOrigin, uuid: String, clientId: String, customId: String?)
```
```Objective-C
- (instancetype)initWithTokenString:(NSString *)tokenString expirationDate:(NSDate *)expirationDate creationDate:(NSDate *)creationDate rlm:(NSString *)rlm origin:(SNRTokenOrigin)origin uuid:(NSString *)uuid clientId:(NSString *)clientId customId:(nullable NSString *)customId;
```
---
---
### Token
**Declared In:**
Headers/SNRToken.h
**Related To:**
[TokenOrigin](/developers/mobile-sdk/class-reference/ios/client#tokenorigin)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class Token: BaseModel
```
```Objective-C
@interface SNRToken : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **tokenString** | String | no | Token as a raw string |
| **expirationDate** | String | no | Token's expiration time |
| **rlm** | String | no | Token's RLM |
| **origin** | [TokenOrigin](/developers/mobile-sdk/class-reference/ios/client#tokenorigin) | no | Token's origin |
| **clientId** | String | no | Customer's ID |
| **customId** | String | yes | Customer's custom ID |
**Methods:**
Checks if the token is near expiration.
Swift Objective-C
```Swift
func isNearExpiring() -> Bool
```
```Objective-C
- (BOOL)isNearExpiring
```
---
---
### TokenOrigin
The `Oauth` value was renamed in 5.0.0 version to `OAuth`.
**Declared In:**
Headers/SNRTokenOrigin.h
**Declaration:**
Swift Objective-C
```Swift
enum TokenOrigin: Int {
unknown,
synerise,
simpleAuth,
facebook,
OAuth,
apple
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRTokenOrigin) {
SNRTokenOriginUnknown,
SNRTokenOriginSynerise,
SNRTokenOriginSimpleAuth,
SNRTokenOriginFacebook,
SNRTokenOriginOAuth,
SNRTokenOriginApple
}
```
**Functions:**
Converts from **TokenOrigin** to **String**.
Swift Objective-C
```Swift
func SNR_TokenOriginToString(_: TokenOrigin) -> String
```
```Objective-C
NSString * SNR_TokenOriginToString(SNRTokenOrigin type)
```
---
Converts from **String** to **TokenOrigin**.
Swift Objective-C
```Swift
func SNR_StringToTokenOrigin(_: String) -> TokenOrigin
```
```Objective-C
SNRTokenOrigin SNR_StringToTokenOrigin(NSString *string)
```
---
---
## Removed symbols
---
### ClientOAuthAuthenticationContext{#clientoauthauthenticationcontext}
| | **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 |
**Declared In:**
Headers/SNRClientOAuthAuthenticationContext.h
**Related To:**
[ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientOAuthAuthenticationContext: BaseModel
```
```Objective-C
@interface SNRClientOAuthAuthenticationContext : SNRBaseModel
```
**Properties:**
Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements) | yes | nil | Object that stores all agreements of a customer |
| **attributes** | [AnyHashable: Any] | yes | [] | Additional custom attributes of a customer |
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
---
---
### ClientFacebookAuthenticationContext{#clientfacebookauthenticationcontext}
| | **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 |
**Declared In:**
Headers/SNRClientFacebookAuthenticationContext.h
**Related To:**
[ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientFacebookAuthenticationContext: BaseModel
```
```Objective-C
@interface SNRClientFacebookAuthenticationContext : SNRBaseModel
```
**Properties:**
Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements) | yes | nil | Object that stores all agreements of a customer |
| **attributes** | [AnyHashable: Any] | yes | [] | Additional custom attributes of a customer |
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
---
---
### ClientAppleSignInAuthenticationContext{#clientapplesigninauthenticationcontext}
| | **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 |
**Declared In:**
Headers/SNRClientAppleSignInAuthenticationContext.h
**Related To:**
[ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class ClientAppleSignInAuthenticationContext: BaseModel
```
```Objective-C
@interface SNRClientAppleSignInAuthenticationContext : SNRBaseModel
```
**Properties:**
Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/ios/client#clientagreements) | yes | nil | Object that stores all agreements of a customer |
| **attributes** | [AnyHashable: Any] | yes | [] | Additional custom attributes of a customer |
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
# Customer authentication
## Set Client State delegate
---
This method sets an object for a customer's state delegate methods.
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientStateDelegate](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#client-state-delegate)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func setClientStateDelegate(_ delegate: ClientStateDelegate)
```
```Objective-C
+ (void)setClientStateDelegate:(SNRClientStateDelegate *)delegate
```
**Discussion:**
Learn more about the methods and the purpose of this listener [here](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#client-state-delegate).
## 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](/developers/mobile-sdk/user-identification-and-authorization/overview).
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](/developers/mobile-sdk/class-reference/ios/client#clientregisteraccountcontext)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func registerAccount(context: ClientRegisterAccountContext, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)registerAccount:(nonnull SNRClientRegisterAccountContext *)context success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientRegisterAccountContext](/developers/mobile-sdk/class-reference/ios/client#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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
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
})
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func requestAccountActivation(email: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)requestAccountActivationWithEmail:(nonnull NSString *)email success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer's email |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let email: String = "EMAIL"
Client.requestAccountActivation(email: email, success: {
// success
}) { (error) in
// failure
}
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func confirmAccountActivation(token: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let token: String = "TOKEN"
Client.confirmAccountActivation(token: token, success: {
// success
}, failure: { (error) in
// failure
})
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func requestAccountActivationByPin(email: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)requestAccountActivationByPinWithEmail:(nonnull NSString *)email success:(nonnull void (^)(void))success failure:(nonnull void (^)(SNRApiError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer's email |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let email: String = "EMAIL"
Client.requestAccountActivationByPin(email: email, success: {
// success
}) { (error) in
// failure
}
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func confirmAccountActivationByPin(pinCode: String, email: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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 |
| **email** | String | yes | - | Customer's email |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let pinCode: String = "PIN_CODE"
let email: String = "EMAIL"
Client.confirmAccountActivationByPin(pinCode: pinCode, email: email, success: {
// success
}) { (error) in
// failure
}
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func signIn(email: String, password: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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 |
| --- | --- | --- | --- | --- |
| **email** | 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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let email: String = "EMAIL"
let password: String = "PASSWORD"
Client.signIn(email: email, password: password, success: {
// success
}, failure: { (error) in
// failure
})
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func signInConditionally(email: String, password: String, success: ((ClientAuthenticationResult) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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 |
| --- | --- | --- | --- | --- |
| **email** | 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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
let email: String = "EMAIL"
let password: String = "PASSWORD"
Client.signInConditionally(email: email, password: password, success: { (result) in
// success
}, failure: { (error) in
// failure
})
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/client#clientauthenticationcontext)
[ClientIdentityProivider](/developers/mobile-sdk/class-reference/ios/client#clientidentityprovider)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func authenticate(token: AnyObject, clientIdentityProvider: ClientIdentityProvider, authID: String?, context: ClientAuthenticationContext?, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/client#clientidentityprovider) | yes | - | Provider of your token |
| **authID** | String | no | nil | Optional identifier of authorization |
| **context** | [ClientAuthenticationContext](/developers/mobile-sdk/class-reference/ios/client#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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
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
}
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/client#clientconditionalauthresult)
[ClientIdentityProvider](/developers/mobile-sdk/class-reference/ios/client#clientidentityprovider)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/client)
**Declaration:**
Swift Objective-C
```Swift
static func authenticateConditionally(token: AnyObject, clientIdentityProvider: ClientIdentityProvider, authID: String?, context: ClientConditionalAuthenticationContext?, success: ((ClientAuthenticationResult) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/client#clientidentityprovider) | yes | - | Provider of your token |
| **authID** | String | no | nil | Optional identifier of authorization |
| **context** | [ClientConditionalAuthenticationContext](/developers/mobile-sdk/class-reference/ios/client#clientconditionalauthenticationcontext) | no | nil | Object which contains agreements and attributes |
| **success** | (([ClientConditionalAuthResult](/developers/mobile-sdk/class-reference/ios/client#clientconditionalauthenticationcontext)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
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
}
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/client#tokenpayload)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func authenticate(tokenPayload: TokenPayload, authID: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)authenticateWithTokenPayload:(SNRTokenPayload *)tokenPayload authID:(NSString *)authID success:(void (^)(void))success failure:(void (^)(SNRApiError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **tokenPayload** | [TokenPayload](/developers/mobile-sdk/class-reference/ios/client#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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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](/developers/mobile-sdk/class-reference/ios/client#clientsimpleauthenticationdata)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func simpleAuthentication(data: ClientSimpleAuthenticationData, authID: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)simpleAuthentication:(SNRClientSimpleAuthenticationData *)data authID:(NSString *)authID success:(void (^)(void))success failure:(void (^)(SNRApiError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **data** | [ClientSimpleAuthenticationData](/developers/mobile-sdk/class-reference/ios/client#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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func isSignedIn() -> Bool
```
```Objective-C
+ (BOOL)isSignedIn
```
**Return Value:**
**true** if the customer is signed in, otherwise returns **false**.
**Example:**
Swift Objective-C
```Swift
let isSignedIn: Bool = Client.isSignedIn()
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func isSignedInViaSimpleAuthentication() -> Bool
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func signOut() -> Void
```
```Objective-C
+ (void)signOut
```
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
Client.signOut()
```
```Objective-C
[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:
- `.signOut` mode signs out the customer.
- `.signOutWithSessionDestroy` mode 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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func signOut(mode: ClientSignOutMode, fromAllDevices: Bool, success: ((Bool) -> Void), failure: ((ApiError) -> Void))
```
```Objective-C
+ (void)signOutWithmode:(SNRClientSignOutMode)mode fromAllDevices:(BOOL)fromAllDevices success:(void (^)(void))success failure:(void (^)(SNRApiError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **mode** | [ClientSignOutMode](/developers/mobile-sdk/class-reference/ios/client#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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
Client.signOut(mode: .signOutWithSessionDestroy, fromAllDevices: true, success: {
// success
}) { (error) in
// failure
}
```
```Objective-C
[SNRClient signOutWithMode:SNRClientSignOutModeSignOutWithSessionDestroy fromAllDevices:YES success:^{
// success
} failure:^(SNRApiError *error) {
// failure
}];
```
## Removed methods
### Authenticate customer by OAuth with registration {#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](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-by-identityprovider)
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientOAuthAuthenticationContext](/developers/mobile-sdk/class-reference/ios/client#clientoauthauthenticationcontext)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func authenticateByOAuth(accessToken: String, authID: String?, context: ClientOAuthAuthenticationContext?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/client#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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
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
}
```
```Objective-C
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 {#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](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-conditionally-by-identityprovider)
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func authenticateByOAuthIfRegistered(accessToken: String, authID: String?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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 {#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](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-by-identityprovider)
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientFacebookAuthenticationContext](/developers/mobile-sdk/class-reference/ios/client#clientfacebookauthenticationcontext)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func authenticateByFacebook(facebookToken: String, authID: String?, context: ClientFacebookAuthenticationContext?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/client#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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
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
}
```
```Objective-C
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 {#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](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-conditionally-by-identityprovider)
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func authenticateByFacebookIfRegistered(facebookToken: String, authID: String?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
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
})
```
```Objective-C
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 {#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](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-by-identityprovider)
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientAppleSignInAuthenticationContext](/developers/mobile-sdk/class-reference/ios/client#clientapplesigninauthenticationcontext)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func authenticateByAppleSignIn(identityToken: Data, authID: String?, context: ClientAppleSignInAuthenticationContext?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/client#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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
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
}
}
}
}
```
```Objective-C
#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 {#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](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-conditionally-by-identityprovider)
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func authenticateByAppleSignInIfRegistered(identityToken: String, authID: String?, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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 {#sign-out-customer-with-mode}
---
This method signs out a customer out 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 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](/developers/mobile-sdk/method-reference/ios/client-authentication#sign-out-customer-with-mode-or-from-all-devices)
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func signOut(mode: ClientSignOutMode) -> Void
```
```Objective-C
+ (void)signOutWithmode:(SNRClientSignOutMode)mode
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **mode** | [ClientSignOutMode](/developers/mobile-sdk/class-reference/ios/client#clientsignoutmode) | yes | - | Mode of signing out |
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
Client.signOut(mode: .signOutWithSessionDestroy)
```
```Objective-C
[SNRClient signOutWithMode:SNRClientSignOutModeSignOutWithSessionDestroy];
```
# iOS
## iOS delegates
### SyneriseDelegate {id=synerise-delegate}
A delegate to handle the SDK lifecycle events.
To set your object as delegate, you must use [this method](/developers/mobile-sdk/method-reference/ios/lifecycle#set-synerise-delegate).
Swift Objective-C
```Swift
Synerise.setDelegate(YOUR_OBJECT)
```
```Objective-C
[SNRSynerise setDelegate:YOUR_OBJECT];
```
If optional methods for handling URL and deeplink are not implemented, SDK has a default behavior.
##### snr_initialized() {id=synerise-delegate-initialized}
This method is called when the Synerise SDK is initialized.
Swift Objective-C
```Swift
func snr_initialized() -> Void
```
```Objective-C
- (void)SNR_initialized
```
##### snr_initializationError(error: Error) {id=synerise-delegate-initialization-error}
This method is called when an error occurs while initializing the Synerise SDK.
Swift Objective-C
```Swift
func snr_initializationError(error: Error) -> Void
```
```Objective-C
- (void)SNR_initializationError:(NSError *)error
```
| Parameter | Type | Description |
| --- | --- | --- |
| **error** | NSError | The error that occurred. |
##### snr_registerForPushNotificationsIsNeeded() {id=synerise-delegate-register-for-push-notifications-is-needed}
This method is called when Synerise needs registration for push notifications.
See [Configuring push notifications](/developers/mobile-sdk/configuring-push-notifications/ios) for more details.
After invoking this method, you must invoke the [Client.registerForPush(registrationToken:mobilePushAgreement:success:failure:)](/developers/mobile-sdk/method-reference/ios/campaigns#register-for-push-notifications) method again.
This method is invoked when the **snr_registerForPushNotificationsIsNeeded(origin:)** method is not implemented.
Swift Objective-C
```Swift
func snr_registerForPushNotificationsIsNeeded() -> Void
```
```Objective-C
- (void)SNR_registerForPushNotificationsIsNeeded
```
##### snr_registerForPushNotificationsIsNeeded(origin: PushNotificationsRegistrationOrigin) {id=synerise-delegate-register-for-push-notifications-is-needed-by-origin}
This method is called when Synerise needs registration for push notifications.
See [Configuring push notifications](/developers/mobile-sdk/configuring-push-notifications/ios) for more details.
After invoking this method, you must invoke the [Client.registerForPush(registrationToken:mobilePushAgreement:success:failure:)](/developers/mobile-sdk/method-reference/ios/campaigns#register-for-push-notifications) method again.
Swift Objective-C
```Swift
func snr_registerForPushNotificationsIsNeeded(origin: PushNotificationsRegistrationOrigin) -> Void
```
```Objective-C
- (void)SNR_registerForPushNotificationsIsNeededByOrigin:(SNRPushNotificationsRegistrationOrigin)origin
```
| Parameter | Type | Description |
| --- | --- | --- |
| **origin** | [PushNotificationsRegistrationOrigin](/developers/mobile-sdk/class-reference/ios/campaigns#pushnotificationsregistrationorigin) | Origin of the push notifications registration from the SDK. |
##### snr_handledAction(url: URL) {id=snr-handled-url-action}
This method is called when Synerise handles URL action from campaign activities.
This method is invoked when the **snr_handledAction(url:source:)** method is not implemented.
Swift Objective-C
```Swift
func snr_handledAction(url: URL) -> Void
```
```Objective-C
- (void)SNR_handledActionWithURL:(NSURL *)url
```
| Parameter | Type | Description |
| --- | --- | --- |
| **url** | NSURL | URL value from the action of the activity. |
##### snr_handledAction(url: URL, source: SyneriseSource) {id=snr-handled-url-action-advanced-with-parameters}
This method is called when Synerise handles URL action from campaign activities.
Swift Objective-C
```Swift
func snr_handledAction(url: URL, source: SyneriseSource) -> Void
```
```Objective-C
- (void)SNR_handledActionWithURL:(NSURL *)url source:(SNRSyneriseSource)source
```
| Parameter | Type | Description |
| --- | --- | --- |
| **url** | NSURL | URL value from the action of the activity. |
| **source** | [SyneriseSource](/developers/mobile-sdk/class-reference/ios/campaigns#synerisesource) | Identifies Synerise campaign source ([SyneriseSource](/developers/mobile-sdk/class-reference/ios/campaigns#synerisesource)). |
##### snr_handledAction(url: URL, activity: SyneriseActivity, completionHandler: SyneriseActivityCompletionHandler) {id=snr-handled-url-action-advanced-with-parameters-deprecated}
This method is called when Synerise handles URL action from campaign activities.
This method was deprecated in SDK version 5.0.0.
Swift Objective-C
```Swift
func snr_handledAction(url: URL, activity: SyneriseActivity, completionHandler: SyneriseActivityCompletionHandler) -> Void
```
```Objective-C
- (void)SNR_handledActionWithURL:(NSURL *)url activity:(SNRSyneriseActivity)activity completionHandler:(SNRSyneriseActivityCompletionHandler)completionHandler
```
| Parameter | Type | Description |
| --- | --- | --- |
| **url** | NSURL | URL value from the action of the activity. |
| **activity** | [SyneriseActivity](/developers/mobile-sdk/class-reference/ios/campaigns#syneriseactivity) | Identifies Synerise campaign activity ([SyneriseActivity](/developers/mobile-sdk/class-reference/ios/campaigns#syneriseactivity)). |
| **completionHandler** | [SyneriseActivityAction](/developers/mobile-sdk/class-reference/ios/campaigns#syneriseactivityaction) | A block/closure that should be invoked with [SyneriseActivityAction](/developers/mobile-sdk/class-reference/ios/campaigns#syneriseactivityaction) parameters and a completion block to execute. |
##### snr_handledAction(deepLink: String) {id=snr-handled-deeplink-action}
This method is called when Synerise handles deeplink action from campaign activities.
This method is invoked when the **snr_handledAction(deepLink:source:)** method is not implemented.
Swift Objective-C
```Swift
func snr_handledAction(deepLink: String) -> Void
```
```Objective-C
- (void)SNR_handledActionWithDeepLink:(NSString *)deepLink
```
| Parameter | Type | Description |
| --- | --- | --- |
| **deepLink** | String | Deep link value from the action of the activity. |
##### snr_handledAction(deepLink: String, source: SyneriseSource) {id=snr-handled-deeplink-action-advanced-with-parameters}
This method is called when Synerise handles deeplink action from campaign activities.
Swift Objective-C
```Swift
func snr_handledAction(deepLink: String, source: SyneriseSource) -> Void
```
```Objective-C
- (void)SNR_handledActionWithDeepLink:(NSString *)deepLink source:(SNRSyneriseSource)source
```
| Parameter | Type | Description |
| --- | --- | --- |
| **deeplink** | String | Deep link value from the action of the activity. |
| **source** | [SyneriseSource](/developers/mobile-sdk/class-reference/ios/campaigns#synerisesource) | Identifies Synerise campaign source ([SyneriseActivity](/developers/mobile-sdk/class-reference/ios/campaigns#synerisesource)). |
##### snr_handledAction(deepLink: String, activity: SyneriseActivity, completionHandler: SyneriseActivityCompletionHandler) {id=snr-handled-deeplink-action-advanced-with-parameters-deprecated}
This method is called when Synerise handles deeplink action from campaign activities.
This method was deprecated in SDK version 5.0.0.
Swift Objective-C
```Swift
func snr_handledAction(deepLink: String, activity: SyneriseActivity, completionHandler: SyneriseActivityCompletionHandler) -> Void
```
```Objective-C
- (void)SNR_handledActionWithDeepLink:(NSString *)deepLink activity:(SNRSyneriseActivity)activity completionHandler:(SNRSyneriseActivityCompletionHandler)completionHandler
```
| Parameter | Type | Description |
| --- | --- | --- |
| **deeplink** | String | Deep link value from the action of the activity. |
| **activity** | [SyneriseActivity](/developers/mobile-sdk/class-reference/ios/campaigns#syneriseactivity) | Identifies Synerise campaign activity ([SyneriseActivity](/developers/mobile-sdk/class-reference/ios/campaigns#syneriseactivity)). |
| **completionHandler** | [SyneriseActivityAction](/developers/mobile-sdk/class-reference/ios/campaigns#syneriseactivityaction) | A block/closure that should be invoked with parameters: [SyneriseActivityAction](/developers/mobile-sdk/class-reference/ios/campaigns#syneriseactivityaction) and completion block to execute. |
---
---
### NotificationDelegate {id=notification-delegate}
A delegate to handle events from Synerise notifications.
See [Configuring push notifications](/developers/mobile-sdk/configuring-push-notifications/ios#delegate-methods) for more details.
**NotificationDelegate** is available from 4.10.0 SDK version. All methods are optional.
To set your object as delegate, you must use [this method](/developers/mobile-sdk/method-reference/ios/campaigns#set-notification-delegate).
Swift Objective-C
```Swift
Synerise.setNotificationDelegate(YOUR_OBJECT)
```
```Objective-C
[SNRSynerise setNotificationDelegate:YOUR_OBJECT];
```
##### snr_notificationDidReceive(notificationInfo: NotificationInfo) {id=notification-delegate-notification-did-receive}
This method is called when a Synerise notification is received.
Swift Objective-C
```Swift
snr_notificationDidReceive(notificationInfo: NotificationInfo)
```
```Objective-C
- (void)SNR_notificationDidReceive:(SNRNotificationInfo *)notificationInfo
```
| Parameter | Type | Description |
| --- | --- | --- |
| **notificationInfo** | [NotificationInfo](/developers/mobile-sdk/class-reference/ios/campaigns#notificationinfo) | Object providing information about the notification. |
##### snr_notificationDidDismiss(notificationInfo: NotificationInfo) {id=notification-delegate-notification-did-dismiss}
This method is called when a Synerise notification is dismissed.
Swift Objective-C
```Swift
func snr_notificationDidDissmis(notificationInfo: NotificationInfo)
```
```Objective-C
- (void)SNR_notificationDidDissmis:(SNRNotificationInfo *)notificationInfo
```
| Parameter | Type | Description |
| --- | --- | --- |
| **notificationInfo** | [NotificationInfo](/developers/mobile-sdk/class-reference/ios/campaigns#notificationinfo) | Object providing information about the notification. |
##### snr_notificationClicked(notificationInfo: NotificationInfo) {id=notification-delegate-notification-clicked}
This method is called when a Synerise notification is clicked.
Swift Objective-C
```Swift
func snr_notificationClicked(notificationInfo: NotificationInfo)
```
```Objective-C
- (void)SNR_notificationClicked:(SNRNotificationInfo *)notificationInfo
```
| Parameter | Type | Description |
| --- | --- | --- |
| **notificationInfo** | [NotificationInfo](/developers/mobile-sdk/class-reference/ios/campaigns#notificationinfo) | Object providing information about the notification. |
##### snr_notificationClicked(notificationInfo: NotificationInfo, actionButton: String) {id=notification-delegate-notification-clicked-with-button}
This method is called when an action button is clicked in a Synerise notification.
Swift Objective-C
```Swift
func snr_notificationClicked(notificationInfo: NotificationInfo, actionButton: String)
```
```Objective-C
- (void)SNR_notificationActionButtonClicked:(SNRNotificationInfo *)notificationInfo actionButton:(NSString *)actionButton
```
| Parameter | Type | Description |
| --- | --- | --- |
| **notificationInfo** | [NotificationInfo](/developers/mobile-sdk/class-reference/ios/campaigns#notificationinfo) | Object providing information about the notification. |
| **actionButton** | String | Text on the clicked action button. |
---
---
### ClientStateDelegate {id=client-state-delegate}
A delegate to handle customer's sign-in state changes.
To set your object as delegate, you must use [this method](/developers/mobile-sdk/method-reference/ios/client-authentication#set-client-state-delegate).
Swift Objective-C
```Swift
Client.setClientStateDelegate(YOUR_OBJECT)
```
```Objective-C
[SNRClient setClientStateDelegate:YOUR_OBJECT];
```
##### snr_clientIsSignedIn() {id=client-state-delegate-client-is-signed-in}
This method is called when a customer signs in.
Swift Objective-C
```Swift
func snr_clientIsSignedIn()
```
```Objective-C
- (void)SNR_clientIsSignedIn
```
##### snr_clientIsSignedOut(reason: ClientSessionEndReason) {id=client-state-delegate-client-is-signed-out}
This method is called when a customer signs out.
Swift Objective-C
```Swift
func snr_clientIsSignedOut(reason: ClientSessionEndReason)
```
```Objective-C
- (void)SNR_clientIsSignedOutWithReason:(SNRClientSessionEndReason)reason
```
| Parameter | Type | Description |
| --- | --- | --- |
| **reason** | [ClientSessionEndReason](/developers/mobile-sdk/class-reference/ios/client#clientsessionendreason) | Specifies the reason for signing out. |
---
---
### InjectorInAppMessageDelegate {id=injector-in-app-message-delegate}
A delegate to handle the states of [in-app message](/developers/mobile-sdk/campaigns/in-app-message).
**InjectorInAppMessageDelegate** is available from 4.6.0 SDK version.
To set your object as delegate, you must use [this method](/developers/mobile-sdk/method-reference/ios/campaigns#set-in-app-message-delegate).
Swift Objective-C
```Swift
Injector.setInAppMessageDelegate(YOUR_OBJECT)
```
```Objective-C
[SNRInjector setInAppMessageDelegate:YOUR_OBJECT];
```
##### snr_shouldInAppMessageAppear(data: InAppMessageData) -> Bool {id=injector-in-app-message-delegate-should-in-app-message-appear}
This method is called after an in-app message is loaded and Synerise SDK asks for permission to show it.
Swift Objective-C
```Swift
func snr_shouldInAppMessageAppear(data: InAppMessageData) -> Bool
```
```Objective-C
- (BOOL)SNR_shouldInAppMessageAppear:(SNRInAppMessageData *)data
```
| Parameter | Type | Description |
| --- | --- | --- |
| **data** | [InAppMessageData](/developers/mobile-sdk/class-reference/ios/campaigns#inappmessagedata) | Model representation of the in-app message. |
##### snr_inAppMessageDidAppear(data: InAppMessageData) {id=injector-in-app-message-delegate-in-app-message-did-appear}
This method is called after an in-app message appears.
Swift Objective-C
```Swift
func snr_inAppMessageDidAppear(data: InAppMessageData)
```
```Objective-C
- (void)SNR_inAppMessageDidAppear:(SNRInAppMessageData *)data
```
| Parameter | Type | Description |
| --- | --- | --- |
| **data** | [InAppMessageData](/developers/mobile-sdk/class-reference/ios/campaigns#inappmessagedata) | Model representation of the in-app message. |
##### snr_inAppMessageDidDisappear(data: InAppMessageData) {id=injector-in-app-message-delegate-in-app-message-did-disappear}
This method is called after an in-app message disappears.
Swift Objective-C
```Swift
func snr_inAppMessageDidDisappear(data: InAppMessageData)
```
```Objective-C
- (void)SNR_inAppMessageDidDisappear:(SNRInAppMessageData *)data
```
| Parameter | Type | Description |
| --- | --- | --- |
| **data** | [InAppMessageData](/developers/mobile-sdk/class-reference/ios/campaigns#inappmessagedata) | Model representation of the in-app message. |
##### snr_inAppMessageDidChangeSize(rect: CGRect) {id=injector-in-app-message-delegate-in-app-message-did-change-size}
This method is called when an in-app message changes its size.
Swift Objective-C
```Swift
func snr_inAppMessageDidChangeSize(rect: CGRect)
```
```Objective-C
- (void)SNR_inAppMessageDidChangeSize:(CGRect)rect
```
| Parameter | Type | Description |
| --- | --- | --- |
| **data** | [InAppMessageData](/developers/mobile-sdk/class-reference/ios/campaigns#inappmessagedata) | Model representation of the in-app message. |
##### snr_inAppMessageContextIsNeeded(data: InAppMessageData) -> [AnyHashable: Any]? {id=injector-in-app-message-delegate-in-app-message-context-is-needed}
This method is called when an individual context (for example a profile ID, an item SKU) for an in-app message is needed.
Swift Objective-C
```Swift
func snr_inAppMessageContextIsNeeded(data: InAppMessageData) -> [AnyHashable: Any]?
```
```Objective-C
- (nullable NSDictionary *)SNR_inAppMessageContextIsNeeded:(SNRInAppMessageData *)data
```
| Parameter | Type | Description |
| --- | --- | --- |
| **data** | [InAppMessageData](/developers/mobile-sdk/class-reference/ios/campaigns#inappmessagedata) | Model representation of the in-app message. |
##### snr_inAppMessageHandledAction(data: InAppMessageData, deepLink: String) {id=injector-in-app-message-delegate-in-app-message-handled-deeplink-action}
This method is called when the [`SRInApp.openDeeplink(url)` method](/docs/campaign/in-app-messages/creating-inapp-templates/creating-inapp-template#open-deeplink) is used in an in-app message.
This method was renamed in 5.0.0 SDK version from `snr_inAppMessageHandledAction(data:deeplink:)`.
Swift Objective-C
```Swift
func snr_inAppMessageHandledAction(data: InAppMessageData, deepLink: String)
```
```Objective-C
- (void)SNR_inAppMessageHandledDeeplinkAction:(SNRInAppMessageData *)data deepLink:(NSString *)deepLink
```
| Parameter | Type | Description |
| --- | --- | --- |
| **data** | [InAppMessageData](/developers/mobile-sdk/class-reference/ios/campaigns#inappmessagedata) | Model representation of the in-app message. |
| **deepLink** | String | Deep link value from the action of the activity. |
##### snr_inAppMessageHandledAction(data: InAppMessageData, url: URL) {id=injector-in-app-message-delegate-in-app-message-handled-url-action}
This method is called when the [`SRInApp.openUrl(url)` method](/docs/campaign/in-app-messages/creating-inapp-templates/creating-inapp-template#open-url) is used in an in-app message.
Swift Objective-C
```Swift
func snr_inAppMessageHandledAction(data: InAppMessageData, url: URL)
```
```Objective-C
- (void)SNR_inAppMessageHandledURLAction:(SNRInAppMessageData *)data url:(NSURL *)url
```
| Parameter | Type | Description |
| --- | --- | --- |
| **data** | [InAppMessageData](/developers/mobile-sdk/class-reference/ios/campaigns#inappmessagedata) | Model representation of the in-app message. |
| **url** | URL | URL value from the action of the activity. |
##### snr_inAppMessageHandledCustomAction(data: InAppMessageData, name: String, parameters: [AnyHashable: Any]) {id=injector-in-app-message-delegate-in-app-message-handled-custom-action}
This method is called when the [`SRInApp.handleCustomAction(name, params)` method](/docs/campaign/in-app-messages/creating-inapp-templates/creating-inapp-template#trigger-a-custom-action) is used in an in-app message.
Swift Objective-C
```Swift
func snr_inAppMessageHandledCustomAction(data: InAppMessageData, name: String, parameters: [AnyHashable: Any])
```
```Objective-C
- (void)SNR_inAppMessageHandledCustomAction:(SNRInAppMessageData *)data name:(NSString *)name parameters:(NSDictionary *)parameters
```
| Parameter | Type | Description |
| --- | --- | --- |
| **data** | [InAppMessageData](/developers/mobile-sdk/class-reference/ios/campaigns#inappmessagedata) | Model representation of the in-app message. |
| **name** | String | Custom action name for identification. |
| **parameters** | [AnyHashable: Any] | Custom action parameters. |
---
---
### TrackerDelegate {id=tracker-delegate}
A delegate to handle events from the Tracker.
To set your object as delegate, you must use [this method](/developers/mobile-sdk/method-reference/ios/tracking#set-tracker-delegate).
Swift Objective-C
```Swift
Tracker.setDelegate(YOUR_OBJECT)
```
```Objective-C
[SNRTracker setDelegate:YOUR_OBJECT];
```
##### snr_locationUpdateRequired() {id=tracker-delegate-location-update-required}
This method is called when the Tracker module requests a location update.
Swift Objective-C
```Swift
func snr_locationUpdateRequired()
```
```Objective-C
- (void)SNR_locationUpdateRequired
```
---
---
### NotificationServiceExtensionDelegate {id=notification-service-extension-delegate}
A delegate to handle events from Notification Extension Service.
**NotificationServiceExtensionDelegate** is available from 4.0.0 SDK version.
To set your object as delegate, you must use this code in your Notification Service Extension.
Swift Objective-C
```Swift
NotificationServiceExtension.setDelegate(YOUR_OBJECT)
```
```Objective-C
[SNRNotificationServiceExtension setDelegate:YOUR_OBJECT];
```
##### notificationServiceExtensionDidFailDecryptionWithError(_: Error) {id=notification-service-extension-delegate-notification-service-extension-did-fail-decryption}
This method is called when the decryption process fails.
Swift Objective-C
```Swift
func notificationServiceExtensionDidFailDecryptionWithError(_: Error)
```
```Objective-C
- (void)notificationServiceExtensionDidFailDecryptionWithError:(NSError *)error
```
| Parameter | Type | Description |
| --- | --- | --- |
| **error** | NSError | The error that occurred |
##### notificationServiceExtensionDidFailProcessingWithError(_: Error) {id=notification-service-extension-delegate-notification-service-extension-did-fail-processing}
This method is called when the processing notification operation fails.
Swift Objective-C
```Swift
func notificationServiceExtensionDidFailProcessingWithError(_: Error)
```
```Objective-C
- (void)notificationServiceExtensionDidFailProcessingWithError:(NSError *)error
```
| Parameter | Type | Description |
| --- | --- | --- |
| **error** | NSError | The error that occurred |
---
---
### ContentWidgetDelegate {id=content-widget-delegate}
A delegate to handle [Content Widget](/developers/mobile-sdk/displaying-recommendations/content-widget) actions.
To set your object as delegate, you must use this code below.
Swift Objective-C
```Swift
let widget = ContentWidget(options: widgetOptions, appearance: widgetAppearance)
widget.delegate = YOUR_OBJECT
```
```Objective-C
SNRContentWidget *widget = [SNRContentWidget initWithOptions:options andAppearance:appearance];
widget.delegate = YOUR_OBJECT;
```
##### snr_widgetDidLoad(widget: ContentWidget) {id=content-widget-delegate-widget-did-load}
This method is called after a widget is loaded.
Swift Objective-C
```Swift
func snr_widgetDidLoad(widget: ContentWidget)
```
```Objective-C
- (void)SNR_widgetDidLoad:(SNRContentWidget *)widget
```
| Parameter | Type | Description |
| --- | --- | --- |
| **widget** | [ContentWidget](/developers/mobile-sdk/class-reference/ios/content-widget#contentwidget) | The widget instance that called the delegate method. |
##### snr_widgetDidNotLoad(widget:ContentWidget error: Error) {id=content-widget-delegate-widget-did-not-load}
This method is called when an error occurs while loading a widget.
Swift Objective-C
```Swift
func snr_widgetDidNotLoad(widget:ContentWidget error: Error)
```
```Objective-C
- (void)SNR_widget:(SNRContentWidget *)widget didNotLoadWithError:(NSError *)error
```
| Parameter | Type | Description |
| --- | --- | --- |
| **widget** | [ContentWidget](/developers/mobile-sdk/class-reference/ios/content-widget) | The widget instance that called the delegate method. |
| **error** | NSError | The error that occurred. |
##### snr_widgetDidReceiveClickAction(widget:ContentWidget model: BaseModel) {id=content-widget-delegate-widget-did-receive-click-action}
This method is called when the customer clicks a widget’s item.
Swift Objective-C
```Swift
func snr_widgetDidReceiveClickAction(widget:ContentWidget model: BaseModel)
```
```Objective-C
- (void)SNR_widget:(SNRContentWidget *)widget didReceiveClickActionForModel:(SNRBaseModel *)model
```
| Parameter | Type | Description |
| --- | --- | --- |
| **widget** | [ContentWidget](/developers/mobile-sdk/class-reference/ios/content-widget) | The widget instance that called the delegate method. |
| **model** | BaseModel | The model's object that was clicked. |
##### snr_widgetIsLoading(widget: ContentWidget isLoading: Bool) {id=content-widget-delegate-widget-is-loading}
This method is called when the widget’s loading state changes.
Swift Objective-C
```Swift
func snr_widgetIsLoading(widget: ContentWidget isLoading: Bool)
```
```Objective-C
- (void)SNR_widget:(SNRContentWidget *)widget isLoading:(BOOL)isLoading
```
| Parameter | Type | Description |
| --- | --- | --- |
| **widget** | [ContentWidget](/developers/mobile-sdk/class-reference/ios/content-widget) | The widget instance that called the delegate method. |
| **isLoading** | Bool | Widget's loading state. |
##### snr_widgetDidChangeSize(widget: ContentWidget size: CGSize) {id=content-widget-delegate-widget-did-change-size}
This method is called when the widget’s size changes.
Swift Objective-C
```Swift
func snr_widgetDidChangeSize(widget: ContentWidget size: CGSize)
```
```Objective-C
- (void)SNR_widget:(SNRContentWidget *)widget didChangeToSize:(CGSize)size
```
| Parameter | Type | Description |
| --- | --- | --- |
| **widget** | [ContentWidget](/developers/mobile-sdk/class-reference/ios/content-widget) | The widget instance that called the delegate method. |
| **size** | CGSize | Widget's new size. |
---
---
### InjectorWalkthroughDelegate {id=injector-walkthrough-delegate}
**InjectorWalkthroughDelegate** was removed in 5.0.0 SDK version.
---
---
### InjectorBannerDelegate {id=injector-banner-delegate}
**InjectorBannerDelegate** was removed in 5.0.0 SDK version.
# Customer authentication
---
## 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](/developers/mobile-sdk/user-identification-and-authorization/overview).
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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> registerAccount(ClientAccountRegisterContext context, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientAccountRegisterContext](/developers/mobile-sdk/class-reference/flutter/client#clientaccountregistercontext) | yes | - | Object with the customer's email, password, and other optional data |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
ClientAccountRegisterContext clientAccountRegisterContext = ClientAccountRegisterContext(email: email, password: password);
await Synerise.client.registerAccount(clientAccountRegisterContext, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> registerAccount(ClientAccountRegisterContext context) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientAccountRegisterContext](/developers/mobile-sdk/class-reference/flutter/client#clientaccountregistercontext) | yes | - | Object with the customer's email, password, and other optional data |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.registerAccount(clientAccountRegisterContext).catchError((error)
## 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> requestAccountActivation(String email,
{required void Function() onSuccess,
required void Function(SyneriseError error) onError}) async
Before version 2.0.0, this method was called `activateAccount`
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer’s email |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.synerise-flutter-sdkAccount(email, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> activateAccount(String email) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer’s email |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.activateAccount(email).catchError((error)
## 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> confirmAccountActivation(String token, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
Before version 1.0.0, this method was called `confirmAccount`.
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | String | yes | - | Customer’s token provided by email |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.confirmAccountActivation(token, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> confirmAccountActivation(String token) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | String | yes | - | Customer’s token provided by email |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.confirmAccount(token).catchError((error)
## 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> requestAccountActivationByPin(String email, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **email** | String | yes | Customer's email |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.requestAccountActivationByPin(email, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> requestAccountActivationByPin(String email) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **email** | String | yes | Customer's email |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.requestAccountActivationByPin(email).catchError((error) {
## 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> confirmAccountActivationByPin(String email, String pinCode, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **pinCode** | String | yes | Code sent to a customer's email |
| **email** | String | yes | Customer's email |
| **onSuccess** | Function() | yes | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.confirmAccountActivationByPin(email, pinCode, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> confirmAccountActivationByPin(String email, String pinCode) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **pinCode** | String | yes | Code sent to a customer's email |
| **email** | String | yes | Customer's email |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.confirmAccountActivationByPin(email, pinCode).catchError((error) {
## 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> signIn(String email, String password, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer’s email |
| **password** | String | yes | - | Customer’s password |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.signIn(email, password, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> signIn(String email, String password) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer’s email |
| **password** | String | yes | - | Customer’s password |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.signIn(email,password).catchError((error)
## 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:**
lib/modules/client/client_impl.dart
**Related To:**
[ClientConditionalAuthResult](/developers/mobile-sdk/class-reference/flutter/client#clientconditionalauthresult)
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> signInConditionally(String email, String password,
{required void Function(ClientConditionalAuthResult) onSuccess,
required void Function(SyneriseError error) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **email** | String | yes | Customer's email |
| **password** | String | yes | Customer's password |
**Return Value:**
No value is returned.
**Example:**
Dart
```Dart
await Synerise.client.signInConditionally(email, password, onSuccess: (ClientConditionalAuthResult result) {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
```
**Declaration:**
Future<ClientConditionalAuthResult> signInConditionally(String email, String password) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **email** | String | yes | Customer's email |
| **password** | String | yes | Customer's password |
**Return Value:**
[ClientConditionalAuthResult](/developers/mobile-sdk/class-reference/flutter/client#clientconditionalauthresult)
**Example:**
Dart
```Dart
await Synerise.client.signInConditionally(email, password).catchError((error)
```
## 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:**
lib/modules/client/client_impl.dart
**Related To:**
[ClientAuthContext](/developers/mobile-sdk/class-reference/flutter/client#clientauthcontext)
[ClientIdentityProvider](/developers/mobile-sdk/class-reference/flutter/client#clientidentityprovider)
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> authenticate(ClientAuthContext clientAuthContext, IdentityProvider identityProvider, String tokenString,
{required void Function(bool) onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **clientAuthContext** | [ClientAuthContext](/developers/mobile-sdk/class-reference/flutter/client#clientauthcontext) | yes | - | Object which contains agreements, attributes, and identifier of authorization |
| **identityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/flutter/client#clientidentityprovider) | yes | - | Provider of your token |
| **tokenString** | String | yes | - | Token retrieved from provider |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.authenticate(clientAuthContext, identityProvider, tokenString, onSuccess: (bool result) {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<bool> authenticate(ClientAuthContext clientAuthContext, IdentityProvider identityProvider, String tokenString) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **clientAuthContext** | [ClientAuthContext](/developers/mobile-sdk/class-reference/flutter/client#clientauthcontext) | yes | - | Object which contains agreements, attributes, and identifier of authorization |
| **identityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/flutter/client#clientidentityprovider) | yes | - | Provider of your token |
| **tokenString** | String | yes | - | Token retrieved from provider |
**Return Value:**
**true** if the operation is success, otherwise it throws an error.
**Example:**
await Synerise.client.authenticate(clientAuthContext, identityProvider, tokenString).catchError((error)
## 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:**
lib/modules/client/client_impl.dart
**Related To:**
[ClientConditionalAuthResult](/developers/mobile-sdk/class-reference/flutter/client#clientconditionalauthresult)
[ClientIdentityProvider](/developers/mobile-sdk/class-reference/flutter/client#clientidentityprovider)
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> authenticateConditionally(ClientAuthContext clientAuthContext, IdentityProvider identityProvider, String tokenString,
{String? authID, required void Function(ClientConditionalAuthResult) onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Optional | Description |
| --- | --- | --- | --- |
| **clientAuthContext** | [ClientAuthContext](/developers/mobile-sdk/class-reference/flutter/client#clientauthcontext) | no | Object which contains agreements and attributes |
| **identityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/flutter/client#clientidentityprovider) | no | Provider of your token |
| **tokenString** | String | no | Token retrieved from provider |
| **authID** | String | yes | Optional identifier of authorization |
| **onSuccess** | Function([ClientConditionalAuthResult](/developers/mobile-sdk/class-reference/flutter/client#clientconditionalauthresult) result) | yes | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | Function 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:**
Token token = Token(tokenString: "tokenString", origin: TokenOrigin.anonymous, expirationDate: DateTime;
await Synerise.client.retrieveToken(onSuccess: (Token token) {
token = token;
}, onError: (SyneriseError error) {
//onError handling
});
String tokenString = token.tokenString;
IdentityProvider identityProvider = IdentityProvider.oauth;
await Synerise.client.authenticateConditionally(identityProvider, tokenString, onSuccess: (ClientConditionalAuthResult result) {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<ClientConditionalAuthResult> authenticateConditionally(ClientAuthContext clientAuthContext, IdentityProvider identityProvider, String tokenString) async
**Parameters:**
| Parameter | Type | Optional | Description |
| --- | --- | --- | --- |
| **token** | String | no | Token retrieved from provider |
| **clientIdentityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/flutter/client#clientidentityprovider) | no | Provider of your token |
| **authID** | String | yes | Optional identifier of authorization |
| **context** | [ClientConditionalAuthContext](/developers/mobile-sdk/class-reference/flutter/client#clientconditionalauthcontext) | no | Object which contains agreements and attributes |
**authID** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
**Return Value:**
[ClientConditionalAuthResult](/developers/mobile-sdk/class-reference/flutter/client#clientconditionalauthresult)
**Example:**
ClientAgreements? agreements = ClientAgreements(push: false, rfid: false, wifi: false);
Map<String, Object>? attributes;
ClientAuthContext clientAuthContext = ClientAuthContext(authId: 'AUTH_ID', agreements: agreements, attributes: attributes);
Token token = await Synerise.client.retrieveToken().catchError((error) {
String errorMessage = Utils.handlePlatformException(error);
Utils.displaySimpleAlert("error on handling api call \n $errorMessage", context);
throw Exception(errorMessage);
});
String tokenString = token.tokenString;
IdentityProvider identityProvider = IdentityProvider.oauth;
ClientConditionalAuthResult result =
await Synerise.client.authenticateConditionally(clientAuthContext, identityProvider, tokenString).catchError((error) {
String errorMessage = Utils.handlePlatformException(error);
Utils.displaySimpleAlert("error on handling api call: you need to be signed in to authenticate \n $errorMessage", context);
throw Exception(errorMessage);
});
## 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:**
lib/modules/client/client_impl.dart
**Related To:**
[ClientSimpleAuthenticationData](/developers/mobile-sdk/class-reference/flutter/client#clientsimpleauthenticationdata)
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> simpleAuthentication(ClientSimpleAuthenticationData data, String authID, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **data** | [ClientSimpleAuthenticationData](/developers/mobile-sdk/class-reference/flutter/client#clientsimpleauthenticationdata) | yes | Object which contains customer data |
| **authID** | String | yes | Required identifier of authorization |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function 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:**
ClientSimpleAuthenticationData data =
ClientSimpleAuthenticationData(firstName: firstName, lastName: lastName, email: email, customId: customID);
await Synerise.client.simpleAuthentication(data, authID, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> simpleAuthentication(ClientSimpleAuthenticationData clientSimpleAuthenticationData, String authID) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **data** | [ClientSimpleAuthenticationData](/developers/mobile-sdk/class-reference/flutter/client#clientsimpleauthenticationdata) | yes | - | Object which contains customer data |
| **authID** | String | yes | null | Required identifier of authorization |
**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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
**Declaration:**
Future<bool> isSignedIn() async
**Return Value:**
**true** if the customer is signed in, otherwise returns **false**.
**Example:**
bool isSignedInBool = await Synerise.client.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:**
lib/modules/client/client_impl.dart
**Class:**
[Client](/developers/mobile-sdk/class-reference/flutter/modules#client)
**Declaration:**
Future<bool> isSignedInViaSimpleAuthentication() async
**Return Value:**
**true** if the customer is signed in (via Simple Profile Authentication), otherwise returns **false**.
**Example:**
await Synerise.client
.isSignedInViaSimpleAuthentication()
.then((bool result) {
if (result == true) {
//result handling
} else {
//error handling
}
});
## Sign out a 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
**Declaration:**
Future<void> signOut() async
**Return Value:**
No value is returned.
**Example:**
Dart
```Dart
Synerise.client.signOut().whenComplete(() => {
//onSuccess handling
});
```
## 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:
- `.signOut` mode signs out the customer.
- `.signOutWithSessionDestroy` mode 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> signOutWithMode(ClientSignOutMode mode, bool fromAllDevices, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **mode** | [ClientSignOutMode](/developers/mobile-sdk/class-reference/flutter/client#clientsignoutmode) | yes | Mode of signing out |
| **fromAllDevices** | bool | yes | Determines if the method should sign out all devices |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
ClientSignOutMode mode = ClientSignOutMode.signOutWithSessionDestroy;
bool fromAllDevices = true;
await Synerise.client.signOutWithMode(mode, fromAllDevices, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> signOutWithMode(ClientSignOutMode mode, bool fromAllDevices) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **mode** | [ClientSignOutMode](/developers/mobile-sdk/class-reference/flutter/client#clientsignoutmode) | yes | Mode of signing out |
| **fromAllDevices** | bool | yes | Determines if the method should sign out all devices |
**Return Value:**
No value is returned.
**Example:**
ClientSignOutMode mode = ClientSignOutMode.signOutWithSessionDestroy;
bool fromAllDevices = true;
await Synerise.client.signOutWithMode(mode, fromAllDevices).catchError((error) {
# Client
### ClientIdentityProvider
This enum contains values which set the provider for deleting a profile (a profile itself and their account).
**Declared In:**
`com.synerise.sdk.client.model.ClientIdentityProvider`
**Declaration:**
Java Kotlin
```Java
public enum ClientIdentityProvider
```
```Kotlin
public enum ClientIdentityProvider
```
**Values:**
| Property | Value | Description |
| --- | --- | --- |
| **FACEBOOK** | "FACEBOOK" | Facebook provider |
| **GOOGLE** | "GOOGLE" | Google provider |
| **OAUTH** | "OAUTH" | Oauth provider |
| **SYNERISE** | "SYNERISE" | Synerise provider |
| **SIMPLE_AUTH** | "SIMPLE_AUTH" | Simple Profile Authentication provider |
**Methods:**
Get a provider.
public static ClientIdentityProvider getByProvider(String provider)
---
---
---
### AuthConditions
Auth conditions model.
Model passes status and conditions.
**Declared In:**
`com.synerise.sdk.client.model`
**Declaration:**
Java Kotlin
```Java
public class AuthConditions
```
```Kotlin
class AuthConditions
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **status** | [ConditionalAuthenticationStatus](/developers/mobile-sdk/class-reference/android/client#conditionalauthenticationstatus) | no | - | Status of authentication |
| **conditions** | ArrayList | no | - | List of conditions |
All of the properties above are accessible by using getters.
**Methods:**
There are getters and setters for the above properties.
---
---
---
### ConditionalAuthenticationStatus
This enum contains values which describe the status of an after a log-in attempt.
**Declared In:**
`com.synerise.sdk.client.model.ConditionalAuthenticationStatus`
**Declaration:**
Java Kotlin
```Java
public enum ConditionalAuthenticationStatus
```
```Kotlin
public enum ConditionalAuthenticationStatus
```
**Values:**
| Property | Description |
| --- | -- |
| **SUCCESS** | Authentication successful |
| **UNAUTHORIZED** | Currently unused |
| **ACTIVATION_REQUIRED** |Currently unused |
| **REGISTRATION_REQUIRED** | Currently unused |
| **APPROVAL_REQUIRED** | Currently unused |
| **TERMS_ACCEPTANCE_REQUIRED** | Currently unused |
| **MFA_REQUIRED** | Currently unused |
**Methods:**
There are no methods.
---
---
### ClientData
**Declared In:**
`com.synerise.sdk.client.model.simpleAuth`
**Declaration:**
Java Kotlin
```Java
public final class ClientData extends ClientDataInformation
```
```Kotlin
class ClientData : ClientDataInformation
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer's email |
| **phone** | String | yes | - | Customer's phone |
| **customId** | String | yes | - | Customer's custom ID |
| **uuid** | String | yes | - | Customer's uuid |
| **firstName** | String | yes | - | Customer's first name |
| **lastName** | String | yes | - | Customer's last name |
| **displayName** | String | yes | - | Customer's display name |
| **company** | String | yes | - | Customer's company |
| **address** | String | yes | - | Customer's address |
| **city** | String | yes | - | Customer's city |
| **province** | String | yes | - | Customer's province |
| **zipCode** | String | yes | - | Customer's ZIP code |
| **countryCode** | String | yes | - | Customer's country code |
| **birthDate** | String | yes | - | Customer's birthdate |
| **sex** | [Sex](/developers/mobile-sdk/class-reference/android/client#sex) | yes | - | Customer's sex |
| **avatarUrl** | String | yes | - | Customer's avatar URL |
| **agreements** | [Agreements](/developers/mobile-sdk/class-reference/android/client#agreements) | yes | - | Customer's agreements |
| **attributes** | [Attributes](/developers/mobile-sdk/class-reference/android/client#attributes) | yes | - | Customer's attributes |
All properties above are accessible by using setters.
**Initializers:**
There are no initializers.
**Methods:**
There are only setters for above properties.
---
---
### ClientSessionEndReason
This enum contains values which describe the reason for sending a session.
**Declared In:**
`com.synerise.sdk.core.types.enums.ClientSessionEndReason`
**Declaration:**
Java Kotlin
```Java
public enum ClientSessionEndReason
```
```Kotlin
public enum ClientSessionEndReason
```
**Values:**
| Property | Description |
| --- | --- |
| **SESSION_EXPIRATION** | Session ended due to token expiration. |
| **SECURITY_EXCEPTION** | Session ended due to security errors. |
| **USER_SIGN_OUT** | Session ended due to a profile sign-out. |
| **SYSTEM_SIGN_OUT** | Session ended due to a remote sign out by the system. |
| **SESSION_DESTROYED** | Session ended due to the `Client.destroySession` method. |
| **CLIENT_REJECTED** | Session ended due to 401 or 410 response. |
| **USER_ACCOUNT_DELETED** | Session ended due to profile account deletion. |
**Methods:**
There are no methods.
---
---
### ClientSignOutMode
This enum contains values for the sign out mode.
**Declared In:**
`com.synerise.sdk.core.types.enums`
**Declaration:**
Java Kotlin
```Java
public enum ClientSignOutMode
```
```Kotlin
public enum ClientSignOutMode
```
**Values:**
| Property | Value | Description |
| --- | --- | --- |
| **SIGN_OUT** | "LOGOUT" | Sign out with a backend call. The token is invalidated and cleared in the SDK, but the UUID remains the same. |
| **SIGN_OUT_WITH_SESSION_DESTROY** | "LOGOUT_WITH_SESSION_DESTROY" | Sign out with a backend call. The token is invalidated. The token and UUID are cleared in the SDK. |
**Methods:**
No methods.
---
---
---
### GetAccountInformation
Class providing a profile account information.
**Declared In:**
`com.synerise.sdk.client.model.GetAccountInformation`
**Declaration:**
Java Kotlin
```Java
public final class GetAccountInformation extends AccountInformation implements Serializable
```
```Kotlin
class GetAccountInformation:AccountInformation(), Serializable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **clientId** | long | no | - | A unique ID of a profile |
| **lastActivityDate** | Date | no | - | Profile's last performed activity date |
| **email** | String | no | - | Profile's email |
| **phone** | String | no | - | Profile's phone |
| **customId** | String | no | - | Profile's customId |
| **uuid** | String | no | - | Profile's UUID |
| **firstName** | String | no | - | Profile's first name |
| **lastName** | String | no | - | Profile's last name |
| **displayName** | String | no | - | Profile's display name |
| **company** | String | no | - | Profile's company |
| **address** | String | no | - | Profile's address |
| **city** | String | no | - | Profile's city |
| **province** | String | no | - | Profile's province |
| **zipCode** | String | no | - | Profile's ZIP code |
| **countryCode** | String | no | - | Profile's country code |
| **birthDate** | String | no | - | Profile's birth date |
| **sex** | [Sex](/developers/mobile-sdk/class-reference/android/client#sex) | no | - | Profile's sex |
| **avatarUrl** | String | no | - | Profile's avatar URL |
| **anonymous** | Boolean | no | - | Defines if the profile is anonymous |
| **agreements** | [Agreements](/developers/mobile-sdk/class-reference/android/client#agreements) | no | - | Profile's agreements |
| **attributes** | [Attributes](/developers/mobile-sdk/class-reference/android/client#attributes) | no | - | Profile's attributes |
| **tags** | List | no | - | Profile's tags |
All properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters for the above properties.
---
---
---
### UpdateAccountBasicInformation
Class providing data to update account basic information.
**Declared In:**
`com.synerise.sdk.client.model.UpdateAccountBasicInformation`
**Declaration:**
Java Kotlin
```Java
public final class UpdateAccountBasicInformation
```
```Kotlin
class UpdateAccountBasicInformation
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **phoneNumber** | String | no | - | Profile's phone |
| **firstName** | String | no | - | Profile's first name |
| **lastName** | String | no | - | Profile's last name |
| **displayName** | String | no | - | Profile's display name |
| **company** | String | no | - | Profile's company |
| **address** | String | no | - | Profile's address |
| **city** | String | no | - | Profile's city |
| **province** | String | no | - | Profile's province |
| **zipCode** | String | no | - | Profile's ZIP code |
| **countryCode** | String | no | - | Profile's country code |
| **birthDate** | String | no | - | Profile's birth date |
| **sex** | [Sex](/developers/mobile-sdk/class-reference/android/client#sex) | no | - | Profile's sex |
| **avatarUrl** | String | no | - | Profile's avatar URL |
| **anonymous** | Boolean | no | - | Defines if the profile is anonymous |
| **agreements** | [Agreements](/developers/mobile-sdk/class-reference/android/client#agreements) | no | - | Profile's agreements |
| **attributes** | [Attributes](/developers/mobile-sdk/class-reference/android/client#attributes) | no | - | Profile's attributes |
All properties above are accessible by using setters.
**Initializers:**
There are no initializers.
**Methods:**
There are only setters for above properties.
---
---
---
### UpdateAccountInformation
Class providing data to update account information.
**Declared In:**
`com.synerise.sdk.client.model.UpdateAccountInformation`
**Declaration:**
Java Kotlin
```Java
public final class UpdateAccountInformation extends AccountInformation
```
```Kotlin
class UpdateAccountInformation:AccountInformation()
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | no | - | Profile's email |
| **phoneNumber** | String | no | - | Profile's phone |
| **customId** | String | no | - | Profile's customId |
| **uuid** | String | no | - | Profile's uuid |
| **firstName** | String | no | - | Profile's first name |
| **lastName** | String | no | - | Profile's last name |
| **displayName** | String | no | - | Profile's display name |
| **company** | String | no | - | Profile's company |
| **address** | String | no | - | Profile's address |
| **city** | String | no | - | Profile's city |
| **province** | String | no | - | Profile's province |
| **zipCode** | String | no | - | Profile's ZIP code |
| **countryCode** | String | no | - | Profile's country code |
| **birthDate** | String | no | - | Profile's birth date |
| **sex** | [Sex](/developers/mobile-sdk/class-reference/android/client#sex) | no | - | Profile's sex |
| **avatarUrl** | String | no | - | Profile's avatar URL |
| **anonymous** | Boolean | no | - | Defines if the profile is anonymous |
| **agreements** | [Agreements](/developers/mobile-sdk/class-reference/android/client#agreements) | no | - | Profile's agreements |
| **attributes** | [Attributes](/developers/mobile-sdk/class-reference/android/client#attributes) | no | - | Profile's attributes |
All properties above are accessible by using setters.
**Initializers:**
There are no initializers.
**Methods:**
There are only setters for above properties.
---
---
---
### RegisterClient
Class responsible for registering a profile.
**Declared In:**
`com.synerise.sdk.client.model.client.RegisterClient`
**Declaration:**
Java Kotlin
```Java
public class RegisterClient extends BaseClient
```
```Kotlin
class RegisterClient : BaseClient
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **agreements** | [Agreements](/developers/mobile-sdk/class-reference/android/client#agreements) | no | - | Profile's agreements |
| **attributes** | [Attributes](/developers/mobile-sdk/class-reference/android/client#attributes) | no | - | Profile's attributes |
| **city** | String | yes | - | Profile's city |
| **company** | String | yes | - | Profile's company |
| **countryCode** | String | yes | - | Profile's country code |
| **customId** | String | yes | - | Profile's customId |
| **firstName** | String | yes | - | Profile's first name |
| **lastName** | String | yes | - | Profile's last name |
| **phoneNumber** | String | yes | - | Profile's phone number |
| **province** | String | yes | - | Profile's province |
| **sex** | [Sex](/developers/mobile-sdk/class-reference/android/client#sex) | yes | - | Profile's sex |
| **zipCode** | String | yes | - | Profile's ZIP code |
| **uuid** | String | yes | - | Profile's UUID |
| **email** | String | yes | - | Profile's email |
| **password** | String | yes | - | Profile's password |
**Initializers:**
There are no initializers.
**Methods:**
All properties have their own setters.
---
---
---
### PasswordResetRequest
Class responsible for creating a payload for password reset request.
**Declared In:**
`com.synerise.sdk.client.model.password.PasswordResetRequest`
**Declaration:**
Java Kotlin
```Java
public final class PasswordResetRequest
```
```Kotlin
class PasswordResetRequest
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Profile's email |
**Initializers:**
There is a constructor.
public PasswordResetRequest(@NonNull String email)
**Methods:**
There are no methods.
---
---
---
### PasswordResetConfirmation
Class responsible for creating a payload for password reset confirmation.
**Declared In:**
`com.synerise.sdk.client.model.password.PasswordResetConfirmation`
**Declaration:**
Java Kotlin
```Java
public final class PasswordResetConfirmation
```
```Kotlin
class PasswordResetConfirmation
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **password** | String | no | - | Profile's password |
| **token** | String | no | - | Profile's token |
**Initializers:**
There is a constructor.
public PasswordResetConfirmation(@NonNull String password, @NonNull String token)
**Methods:**
There are no methods.
---
---
---
### Sex
This enum contains values for the `sex` parameter.
**Declared In:**
`com.synerise.sdk.core.types.enums.Sex`
**Declaration:**
Java Kotlin
```Java
public enum Sex
```
```Kotlin
public enum Sex
```
**Values:**
| Property | Value | Description |
| --- | --- | --- |
| **FEMALE** | "FEMALE" | Female |
| **MALE** | "MALE" | Male |
| **OTHER** | "OTHER" | Other |
| **NA** | "NOT_SPECIFIED" | Not specified |
**Methods:**
This method retrieves the value of the `sex` parameter.
public String getSex()
---
This method retrieves the value of the `sex` parameter.
public static Sex getSex(String name)
---
---
---
### Agreements
Class responsible for passing agreements.
**Declared In:**
`com.synerise.sdk.client.model.client.Agreements`
**Declaration:**
Java Kotlin
```Java
public class Agreements
```
```Kotlin
class Agreements
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | Boolean | yes | - | Email agreement |
| **sms** | Boolean | yes | - | SMS agreement |
| **push** | Boolean | yes | - | Push agreement |
| **bluetooth** | Boolean | yes | - | Bluetooth agreement |
| **rfid** | Boolean | yes | - | RFID agreement |
| **wifi** | Boolean | yes | - | WiFi agreement |
**Initializers:**
There are no initializers.
**Methods:**
All properties have their own setters and getters.
---
---
---
### Attributes
Class responsible for passing attributes.
**Declared In:**
`com.synerise.sdk.client.model.client.Attributes`
**Declaration:**
Java Kotlin
```Java
public class Attributes
```
```Kotlin
class Attributes
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **properties** | HashMap | yes | - | A key-value pair of profile's attributes |
**Initializers:**
There are no initializers.
**Methods:**
This method adds attributes.
public Attributes add(String key, String value)
---
This method retrieves a value of an attribute.
public HashMap<String, String> getProperties()
---
---
---
### ClientEventData
Event data model.
**Declared In:**
`com.synerise.sdk.client.model.events.ClientEventData`
**Declaration:**
Java Kotlin
```Java
public class ClientEventData
```
```Kotlin
class ClientEventData
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **time** | String | no | - | Event time |
| **action** | String | no | - | Event action |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision Hub or Automation Hub. It isn't shown on a Profile card. |
| **client** | HashMap | no | - | Profiles |
All properties above are accessible by using getters and setters.
**Initializers:**
There are no initializers.
**Methods:**
This method returns the value of the `email` attribute from the profile hashmap.
public String getClientEmail()
---
This method returns the `uuid` attribute from the profile hashmap.
public String getClientUuid()
---
This method returns the `clientId` attribute from the profile hashmap.
public int getClientId()
---
---
---
### ClientEventQuery
Class responsible for creating a query to get events.
**Declared In:**
`com.synerise.sdk.client.model.client.ClientEventsQuery`
**Declaration:**
Java Kotlin
```Java
public class ClientEventsQuery
```
```Kotlin
class ClientEventsQuery
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **actions** | List | yes | - | Event action |
| **timeFrom** | Date | yes | - | Event time |
| **label** | String | yes | - | This value is currently unused |
| **limit** | int | yes | 1000 | Event limit |
All properties above are accessible by using setters.
**Initializers:**
There are no initializers.
**Methods:**
There are no methods.
---
---
---
### TokenPayload
TokenPayload model.
**Declared In:**
`com.synerise.sdk.core.types.model.TokenPayload`
**Declaration:**
Java Kotlin
```Java
public class TokenPayload
```
```Kotlin
class TokenPayload
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **tokenString** | String | no | Token as a raw string |
| **expirationDate** | Date | no | Token's expiration time |
| **creationDate** | Date | no | Token's creation time |
| **rlm** | [TokenRLM](/developers/mobile-sdk/class-reference/android/client#tokenrlm) | no | Token's RLM |
| **origin** | [TokenOrigin](/developers/mobile-sdk/class-reference/android/client#tokenorigin) | no | Token's origin |
| **uuid** | String | no | Customer's UUID |
| **clientId** | String | no | Customer's ID |
| **customId** | String | yes | Customer's custom ID |
All properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters for the above properties.
---
---
---
### Token
Token model.
**Declared In:**
`com.synerise.sdk.core.types.model.Token`
**Declaration:**
Java Kotlin
```Java
public class Token
```
```Kotlin
class Token
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **rawJwt** | String | no | - | Raw JWT token string |
| **expirationUnixTime** | long | no | - | Parsed expiration time in UNIX format |
| **signKey** | String | no | - | Encrypted signing key |
| **tokenRLM** | [TokenRLM](/developers/mobile-sdk/class-reference/android/client#tokenrlm) | no | - | Token scope |
| **tokenOrigin** | [TokenOrigin](/developers/mobile-sdk/class-reference/android/client#tokenorigin) | no | - | Token source origin |
| **clientId** | String | no | - | Token customer ID |
| **customId** | String | no | - | Token customId |
All properties above are accessible by using getters.
**Initializers:**
public static Token createToken(String signKey, String rawJwt, long expirationUnixTime, String rlm, String origin)
---
---
---
### TokenOrigin
This enum contains values for a token origin.
**Declared In:**
`com.synerise.sdk.core.types.model.Token.TokenOrigin`
**Declaration:**
Java Kotlin
```Java
public enum TokenOrigin
```
```Kotlin
public enum TokenOrigin
```
**Values:**
| Property | Value | Description |
| --- | --- | --- |
| **SYNERISE** | "SYNERISE" | Token comes from Synerise |
| **SIMPLE_AUTH** | "SIMPLE_AUTH" | Token comes from Synerise Simple Profile Authentication |
| **FACEBOOK** | "FACEBOOK" | Token comes from Facebook |
| **OAUTH** | "OAUTH" | Token comes from OAuth |
| **UNKNOWN** | "UNKNOWN" | Unknown token source |
**Methods:**
This method retrieves the value of the `origin` parameter.
public String getOrigin()
---
This method retrieves the value of the `origin` parameter.
public static TokenOrigin getOrigin(String rlm)
---
---
---
### TokenRLM
This enum contains values for a token realm.
**Declared In:**
`com.synerise.sdk.core.types.model.Token.TokenRLM`
**Declaration:**
Java Kotlin
```Java
public enum TokenRLM
```
```Kotlin
public enum TokenRLM
```
**Values:**
| Property | Value | Description |
| --- | --- | --- |
| **ANONYMOUS** | "anonymous_client" | Anonymous profile |
| **CLIENT** | "client" | Recognized profile |
**Methods:**
This method retrieves the value of the `rlm` parameter.
public String getRlm()
---
This method retrieves the value of the `rlm` parameter.
public static TokenRLM getRlm(String rlm)
---
# Installation and configuration
In this section, you will find out how to install, configure, and initialize SDK in the Android, iOS and React Native mobile applications.
## Contents
# React Native
## Class reference - React Native
# Silent push
## Overview
---
Silent push is a hidden notification that is delivered to the app. It does not cause any interaction with the user like a typical push. Silent notifications quietly deliver a certain set of data to the app so you may use it to notify that new content is available or inform about changes in the content. This kind of campaign does not affect your UI.
Within the silent push campaign, the SDK provides features such as remote sign out or acquiring location by using a silent push command. Read more in the [SDK Commands](#sdk-commands) section.
## Configuration
---
Silent push campaign is served by push notifications. See:
- [Configuring push notifications - Android](/developers/mobile-sdk/configuring-push-notifications/android)
- [Configuring push notifications - iOS](/developers/mobile-sdk/configuring-push-notifications/ios)
- [Configuring push notifications - React Native](/developers/mobile-sdk/configuring-push-notifications/react-native)
- [Configuring push notifications - Flutter](/developers/mobile-sdk/configuring-push-notifications/flutter)
Additionally, check possible available configuration options in the [Settings](/developers/mobile-sdk/settings#notifications).
## Checking custom notification payloads
---
The silent push campaign is designed to send notifications with your own payload and in this case should not be passed to the SDK. However, the campaign allows sending any data in payload including [SDK commands](#sdk-commands). Then, the notification must be handled correctly. You may use the samples below.
Java Swift JavaScript
```Java
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Map data = remoteMessage.getData();
if (Injector.isSynerisePush(data)) {
if (Injector.isSilentCommand(data)) {
try {
SilentCommand silentCommand = Injector.getSilentCommand(data);
<>
} catch (ValidationException e) {
e.printStackTrace();
}
}
} else {
<>
}
}
```
```Swift
extension NotificationService: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.userInfo
let isSyneriseNotification: Bool = Synerise.isSyneriseNotification(userInfo)
if (isSyneriseNotification == true) {
let isSyneriseSilentCommand: Bool = Synerise.isSyneriseSilentCommand(userInfo)
if isSyneriseSilentCommand {
<>
}
} else {
<>
}
completionHandler(.alert)
}
}
```
```JavaScript
Synerise.onReady(function() {
onNotification: function(payload, actionIdentifier) {
let isSyneriseNotification = Synerise.Notifications.isSyneriseNotification(payload);
if (isSyneriseNotification == true) {
let isSyneriseSilentCommand = Synerise.Notifications.isSilentCommand(payload);
if (isSyneriseSilentCommand == true) {
<>
} else {
<>
}
}
}
});
```
## Payload
---
Android iOS
{
"data": {
<<campaign content>>
}
}
{
"aps": {
"content-available": 1
},
<<campaign content>>
}
## SDK Commands
---
### SIGN_OUT {id=sdk-commands-sign-out}
Android iOS
{
"data": {
"issuer": "Synerise",
"message-type": "dynamic-content",
"content-type": "silent-sdk-command",
"content": {
"class_name": "com.synerise.sdk.injector.Injector",
"method_name": "SIGN_OUT",
"method_parameters": []
}
}
}
{
"aps": {
"content-available": 1
},
"issuer": "Synerise",
"message-type": "dynamic-content",
"content-type": "silent-sdk-command",
"content": {
"class_name": "com.synerise.sdk.injector.Injector",
"method_name": "SIGN_OUT",
"method_parameters": []
}
}
### GET_LOCATION {id=sdk-commands-get-location}
Android iOS
{
"data": {
"issuer": "Synerise",
"message-type": "dynamic-content",
"content-type": "silent-sdk-command",
"content": {
"class_name": "com.synerise.sdk.injector.Injector",
"method_name": "GET_LOCATION",
"method_parameters": []
}
}
}
{
"aps": {
"content-available": 1
},
"issuer": "Synerise",
"message-type": "dynamic-content",
"content-type": "silent-sdk-command",
"content": {
"class_name": "com.synerise.sdk.injector.Injector",
"method_name": "GET_LOCATION",
"method_parameters": []
}
}
# Settings
This article describes options that allow you to change some SDK behaviors.
It contains all settings you can configure to change some SDK behaviors. The settings are divided into groups:
- [General](/developers/mobile-sdk/settings#general) - This group contains options related to the general functioning of mobile SDK.
- [Notifications](/developers/mobile-sdk/settings#notifications) - This group contains options related to push notifications.
- [In-app messaging](/developers/mobile-sdk/settings#in-app-messaging) - This group contains options related to the [in-app messages](/docs/campaign/in-app-messages) feature.
- [Tracker](/developers/mobile-sdk/settings#tracker) - This group contains options related to tracking the customer activities in a mobile application.
- [Injector](/developers/mobile-sdk/settings#injector) - This group contains options related to displaying [campaigns](/docs/campaign/Mobile).
## Pre-initialization settings
Some of the pre-initialization settings are optional. If you want to use them, they must be configured before Synerise SDK is initialized, before invoking the following methods:
- Synerise.Builder.build() (Android)
- [Synerise.initialize(apiKey:)](/developers/mobile-sdk/method-reference/ios/lifecycle#initialization) (iOS)
**Pre-initialization settings:**
- [Set up App Group Identifier](#set-up-app-group-identifier) (iOS only)
- [Set up Keychain Group Identifier](#set-up-keychain-group-identifier) (iOS only)
- [Maintaining customer session on different API keys](#maintaining-customer-session-on-different-api-keys)
- [Turn on/turn off notification encryption](#turn-onturn-off-notification-encryption)
**The rest of the options can be changed dynamically anytime.**
See advanced initialization example with all settings options for:
- [Advanced initialization - Android](/developers/mobile-sdk/installation-and-configuration/android#initialization)
- [Advanced initialization - iOS](/developers/mobile-sdk/installation-and-configuration/ios#advanced-initialization)
- [Advanced initialization - React Native](/developers/mobile-sdk/installation-and-configuration/react-native#advanced-initialization)
## General
### Enable/disable SDK
---
This parameter specifies if the SDK is enabled.
If the SDK is disabled, it means:
- the SDK does not send any events
- the SDK does not handle notifications
- the SDK does not show in-app messages
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.enabled` | `Boolean` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.enabled` | `Bool` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.Settings.sdk.enabled`| `boolean` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.enabled`| `bool` | true |
### Minimum time interval to refresh token
---
This parameter sets a time interval (in seconds) counting backwards from the expiration time. Within this time, the authorization token will be automatically refreshed by the SDK.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Method | Type | Default | Minimum |
| --- | --- | --- | --- |
| `Synerise.settings.sdk.setMinTokenRefreshInterval(value)` | `TimeInterval` | 1800 | 1800 |
| Parameter | Type | Default | Minimum |
| --- | --- | --- | --- |
| `Synerise.settings.sdk.minTokenRefreshInterval` | `TimeInterval` | 1800 | 1800 |
| Parameter | Type | Default | Minimum |
| --- | --- | --- | --- |
| `Synerise.Settings.sdk.minTokenRefreshInterval` | `number` | 1800 | 1800 |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.minTokenRefreshInterval`| `double` | 1800 |
### Maintaining customer session on different API keys
---
This parameter specifies if a session is destroyed after the Profile API (formerly Client) key changes.
This option must be configured when Synerise SDK is initialized.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.shouldDestroySessionOnApiKeyChange` | `Boolean` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.shouldDestroySessionOnApiKeyChange` | `Bool` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.Settings.sdk.shouldDestroySessionOnApiKeyChange` | `boolean` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.shouldDestroySessionOnApiKeyChange`| `bool` | true |
This option works only if you change the Profile (formerly Client) API key within one workspace.
To change the API key from a different workspace, use the following method:
- for Android [Client.changeApiKey](/developers/mobile-sdk/method-reference/android/lifecycle#change-profile-api-key-dynamically)
- for iOS [Synerise.changeApiKey](/developers/mobile-sdk/method-reference/ios/lifecycle#change-profile-api-key-dynamically)
- for React Native [Synerise.changeApiKey](/developers/mobile-sdk/method-reference/react-native/lifecycle#change-profile-api-key-dynamically)
- for Flutter [Synerise.changeApiKey](/developers/mobile-sdk/method-reference/flutter/lifecycle#change-profile-api-key-dynamically)
### Set up App Group Identifier
---
This parameter identifies the user default group applications and extensions belong to.
This option must be configured when Synerise SDK is initialized, before invoking the [Synerise.initialize(apiKey:)](/developers/mobile-sdk/method-reference/ios/lifecycle#initialization) method.
Available on: **iOS**, **React Native (iOS)**, **Flutter (iOS)**.
iOS React Native Flutter
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.appGroupIdentifier` | `String` | nil |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.Settings.sdk.appGroupIdentifier` | `string` | null |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.appGroupIdentifier`| `String` | null |
Synerise SDK requires this parameter to be configured for storing your non-sensitive data and sharing it between your app and extensions.
Your App Group must be registered on the [Apple Developer](https://developer.apple.com/) portal. It is recommended to use reverse-domain name style and prefix it with `group.` by default. For example, your App Group can be `group.com.synerise.sdk.sample`.
When your App Group is registered, add it as a capability on the [Apple Developer](https://developer.apple.com/) portal in App ID Configuration and in Xcode in the **Signing&Capabilities** tab.
Documentation is available at [Apple Developer - App Groups](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_application-groups).
Once configured, you need to set it up in the SDK:
#### Example
Swift Objective-C JavaScript Dart
```Swift
Synerise.settings.sdk.appGroupIdentifier = "group.com.synerise.sdk.sample"
```
```Objective-C
SNRSynerise.settings.sdk.appGroupIdentifier = @"group.com.synerise.sdk.sample";
```
```JavaScript
Synerise.Settings.sdk.appGroupIdentifier = "group.com.synerise.sdk.sample";
```
```Dart
Synerise.settings.sdk.appGroupIdentifier = "group.com.synerise.sdk.sample";
```
### Set up Keychain Group Identifier
---
This parameter identifies the keychain group used by applications, extensions and services that your app belongs to.
This option must be configured when Synerise SDK is initialized, before invoking the [Synerise.initialize(apiKey:)](/developers/mobile-sdk/method-reference/ios/lifecycle#initialization) method.
Available on: **iOS**, **React Native (iOS)**, **Flutter (iOS)**.
iOS React Native Flutter
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.keychainGroupIdentifier` | `String` | nil |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.Settings.sdk.keychainGroupIdentifier` | `string` | null |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.sdk.keychainGroupIdentifier`| `String` | null |
Synerise SDK requires that parameter to be configured for storing your data safely and sharing it between your app and extensions.
Your Keychain Group Identifier is made of:
- your Keychain Group
- your $(AppIdentifierPrefix), also called Team ID.
For example, if your Keychain Group is set to `SharedItems` and your Team ID is `ABC1234DEF`, the complete literal that you should set as Keychain Group Identifier is `ABC1234DEF.SharedItems`.
Documentation is available at [Apple Developer - Sharing Access to Keychain Items Among a Collection of Apps](https://developer.apple.com/documentation/security/keychain_services/keychain_items/sharing_access_to_keychain_items_among_a_collection_of_apps).
Once configured, you need to set it up in the SDK:
#### Example
Swift Objective-C JavaScript Dart
```Swift
Synerise.settings.sdk.keychainGroupIdentifier = "ABC1234DEF.SharedItems"
```
```Objective-C
SNRSynerise.settings.sdk.keychainGroupIdentifier = @"ABC1234DEF.SharedItems";
```
```JavaScript
Synerise.Settings.sdk.keychainGroupIdentifier = "ABC1234DEF.SharedItems";
```
```Dart
Synerise.settings.sdk.keychainGroupIdentifier = "ABC1234DEF.SharedItems";
```
### Localize some strings occurring in the SDK
---
This parameter specifies the localization of some strings occurring in the SDK.
When this option isn't used, the SDK uses default strings.
Available on: **iOS**, **React Native (iOS)**, **Flutter (iOS)**.
iOS React Native Flutter
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.sdk.localizable` | `[LocalizableStringKey: String]` | nil | 4.14.12 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.Settings.sdk.localizable` | `object` | null | 0.19.0 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.sdk.localizable` | `Map` | null | 1.0.0 |
We recommend updating the property when you change the language in the Host App.
## Notifications
### Enable/disable notifications
---
This parameter specifies if handling notifications by the SDK is enabled.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.notifications.enabled` | `Boolean` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.notifications.enabled` | `Bool` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.Settings.notifications.enabled` | `boolean` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.notifications.enabled` | `bool` | true |
### Turn on/turn off notification encryption
---
This parameter specifies if encryption for push notifications is enabled.
This option must be configured when Synerise SDK is initialized.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Method | Type | Default |
| --- | --- | --- |
| `Synerise.settings.notifications.setEncryption(value)` | `Boolean` | false |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.notifications.encryption` | `Bool` | false |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.Settings.notifications.encryption` | `boolean` | false |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.notifications.encryption` | `bool` | false |
Encryption must be enabled in the [workspace settings](https://app.synerise.com/spa/modules/old-settings/setting/integration), in the Firebase integration section.
The application must be properly configured and implemented for notification encryption:
- [Configure Notification Encryption for Android.](/developers/mobile-sdk/configuring-push-notifications/android#configure-notification-encryption)
- [Configure Notification Encryption for iOS.](/developers/mobile-sdk/configuring-push-notifications/ios#configure-notification-encryption)
- [Configure Notification Encryption for React Native.](/developers/mobile-sdk/configuring-push-notifications/react-native#configure-notification-encryption)
- [Configure Notification Encryption for Flutter.](/developers/mobile-sdk/configuring-push-notifications/flutter#configure-notification-encryption)
### Enable/disable notification in-app alerts
---
This parameter determines whether the SDK displays an additional alert in the application right after a notification is delivered.
If you have your own notification implementation, or you do not want to display alerts with notification content, you should disable in-app notification alerts from the Synerise SDK.
Also, read [here](/developers/mobile-sdk/campaigns/simple-push#additional-in-app-alert-when-simple-push-is-received).
Available on: **iOS**, **React Native (iOS)**, **Flutter (iOS)**.
iOS React Native Flutter
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.notifications.disableInAppAlerts` | `Bool` | false |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.Settings.notifications.disableInAppAlerts` | `boolean` | false |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.notifications.disableInAppAlerts` | `bool` | false |
## In-app messaging
### Check Global Control Groups when fetching definitions
---
This parameter specifies if global control groups should be checked immediately after in-app definitions are fetched.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.checkGlobalControlGroupsOnDefinitionsFetch` | `Boolean` | false | 5.15.0 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.checkGlobalControlGroupsOnDefinitionsFetch` | `Bool` | false | 4.15.0 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.Settings.notifications.checkGlobalControlGroupsOnDefinitionsFetch` | `boolean` | false | 0.19.0 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.checkGlobalControlGroupsOnDefinitionsFetch` | `bool` | false | 0.8.3 |
### Maximum time interval between in-app definition updates
---
This parameter sets the maximum interval (in seconds) between automatic [in-app message](/docs/campaign/in-app-messages) definition updates.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Method | Type | Default | Minimum | Min. SDK version |
| --- | --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.setMaxDefinitionUpdateIntervalLimit(value)` | `TimeInterval` | 600.0 | 600.0 | 4.7.0 |
| Parameter | Type | Default | Minimum | Min. SDK version |
| --- | --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.maxDefinitionUpdateIntervalLimit` | `TimeInterval` | 600.0 | 600.0 | 4.6.0 |
| Parameter | Type | Default | Minimum | Min. SDK version |
| --- | --- | --- | --- | --- |
| `Synerise.Settings.inAppMessaging.maxDefinitionUpdateIntervalLimit` | `number` | 600.0 | 600.0 | 0.12.0 |
| Parameter | Type | Default | Minimum | Min. SDK version |
| --- | --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.maxDefinitionUpdateIntervalLimit` | `double` | 600.0 | 600.0 | 0.4.0 |
### Content base URL for in-app message
---
This parameter defines the base URL for loading external resources (such as JavaScript files, CSS stylesheets, images, or fonts) within your in-app content. This is particularly useful when resources are hosted on your own server and you have set up **CORS (Cross-Origin Resource Sharing) policies**.
Thanks to the base URL, the app will know where to look for all external resources that are loaded dynamically. This helps avoid specifying full URLs each time a resource is requested and ensures that resources are consistently loaded from the correct location.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.contentBaseUrl` | `String` | null | 5.21.0 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.contentBaseUrl` | `String` | nil | 4.21.0 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.Settings.inAppMessaging.contentBaseUrl` | `string` | null | 0.24.0 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.contentBaseUrl` | `String` | null | 1.4.0 |
#### Example
You should set `contentBaseUrl` to the root URL of the server hosting your resources. This is especially important when hosting assets such as fonts, images, or scripts from a specific domain or server.
Swift Objective-C JavaScript Dart
```Swift
Synerise.settings.inAppMessaging.contentBaseUrl = "https://www.synerise.com"
```
```Objective-C
SNRSynerise.settings.inAppMessaging.contentBaseUrl = @"https://www.synerise.com";
```
```JavaScript
Synerise.Settings.inAppMessaging.contentBaseUrl = "https://www.synerise.com"
```
```Dart
Synerise.settings.inAppMessaging.contentBaseUrl = "https://www.synerise.com"
```
### Maximum time for in-app message rendering
---
This parameter sets a timeout (in seconds) for in-app message rendering.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Parameter | Type | Default | Minimum | Min. SDK version |
| --- | --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.renderingTimeout` | `TimeInterval` | 2.0 | - | 4.7.0 |
| Parameter | Type | Default | Minimum | Min. SDK version |
| --- | --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.renderingTimeout` | `TimeInterval` | 5.0 | 1.0 | 4.6.0 |
| Parameter | Type | Default | Minimum | Min. SDK version |
| --- | --- | --- | --- | --- |
| `Synerise.Settings.inAppMessaging.renderingTimeout` | `number` | 2.0 (Android) 5.0 (iOS) | - (Android) 1.0 (iOS) | 0.12.0 |
| Parameter | Type | Default | Minimum | Min. SDK version |
| --- | --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.renderingTimeout` | `double` | 2.0 (Android) 5.0 (iOS) | - (Android) 1.0 (iOS) | 0.4.0 |
### Enable/disable sending inApp.capping event
---
This parameter specifies if the SDK should send the `inApp.capping` event.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.shouldSendInAppCappingEvent` | `Boolean` | true | 5.10.1 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.shouldSendInAppCappingEvent` | `Bool` | true | 4.14.8 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.Settings.inAppMessaging.shouldSendInAppCappingEvent` | `boolean` | true | 0.16.0 |
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.inAppMessaging.shouldSendInAppCappingEvent` | `bool` | true | 0.7.2 |
## Tracker
### Enable/disable declarative tracking
---
This parameter specifies if the [declarative tracking](/developers/mobile-sdk/event-tracking#declarative-tracking) feature is enabled.
Available on: **Android**, **iOS**.
Android iOS
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.tracking.enabled` | `Boolean` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.tracking.enabled` | `Bool` | true |
### Enable/disable auto-tracking
---
Autotracking is **NOT** available when building apps with Jetpack Compose (Android) and SwiftUI (iOS).
This parameter specifies if the [auto-tracking feature](/developers/mobile-sdk/event-tracking#auto-tracking) is enabled.
Available on: **Android**, **iOS**.
Android iOS
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.autoTracking.enabled` | `Boolean` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.autoTracking.enabled` | `Bool` | true |
### Require/do not require backend time synchronization to send events
---
This parameter specifies if events are sent when the server time synchronization has failed.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.isBackendTimeSyncRequired` | `Boolean` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.isBackendTimeSyncRequired` | `Bool` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.Settings.tracker.isBackendTimeSyncRequired` | `Bool` | true |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.isBackendTimeSyncRequired` | `bool` | true |
### Minimum number of events in queue
---
This parameter sets the minimum number of events in queue required to send the queue.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Method | Type | Default | Minimum | Maximum |
| --- | --- | --- | --- | --- |
| `Synerise.settings.tracker.setMinimumBatchSize(value)` | `Integer` | 10 | 1 | 100 |
| Parameter | Type | Default | Minimum | Maximum |
| --- | --- | --- | --- | --- |
| `Synerise.settings.tracker.minBatchSize` | `Int` | 10 | 1 | 100 |
| Parameter | Type | Default | Minimum | Maximum |
| --- | --- | --- | --- | --- |
| `Synerise.Settings.tracker.minBatchSize` | `number` | 10 | 1 | 100 |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.minBatchSize` | `int` | 10 | 1 | 100 |
If the [timer](/developers/mobile-sdk/settings#timeout-to-send-events-automatically) runs out, events are sent even if the queue is smaller than defined in **minBatchSize**.
### Maximum number of events in queue
---
This parameter sets the maximum number of events which may be sent in a single batch.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Method | Type | Default | Minimum | Maximum |
| --- | --- | --- | --- | --- |
| `Synerise.settings.tracker.setMaximumBatchSize(value)` | `Integer` | 100 | 1 | 100 |
| Parameter | Type | Default | Minimum | Maximum |
| --- | --- | --- | --- | --- |
| `Synerise.Settings.tracker.maxBatchSize` | `number` | 100 | 1 | 100 |
| Parameter | Type | Default | Minimum | Maximum |
| --- | --- | --- | --- | --- |
| `Synerise.Settings.tracker.maxBatchSize` | `number` | 100 | 1 | 100 |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.maxBatchSize` | `int` | 100 | 1 | 100 |
### Timeout to send events automatically
---
This parameter sets the time (in milliseconds for Android, in seconds for other SDKs) required before an attempt is made to send the queue.
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Method | Type | Default | Minimum | Maximum |
| --- | --- | --- | --- | --- |
| `Synerise.settings.tracker.setAutoFlushTimeout(value)` | `TimeInterval` | 5000 | 50 | - |
| Parameter | Type | Default | Minimum | Maximum |
| --- | --- | --- | --- | --- |
| `Synerise.settings.tracker.autoFlushTimeout` | `TimeInterval` | 5.0 | 0.5 | - |
| Parameter | Type | Default | Minimum | Maximum |
| --- | --- | --- | --- | --- |
| `Synerise.Settings.tracker.autoFlushTimeout` | `number` | 5.0 | 0.5 | - |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.autoFlushTimeout` | `double` | 5.0 | 0.5 | - |
If the [minimum queue size](/developers/mobile-sdk/settings#minimum-number-of-events-in-queue) is met, events are sent even if the timer has not run out.
### Events triggering flush mechanism
---
This parameter sets an array of event 'action' values which trigger the flush mechanism.
The list can be modified or cleared - including removing the default values.
Available on: **Android** (5.17.0 or newer), **iOS** (4.17.0 or newer).
Android iOS
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.tracker.eventsTriggeringFlush` | `List` | ["push.click", "push.view", "push.notView", "push.button.click", "push.dismiss"] | 5.17.0 |
In iOS, `push.view` events are handled by the Notification Service Extension and always sent immediately, regardless of this setting.
| Parameter | Type | Default | Min. SDK version |
| --- | --- | --- | --- |
| `Synerise.settings.tracker.eventsTriggeringFlush` | `[String]` | ["push.openInApp", "push.click", "push.button.click", "push.dismiss"] | 4.17.0 |
### Automatic location event sending
---
This parameter specifies if location events are sent automatically.
Available on: **Android**, **iOS**.
Android iOS
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.locationAutomatic` | `Boolean` | false |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.locationAutomatic` | `Bool` | false |
### Auto-tracking mode
---
This parameter parameter defines the [auto-tracking](/developers/mobile-sdk/event-tracking#auto-tracking-configuration) mode.
Available on: **Android**, **iOS**.
Android iOS
- `PLAIN` - listeners are set to track screen visits only.
- `FINE` - listeners are attached to nearly everything that is clickable in your app, including screen visits.
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.autoTracking.trackMode` | TrackMode | FINE |
- `.disabled` - listeners are disabled (default).
- `.plain` - listeners are set to on-click only.
- `.fine` - listeners are attached to nearly everything in your app (even to activities and `viewDidAppear`, the method that records [**VisitedScreen**](/developers/mobile-sdk/class-reference/ios/events#visitedscreenevent) events).
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.autoTracking.mode` | `TrackerAutoTrackMode` | .disabled |
### Classes excluded from auto-tracking
---
This parameter excludes classes from auto-tracking.
Available on: **Android**, **iOS**.
Android iOS
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.autoTracking.excludedClasses` | `List` | [] |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.autoTracking.excludedClasses` | `[AnyClass]` | [] |
### View Tags excluded from auto-tracking
---
This parameter excludes view tags from [auto-tracking](/developers/mobile-sdk/event-tracking#auto-tracking-configuration).
Available on: **iOS**.
iOS
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.tracker.autoTracking.excludedViewTags` | `[Int]` | [] |
## Injector
### Enable/disable automatic starting of mobile campaigns (deprecated)
---
This parameter specifies if walkthrough is processed automatically or not. - **DEPRECATED**
Available on: **Android**, **iOS**, **React Native**, **Flutter**.
Android iOS React Native Flutter
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.injector.automatic` | `Boolean` | false |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.injector.automatic` | `Bool` | false |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.Settings.injector.automatic` | `boolean` | false |
| Parameter | Type | Default |
| --- | --- | --- |
| `Synerise.settings.injector.automatic` | `bool` | false |
# React Native
## React Native listeners
#### Initialization {id=initialization}
A listener to handle the SDK lifecycle events.
JavaScript
```JavaScript
Synerise.onReady(function() {
...
});
Synerise.onError(function(error) {
...
})
```
---
---
#### NotificationsListener {id=notifications-listener}
A listener to handle actions from the notifications module.
JavaScript
```JavaScript
Synerise.Notifications.setListener({
// The following method is called when Synerise receives a registration token from the native part of application
// It is optional function
onRegistrationToken: function(token) {
...
},
// The following method is called when registration for Push Notifications is needed.
// It is optional function
onNotification: function(payload) {
...
},
// The following method is called when Synerise receives a notification's payload from the native part of application.
// It is optional function
onRegistrationRequired: function() {
...
}
});
```
After invoking **onRegistrationRequired()** function, you must invoke the [Synerise.Notifications.registerForNotifications(registrationToken, mobileAgreement, onSuccess, onError)](/developers/mobile-sdk/method-reference/react-native/campaigns#register-for-push-notifications) method again.
---
---
#### ClientStateListener {id=client-state-listener}
A listener to handle customer's sign-in state changes.
JavaScript
```JavaScript
Synerise.Client.setClientStateListener({
// The following method is called when a customer signs in.
// It is optional function
onClientSignedIn: function() {
...
},
// The following method is called when a customer signs out
// It is optional function
onClientSignedOut: function(reason) {
...
}
});
```
---
---
#### InjectorListener {id=injector-listener}
A listener to handle URL and deeplink actions from the injector module.
JavaScript
```JavaScript
Synerise.Injector.setListener({
// The following method is called when Synerise handles URL action from campaign activities
// It is required function
onOpenUrl: function(url) {
...
},
// The following method is called when Synerise handles deep link action from campaign activities
// It is required function
onDeepLink: function(deepLink) {
...
}
});
```
---
---
#### InjectorInAppMessageListener {id=injector-in-app-message-listener}
A listener to handle the states of [in-app messages](/developers/mobile-sdk/campaigns/in-app-message).
JavaScript
```JavaScript
Synerise.Injector.setInAppMessageListener({
shouldPresent: function(data) {
return true;
},
// The following method is called after an in-app message appears
onPresent: function (data) {
...
},
// The following method is called after an in-app message disappears
onHide: function(data) {
...
},
// This method is called when a individual context for an in-app message is needed
contextIsNeeded: function(data) {
return {}
},
// This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
onOpenUrl: function (data, url) {
...
},
// This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
onDeepLink: function (data, deepLink) {
...
},
// This method is called when the
// SRInApp.handleCustomAction(name, params) method is used in an in-app message.
onCustomAction: function(data, name, parameters) {
}
})
```
---
---
### InjectorWalkthroughListener {id=injector-walkthrough-listener}
**InjectorWalkthroughListener** was removed in SDK version 1.0.0..
---
---
### InjectorBannerListener {id=injector-banner-listener}
**InjectorBannerListener** was removed in SDK version 1.0.0..
# React Native
## Method reference - React Native
# Customer account management
---
## Get customer account information
---
This method gets a customer’s account information.
This method requires customer authentication.
The API key must have the `API_PERSONAL_INFORMATION_CLIENT_READ` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientAccountInformation](/developers/mobile-sdk/class-reference/react-native/client#clientaccountinformation)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public getAccount(onSuccess: (clientAccountInformation: ClientAccountInformation) => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.getAccount(function(clientAccountInformation) {
//success
}, function(error) {
//failure
});
```
## Update customer account basic information
---
This method updates a customer’s account’s basic information (without identification data: uuid, customId, email).
This method requires the context object with the customer’s account information. Omitted fields are not modified.
This method does not require customer authentication and can be used by anonymous profiles.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 4.22.0 | 5.21.0 | 0.24.0 | 1.4.0 |
The API key must have the `API_BASIC_INFORMATION_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientAccountBasicInformationUpdateContext](/developers/mobile-sdk/class-reference/react-native/client#clientaccountupdatebasicinformationcontext)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public updateAccountBasicInformation(context: ClientAccountBasicInformationUpdateContext, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientAccountBasicInformationUpdateContext](/developers/mobile-sdk/class-reference/react-native/client#clientaccountupdatebasicinformationcontext) | yes | - | Object with customer’s first name, phone, and other optional data |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
let context = new ClientAccountBasicInformationUpdateContext();
context.firstName = 'John';
context.lastName = 'Rise';
context.displayName = 'John Rise';
context.sex = ClientSex.Male;
context.phone = '123456789';
context.birthDate = '1989-08-03';
context.company = 'Synerise';
context.address = 'Marszałkowska';
context.city = 'Warszawa';
context.province = 'Mazowieckie';
context.zipCode = '00-000';
context.countryCode = '+48';
context.agreements = new ClientAgreements({
email: true,
sms: true,
push: true,
bluetooth: true,
rfid: true,
wifi: true
});
context.attributes = { ATTRIBUTE_1: 'ATTRIBUTE_1' }
Synerise.Client.updateAccountBasicInformation(context, function() {
// success
}, function(error) {
// failure
})
```
## Update customer account information
---
This method updates a customer’s account information.
This method requires the context object with the customer’s account information. Omitted fields are not modified.
This method requires customer authentication.
The API key must have the `API_PERSONAL_INFORMATION_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientAccountUpdateContext](/developers/mobile-sdk/class-reference/react-native/client#clientaccountupdatecontext)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public updateAccount(context: ClientAccountUpdateContext, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientAccountUpdateContext](/developers/mobile-sdk/class-reference/react-native/client#clientaccountupdatecontext) | yes | - | Object with customer's email, password, and other optional data |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
let context = new ClientAccountUpdateContext();
context.email = 'hello@synerise.com';
context.phone = '123456789';
context.customId = '000111';
context.firstName = 'John';
context.lastName = 'Rise';
context.displayName = 'John Rise';
context.sex = ClientSex.Male;
context.birthDate = '1989-08-03';
context.company = 'Synerise';
context.address = 'Marszałkowska';
context.city = 'Warszawa';
context.province = 'Mazowieckie';
context.zipCode = '00-000';
context.countryCode = '+48';
context.agreements = new ClientAgreements({
email: true,
sms: true,
push: true,
bluetooth: true,
rfid: true,
wifi: true
});
context.attributes = { ATTRIBUTE_1: 'ATTRIBUTE_1' }
Synerise.Client.updateAccount(context, function() {
// success
}, function(error) {
// failure
})
```
## Change customer's account password
---
This method changes a customer’s password.
This method requires customer authentication.
Returns the HTTP 403 status code if the provided old password is invalid.
The API key must have the `SAUTH_CHANGE_PASSWORD_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public changePassword(oldPassword: string, newPassword: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **newPassword** | string | yes | - | Customer's new password |
| **oldPassword** | string | yes | - | Customer's old password |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
let newPassword = "NEW_PASSWORD";
let oldPassword = "OLD_PASSWORD";
Synerise.Client.changePassword(newPassword, oldPassword, function() {
// success
}, function(error) {
// failure
});
```
## Request password reset for customer account
---
This method requests a customer’s password reset with email. The customer will receive a token to the provided email address. That token is then used for the confirmation of password reset.
This method requires the customer’s email.
This method is a global operation and doesn't require customer authentication.
The API key must have the `SAUTH_PASSWORD_RESET_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public requestPasswordReset(email: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | string | yes | - | Customer's email |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.requestPasswordReset("EMAIL", function() {
// success
}, function(error) {
// failure
});
```
## Confirm password reset for customer account
---
This method confirm a customer’s password reset with the new password and token provided by password reset request.
This method requires the customer’s new password and the confirmation token received by e-mail.
This method is a global operation and doesn't require customer authentication.
The API key must have the `SAUTH_PASSWORD_RESET_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public confirmPasswordReset(password: string, token: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **password** | string | yes | - | Customer's new password |
| **token** | string | yes | - | Customer's token provided in an email |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.confirmPasswordReset("PASSWORD", "TOKEN", function() {
// success
}, function(error) {
// failure
});
```
## Request email change for customer account
---
This method requests a customer's email change.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided token or the password is invalid.
The API key must have the `SAUTH_CHANGE_EMAIL_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public requestEmailChange(email: string, password: string | null, externalToken: string | null, authID: string | null, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | string | yes | - | Customer's new email |
| **password** | string | yes | - | Customer's password |
| **externalToken** | AnyObject | no | - | Customer's token (if OAuth, Facebook, and so on) |
| **authID** | String | no | - | Optional identifier of authorization |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.requestEmailChange("EMAIL", "PASSWORD", function() {
// success
}, function(error) {
// failure
});
```
## Confirm email change for customer account
---
This method confirms an email change.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided token is invalid.
The API key must have the `SAUTH_CHANGE_EMAIL_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public confirmEmailChange(token: string, newsletterAgreement: Boolean, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | string | yes | - | Customer's token provided in an email |
| **newsletterAgreement** | boolean | yes | - | Agreement for sending newsletters to the provided email |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.confirmEmailChange("TOKEN", true, function() {
// success
}, function(error) {
// failure
});
```
## Request phone update on customer account
---
This method requests a customer's phone update. A confirmation code is sent to the phone number.
This method is a global operation and doesn't require customer authentication.
The API key must have the `API_PERSONAL_PHONE_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public requestPhoneUpdate(phone: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **phone** | string | yes | - | Customer's new phone number |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.requestPhoneUpdate("PHONE", function() {
// success
}, function(error) {
// failure
});
```
## Confirm phone update on customer account
---
This method confirms a phone number update. This action requires the new phone number and confirmation code as parameters.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided UUID does not exist or the password is invalid.
The API key must have the `API_PERSONAL_PHONE_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public confirmPhoneUpdate(phone: string, confirmationCode: string, smsAgreement: Boolean, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **phone** | string | yes | - | New phone number |
| **confirmationCode** | string | yes | - | A confirmation code received by a text message |
| **smsAgreement** | boolean | yes | - | Agreement for sending SMS to the provided number |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.confirmPhoneUpdate("PHONE", "CONFIRMATION_CODE", true, function() {
// success
}, function(error) {
// failure
});
```
## Delete customer account by Identity Provider
---
This method deletes a customer's account.
This method requires customer authentication.
HTTP 403 status code is returned if the provided password or token is invalid.
The API key must have the `SAUTH_CLIENT_DELETE`, `SAUTH_OAUTH_CLIENT_DELETE`, `SAUTH_FACEBOOK_CLIENT_DELETE`, `SAUTH_APPLE_CLIENT_DELETE` permissions from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Related To:**
[ClientIdentityProvider](/developers/mobile-sdk/class-reference/react-native/client#clientidentityprovider)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public deleteAccountByIdentityProvider(clientAuthFactor: string, clientIdentityProvider: ClientIdentityProvider, authID: string | null, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **clientAuthFactor** | string | yes | - | Token retrieved from provider |
| **clientIdentityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/react-native/client#clientidentityprovider) | yes | - | Provider of your token |
| **authID** | string | no | null | Optional identifier of authorization |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
## Deprecated methods
### Delete customer account
---
This method deletes a customer's account.
This method requires customer authentication.
| | **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.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | n/a | n/a |
Returns the HTTP 403 status code is returned if the provided password is invalid.
The API key must have the `SAUTH_CLIENT_DELETE` permission from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public deleteAccount(password: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **password** | string | yes | - | Customer's password |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
let password = "PASSWORD";
Synerise.Client.deleteAccount(password, function(token) {
// success
}, function(error) {
// failure
});
```
### Delete customer account by OAuth
---
This method deletes a customer's account by OAuth.
This method requires customer authentication.
| | **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.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | n/a | n/a |
The API key must have the `SAUTH_CLIENT_DELETE` and `SAUTH_OAUTH_CLIENT_DELETE` permissions from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public deleteAccountByOAuth(accessToken: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **accessToken** | string | yes | - | OAuth Access Token |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.deleteAccountByOAuth(accessToken, function(token) {
// success
}, function(error) {
// failure
});
```
### Delete customer account by Facebook
---
This method deletes a customer's account by Facebook.
This method requires customer authentication.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 3.3.8 | 3.3.0 | 0.9.12 | n/a |
| Deprecated in: | 3.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | n/a | n/a |
The API key must have the `SAUTH_CLIENT_DELETE` and `SAUTH_FACEBOOK_CLIENT_DELETE` permissions from the **Client** group.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public deleteAccountByFacebook(facebookToken: string, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **facebookToken** | string | yes | - | Facebook Access Token |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.deleteAccountByFacebook(facebookToken, function(token) {
// success
}, function(error) {
// failure
});
```
# Events
### Event
Main event abstract class for inheriting classes.
This is an abstract class and it is not meant to be instantiated directly. You should use concrete `RecommendationEvent` subclasses instead.
**Declared In:**
lib/classes/events/Event.js
**Declaration:**
abstract class Event
**Initializers:**
constructor(type: string, label: string, action: string | null, parameters: object)
---
---
### CustomEvent
DO NOT send `transaction.charge` events as custom events.
Transactions must be tracked with these endpoints:
- [`/v4/transactions`](https://hub.synerise.com/api-reference/data-management#operation/CreateATransaction) (single transaction)
- [`/v4/transactions/batch`](https://hub.synerise.com/api-reference/data-management#operation/BatchAddOrUpdateTransactions) (multiple transactions)
Represents a custom client event.
**Declared In:**
lib/classes/events/other/CustomEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class CustomEvent extends Event
**Initializers:**
constructor(label: string, action: string, parameters?: Record<string, any>)
---
---
### PushViewedEvent
Represents a 'client viewed push' event.
This event is used for push message interaction tracking.
**Declared In:**
lib/classes/events/push/ViewedPushEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class PushViewedEvent extends Event
**Initializers:**
constructor(label: string, parameters?: object)
---
---
### PushClickedEvent
Represents a 'client clicked push' event.
This event is used for push message interaction tracking.
**Declared In:**
lib/classes/events/push/ClickedPushEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class PushClickedEvent extends Event
**Initializers:**
constructor(label: string, parameters?: object)
---
---
### PushCancelledEvent
Represents a 'client viewed push' event.
This event is used for push message interaction tracking.
**Declared In:**
lib/classes/events/push/CancelledPushEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class PushCancelledEvent extends Event
**Initializers:**
constructor(label: string, parameters?: object)
---
---
### CartEvent
Main cart action abstract class for inheriting classes.
This is an abstract class and it is not meant to be instantiated directly. You should use concrete `CartEvent` subclasses instead.
**Declared In:**
lib/classes/events/cart/CartEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class CartEvent extends Event
**Initializers:**
constructor(type: string, label: string, sku: string, finalPrice: UnitPrice, quantity: number, parameters?: object)
**Methods:**
This method sets a value for the `name` parameter.
public setName(name: string)
---
This method sets a value for the `category` parameter.
public setCategory(category: string)
---
This method sets values for the `categories` parameter.
public setCategories(categories: string[])
---
This method sets a value for the `offline` parameter.
public setOffline(offline: boolean)
---
This method sets the value of the `regularPrice` parameter.
public setRegularPrice(regularPrice: UnitPrice)
---
This method sets the value of the `discountedPrice` parameter.
public setDiscountedPrice(discountedPrice: UnitPrice)
---
This method sets the value of the `url` parameter.
public setUrl(url: string)
---
This method sets the value of the `producer` parameter (producer can signify a brand of the item).
public setProducer(producer: string)
---
---
### UnitPrice
**Declared In:**
lib/classes/events/cart/UnitPrice.js
**Declaration:**
class UnitPrice
**Initializers:**
constructor(amount: number, currency: string)
---
---
### ProductAddedToCartEvent
Represents a 'client added product to cart' event.
**Declared In:**
lib/classes/events/product/ProductAddedToCartEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class ProductAddedToCartEvent extends CartEvent
**Initializers:**
constructor(label: string, sku: string, finalPrice: UnitPrice, quantity: number, parameters?: object)
---
---
### ProductRemovedFromCartEvent
Represents a 'client removed product from cart' event.
**Declared In:**
lib/classes/events/cart/RemovedFromCartEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class ProductRemovedFromCartEvent extends CartEvent
**Initializers:**
constructor(label: string, sku: string, finalPrice: UnitPrice, quantity: number, parameters?: object)
---
---
### ProductViewedEvent
Represents a 'client viewed product' event.
**Declared In:**
lib/classes/events/product/ProductViewEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class ProductViewedEvent extends Event
**Initializers:**
constructor(label: string, productId: string, name: string, parameters?: object)
**Methods:**
This method sets a value for the `category` parameter.
public setCategory(category: string)
---
This method sets the value of the `url` parameter.
public setUrl(url: string)
---
---
### ProductAddedToFavoritesEvent
Represents a 'client added product to favorites' event.
**Declared In:**
lib/classes/events/product/ProductAddedToFavouritesEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class ProductAddedToFavouritesEvent extends Event
**Initializers:**
constructor(label: string, parameters?: object)
---
---
### LoggedInEvent
Represents a 'client logged in' event.
**Declared In:**
lib/classes/events/auth/LoggedInEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class LoggedInEvent extends Event
---
---
### LoggedOutEvent
Represents a 'client logged out' event.
**Declared In:**
lib/classes/events/auth/LoggedOutEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class LoggedOutEvent extends Event
---
---
### RegisteredEvent
Represents a 'client registered' event.
**Declared In:**
lib/classes/events/auth/RegisteredEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class RegisteredEvent extends Event
**Initializers:**
constructor(label: string, parameters?: object)
---
---
## RecommendationEvent
Main recommendation abstract class for inheriting classes.
This is an abstract class and it is not meant to be instantiated directly. You should use concrete `RecommendationEvent` subclasses instead.
**Declared In:**
lib/classes/events/recommendation/RecommendationEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class RecommendationEvent extends Event
**Initializers:**
constructor(type: string, label: string, productId: string, name: string, campaignId: string, campaignHash: string, parameters?: object)
---
---
### RecommendationSeenEvent
Represents a 'client saw a recommendation' event.
**Declared In:**
lib/classes/events/recommendation/RecommendationSeenEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class RecommendationSeenEvent extends RecommendationEvent
**Initializers:**
constructor(label: string, productId: string, name: string, campaignId: string, campaignHash: string, parameters?: object)
---
---
### RecommendationClickEvent
Represents a 'client clicked a recommendation' event.
**Declared In:**
lib/classes/events/recommendation/RecommendationClickEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
[RecommendationEvent](/developers/mobile-sdk/class-reference/react-native/events#recommendationevent)
**Declaration:**
class RecommendationClickEvent extends RecommendationEvent
**Initializers:**
constructor(label: string, productId: string, name: string, campaignId: string, campaignHash: string, parameters?: object)
---
---
### VisitedScreenEvent
Represents a 'client visited screen' event.
This can be used for mobile screen usage tracking.
**Declared In:**
lib/classes/events/other/VisitedScreenEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class VisitedScreenEvent extends Event
**Initializers:**
constructor(label: string, parameters?: object)
---
---
### HitTimerEvent
Represents a 'client hit timer' event.
This could be used for profiling or activity time monitoring - you can send a `HitTimerEvent` when your client starts doing something and send it once again when they finish, but this time with the different time signature. Then you can use our analytics engine to measure, for example, average activity time.
**Declared In:**
lib/classes/events/other/HitTimerEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class HitTimerEvent extends Event
**Initializers:**
constructor(label: string, parameters?: object)
---
---
### SearchedEvent
Represents a 'client searched' event.
**Declared In:**
lib/classes/events/other/SearchedEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class SearchedEvent extends Event
**Initializers:**
constructor(label: string, parameters?: object)
---
---
### SharedEvent
Represents a 'client shared' event.
**Declared In:**
lib/classes/events/other/SharedEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class SharedEvent extends Event
**Initializers:**
constructor(label: string, parameters?: object)
---
---
### AppearedInLocationEvent
Represents a 'client appeared in location' event.
**Declared In:**
lib/classes/events/other/AppearedInLocationEvent.js
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
**Declaration:**
class AppearedInLocationEvent extends Event
**Initializers:**
constructor(label: string, lat: number, lon: number, parameters?: object)
# Customer account management
## Get customer account information
---
This method gets a customer’s account information.
This method requires customer authentication.
The API key must have the `API_PERSONAL_INFORMATION_CLIENT_READ` permission from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientAccountInformation](/developers/mobile-sdk/class-reference/ios/client#clientaccountinformation)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func getAccount(success: ((ClientAccountInformation) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)getAccountWithSuccess:(nonnull void (^)(SNRClientAccountInformation *accountInformation))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **success** | ((ClientAccountInformation) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
Client.getAccount(success: { (clientAccountInformation) in
// success
}) { (error) in
// failure
}
```
```Objective-C
[SNRClient getAccountWithSuccess:^(SNRClientAccountInformation *accountInformation) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
```
## Get customer's events
---
This method retrieves events for an authenticated customer.
This method requires customer authentication.
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientEventsApiQuery](/developers/mobile-sdk/class-reference/ios/client#clienteventsapiquery)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func getEvents(apiQuery: ClientEventsApiQuery, success: (([ClientEventData]) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)getEventsWithApiQuery:(nonnull SNRClientEventsApiQuery *)apiQuery success:(nonnull void (^)(NSArray *events))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **apiQuery** | [ClientEventsApiQuery](/developers/mobile-sdk/class-reference/ios/client#clienteventsapiquery) | yes | - | Object responsible for storing all query parameters |
| **success** | (([ClientEventData]) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
## Update customer account basic information
---
This method updates a customer’s account’s basic information (without identification data: uuid, customId, email).
This method requires the context object with the customer’s account information. Omitted fields are not modified.
This method does not require customer authentication and can be used by anonymous profiles.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 4.22.0 | 5.21.0 | 0.24.0 | 1.4.0 |
The API key must have the `API_BASIC_INFORMATION_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientUpdateAccountBasicInformationContext](/developers/mobile-sdk/class-reference/ios/client#clientupdateaccountbasicinformationcontext)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func updateAccountBasicInformation(context: ClientUpdateAccountBasicInformationContext, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)updateAccountBasicInformation:(nonnull SNRClientUpdateAccountBasicInformationContext *)context success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientUpdateAccountBasicInformationContext](/developers/mobile-sdk/class-reference/ios/client#clientupdateaccountbasicinformationcontext) | yes | - | Object with customer's basic information optional data |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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.
## Update customer account information
---
This method updates a customer’s account information.
This method requires the context object with the customer’s account information. Omitted fields are not modified.
This method requires customer authentication.
The API key must have the `API_PERSONAL_INFORMATION_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientUpdateAccountContext](/developers/mobile-sdk/class-reference/ios/client#clientupdateaccountcontext)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func updateAccount(context: ClientUpdateAccountContext, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)updateAccount:(nonnull SNRClientUpdateAccountContext *)context success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientUpdateAccountContext](/developers/mobile-sdk/class-reference/ios/client#clientupdateaccountcontext) | yes | - | Object with customer's email, password, and other optional data |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let agreements: ClientAgreements = ClientAgreements()
agreements.email = true
agreements.sms = true
agreements.push = true
agreements.bluetooth = true
agreements.rfid = true
agreements.wifi = true
let context: ClientUpdateAccountContext = ClientUpdateAccountContext()
context.email = "hello@synerise.com"
context.phone = "123-456-789"
context.customId = "CUSTOM_ID"
context.uuid = "UUID"
context.firstName = "FIRST_NAME"
context.lastName = "LAST_NAME"
context.displayName = "DISPLAY_NAME"
context.sex = .male
context.company = "Synerise"
context.address = "Lubostroń 1"
context.city = "Kraków"
context.province = "Małopolskie"
context.zipCode = "30-383"
context.countryCode = "+48"
context.birthDate = "01-01-2019"
context.avatarUrl = "http://www.synerise.com"
context.agreements = agreements
context.attributes = ["attribute1": "value1", "attribute2": "value2"]
context.tags = ["tag1", "tag2" "tag3"]
Client.updateAccount(context: context, success: {
// success
}) { (error) in
// failure
}
```
```Objective-C
SNRClientAgreements *agreements = [SNRClientAgreements new];
agreements.email = true;
agreements.sms = true;
agreements.push = true;
agreements.bluetooth = true;
agreements.rfid = true;
agreements.wifi = true;
SNRClientUpdateAccountContext *context = [SNRClientUpdateAccountContext new];
context.email = @"hello@synerise.com"
context.phone = @"123-456-789";
context.customId = @"CUSTOM_ID"
context.firstName = @"FIRST_NAME";
context.lastName = @"LAST_NAME";
context.displayName = @"DISPLAY_NAME"
context.sex = SNRClientSexMale;
context.company = @"Synerise";
context.address = @"Lubostroń 1";
context.city = @"Kraków";
context.province = @"Małopolskie";
context.zipCode = @"30-383";
context.countryCode = @"+48";
context.birthDate = @"01-01-2019"
context.avatarUrl = @"http://www.synerise.com"
context.agreements = agreements;
context.attributes = @{@"attribute": @"value"};
context.tags = @[@"tag1", @"tag2" @"tag3"];
[SNRClient updateAccount:context success:^() {
// success
} failure:^(NSError * _Nonnull error) {
// failure
}];
```
## Change customer's account password
---
This method changes a customer’s password.
This method requires customer authentication.
Returns the HTTP 403 status code if the provided old password is invalid.
The API key must have the `SAUTH_CHANGE_PASSWORD_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func changePassword(password: String, oldPassword: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)changePassword:(nonnull NSString *)password oldPassword:(nonnull NSString *)oldPassword success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **password** | String | yes | - | Customer's new password |
| **oldPassword** | String | yes | - | Customer's old password |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let newPassword: String = "NEW_PASSWORD"
let oldPassword: String = "OLD_PASSWORD"
Client.changePassword(password: newPassword, oldPassword: oldPassword, success: {
// success
}, failure: { (error) in
// failure
})
```
```Objective-C
NSString *newPassword = @"NEW_PASSWORD";
NSString *oldPassword = @"OLD_PASSWORD";
[SNRClient changePassword:newPassword oldPassword:oldPassword success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
```
## Request password reset for customer account
---
This method requests a customer’s password reset with email. The customer will receive a token to the provided email address. That token is then used for the confirmation of password reset.
This method requires the customer’s email.
This method is a global operation and doesn't require customer authentication.
The API key must have the `SAUTH_PASSWORD_RESET_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientPasswordResetRequestContext](/developers/mobile-sdk/class-reference/ios/client#clientpasswordresetrequestcontext)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func requestPasswordReset(context: ClientPasswordResetRequestContext, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)requestPasswordReset:(nonnull SNRClientPasswordResetRequestContext *)context success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientPasswordResetRequestContext](/developers/mobile-sdk/class-reference/ios/client#clientpasswordresetrequestcontext) | yes | - | Object with the customer's email |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let email: String = "EMAIL"
let context: ClientPasswordResetRequestContext = ClientPasswordResetRequestContext(email: email)
Client.requestPasswordReset(context: context, success: {
// success
}, failure: { (error) in
// failure
})
```
```Objective-C
NSString *email = @"EMAIL";
SNRClientPasswordResetRequestContext *context = [SNRClientPasswordResetRequestContext alloc] initWithEmail:email];
[SNRClient requestPasswordReset:context success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
```
## Confirm password reset for customer account
---
This method confirm a customer’s password reset with the new password and token provided by password reset request.
This method requires the customer’s new password and the confirmation token received by e-mail.
This method is a global operation and doesn't require customer authentication.
The API key must have the `SAUTH_PASSWORD_RESET_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientPasswordResetConfirmationContext](/developers/mobile-sdk/class-reference/ios/client#clientpasswordresetconfirmationcontext)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func confirmResetPassword(context: ClientPasswordResetConfirmationContext, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)confirmResetPassword:(nonnull SNRClientPasswordResetConfirmationContext *)context success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientPasswordResetConfirmationContext](/developers/mobile-sdk/class-reference/ios/client#clientpasswordresetconfirmationcontext) | yes | - | Object with customer's password and token |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let password: String = "PASSWORD"
let token: String = "TOKEN"
let context: ClientPasswordResetConfirmationContext = ClientPasswordResetConfirmationContext(password: password, token: token)
Client.confirmResetPassword(context: context, success: {
// success
}, failure: { (error) in
// failure
})
```
```Objective-C
NSString *password = @"PASSWORD"
NSString *token = @"TOKEN"
SNRClientPasswordResetConfirmationContext *context = [[SNRClientPasswordResetConfirmationContext alloc] initWithPassword:password andToken:token];
[SNRClient confirmResetPassword:context success:^() {
// success
} failure:^(NSError * _Nonnull error) {
// failure
}];
```
## Request email change for customer account
---
This method requests a customer's email change.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided token or the password is invalid.
The API key must have the `SAUTH_CHANGE_EMAIL_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func requestEmailChange(email: String, password: String, externalToken: AnyObject?, authID: String?, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)requestEmailChange:(nonnull NSString *)email password:(NSString *)password externalToken:(id)externalToken authID:(NSString *)authID success:(nonnull void (^)(void))success failure:(nonnull void (^)(SNRApiError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer's new email |
| **password** | String | yes | - | Customer's password |
| **externalToken** | AnyObject | no | - | Customer's token (if OAuth, Facebook, and so on) |
| **authID** | String | no | - | Optional identifier of authorization |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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.
## Confirm email change for customer account
---
This method confirms an email change.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided token is invalid.
The API key must have the `SAUTH_CHANGE_EMAIL_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func confirmEmailChange(token: String, newsletterAgreement: Bool, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)confirmEmailChange:(nonnull NSString *)token newsletterAgreement:(BOOL)newsletterAgreement success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | String | yes | - | Customer's token provided in an email |
| **newsletterAgreement** | Bool | yes | - | Agreement for sending newsletters to the provided email |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let token: String = "TOKEN"
Client.confirmEmailChange(token: token, success: {
// success
}) { (error) in
// failure
}
```
```Objective-C
NSString *token = @"TOKEN";
[SNRClient confirmEmailChange:token newsletterAgreement:YES success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
```
## Request phone update on customer account
---
This method requests a customer's phone update. A confirmation code is sent to the phone number.
This method is a global operation and doesn't require customer authentication.
The API key must have the `API_PERSONAL_PHONE_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func requestPhoneUpdate(phone: String, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)requestPhoneUpdate:(nonnull NSString *)phone success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **phone** | String | yes | - | Customer's new phone number |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let phone: String = "123-456-789"
Client.requestPhoneUpdate(phone: phone, success: {
// success
}, failure: { (error) in
// failure
})
```
```Objective-C
NSString *phone = @"123-456-789";
[SNRClient requestPhoneUpdate:phone success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
```
## Confirm phone update on customer account
---
This method confirms a phone number update. This action requires the new phone number and confirmation code as parameters.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided UUID does not exist or the password is invalid.
The API key must have the `API_PERSONAL_PHONE_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func confirmPhoneUpdate(phone: String, confirmationCode: String, smsAgreement: Bool, success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)confirmPhoneUpdate:(nonnull NSString *)phone confirmationCode:(nonnull NSString *)confirmationCode smsAgreement:(BOOL)smsAgreement success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **phone** | String | yes | - | New phone number |
| **confirmationCode** | String | yes | - | A confirmation code received by a text message |
| **smsAgreement** | Bool | yes | - | Agreement for sending SMS to the provided number |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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:**
Swift Objective-C
```Swift
let phone: String = "123-456-789"
let confirmationCode: String = "CONFIRMATION_CODE"
Client.confirmPhoneUpdate(phone: phone, confirmationCode: confirmationCode, smsAgreement: true, success: {
// success
}) { (error) in
// failure
}
```
```Objective-C
NSString *phone = @"123-456-789";
NSString *confirmationCode = @"CONFIRMATION_CODE";
[SNRClient confirmPhoneUpdate:phone confirmationCode:confirmationCode smsAgreement:YES success:^() {
// success
} failure:^(SNRApiError *error) {
// failure
}];
```
## Delete customer account by Identity Provider
---
This method deletes a customer's account.
This method requires customer authentication.
HTTP 403 status code is returned if the provided password or token is invalid.
The API key must have the `SAUTH_CLIENT_DELETE`, `SAUTH_OAUTH_CLIENT_DELETE`, `SAUTH_FACEBOOK_CLIENT_DELETE`, `SAUTH_APPLE_CLIENT_DELETE` permissions from the **Client** group.
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func deleteAccount(clientAuthFactor: String, clientIdentityProvider: ClientIdentityProvider, authID: String, success: (() -> Void), failure: ((ApiError) -> Void))
```
```Objective-C
+ (void)deleteAccount:(nonnull id)clientAuthFactor
clientIdentityProvider:(SNRClientIdentityProvider)clientIdentityProvider authID:(nullable NSString *)authID success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **clientAuthFactor** | String | yes | - | Customer's token from the identity provider |
| **clientIdentityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/ios/client#clientidentityprovider) | yes | - | Customer's identity provider |
| **authID** | String | no | - | Optional identifier of authorization |
| **success** | (() -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> 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.
## Removed methods
### Request email change for customer account by Facebook {#request-email-change-for-customer-account-by-facebook}
---
This method requests a customer's email change by Facebook.
This method is a global operation and doesn't require customer authentication.
The API key must have the `SAUTH_CHANGE_EMAIL_CLIENT_UPDATE` permission from the **Client** group.
**Replaced By:**
[Request email change for customer account](/developers/mobile-sdk/method-reference/ios/client-account#request-email-change-for-customer-account)
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func requestEmailChangeByFacebook(email: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)requestEmailChangeByFacebook:(nonnull NSString *)email success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer's new email |
| **success** | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
let email: String = "EMAIL"
Client.requestEmailChange(email: email, success: { success in
// success
}) { (error) in
// failure
}
```
```Objective-C
NSString *email = @"EMAIL";
[SNRClient requestEmailChangeByFacebook:email success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
```
### Delete customer account {#delete-customer-account}
---
This method deletes a customer's account.
This method requires customer authentication.
| | **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.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | n/a | n/a |
Returns the HTTP 403 status code is returned if the provided password is invalid.
The API key must have the `SAUTH_CLIENT_DELETE` permission from the **Client** group.
**Replaced By:**
[Delete customer account by Identity Provider](/developers/mobile-sdk/method-reference/ios/client-account#delete-customer-account-by-identity-provider)
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func deleteAccount(password: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void))
```
```Objective-C
+ (void)deleteAccount:(nonnull NSString *)password success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **password** | String | yes | - | Customer's password |
| **success** | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
let password: String = "PASSWORD"
Client.deleteAccount(password: password, success: { (success) in
// success
}) { (error) in
// failure
}
```
```Objective-C
NSString *password = "PASSWORD";
[SNRClient deleteAccount:password success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
```
### Delete customer account by OAuth {#delete-customer-account-by-oauth}
---
This method deletes a customer's account by OAuth.
This method requires customer authentication.
| | **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.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | n/a | n/a |
The API key must have the `SAUTH_CLIENT_DELETE` and `SAUTH_OAUTH_CLIENT_DELETE` permissions from the **Client** group.
**Replaced By:**
[Delete customer account by Identity Provider](/developers/mobile-sdk/method-reference/ios/client-account#delete-customer-account-by-identity-provider)
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func deleteAccountByOAuth(accessToken: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)deleteAccountByOAuth:(nonnull NSString *)accessToken success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **accessToken** | String | yes | - | OAuth Access Token |
| **success** | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
### Delete customer account by Facebook {#delete-customer-account-by-facebook}
---
This method deletes a customer's account by Facebook.
This method requires customer authentication.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 3.3.8 | 3.3.0 | 0.9.12 | n/a |
| Deprecated in: | 3.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | n/a | n/a |
The API key must have the `SAUTH_CLIENT_DELETE` and `SAUTH_FACEBOOK_CLIENT_DELETE` permissions from the **Client** group.
**Replaced By:**
[Delete customer account by Identity Provider](/developers/mobile-sdk/method-reference/ios/client-account#delete-customer-account-by-identity-provider)
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func deleteAccountByFacebook(facebookToken: String, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)deleteAccountByFacebook:(nonnull NSString *)facebookToken success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **facebookToken** | String | yes | - | Token from an active Facebook session |
| **success** | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
guard let facebookToken = FBSDKAccessToken.current()?.tokenString else {
return
}
Client.deleteAccountByFacebookToken(facebookToken: facebookToken, success: { (success) in
// success
}, failure: { (error) in
// failure
})
```
```Objective-C
NSString *facebookToken = [FBSDKAccessToken currentAccessToken].tokenString;
[SNRClient deleteAccountByFacebook:facebookToken success:^(BOOL isSuccess) {
// success
} failure:^(SNRApiError *error) {
// failure
}];
```
### Delete customer account by Apple Sign In {#delete-customer-account-by-apple-sign-in}
---
This method deletes a customer's account information by Sign In With Apple.
This method requires customer authentication.
| | **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.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | n/a | n/a | n/a |
The API key must have the `SAUTH_CLIENT_DELETE` and `SAUTH_APPLE_CLIENT_DELETE` permissions from the **Client** group.
**Replaced By:**
[Delete customer account by Identity Provider](/developers/mobile-sdk/method-reference/ios/client-account#delete-customer-account-by-identity-provider)
**Declared In:**
Headers/SNRClient.h
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func deleteAccountByAppleSignIn(identityToken: Data, success: ((Bool) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)deleteAccountByAppleSignIn:(nonnull NSData *)identityToken success:(nonnull void (^)(BOOL isSuccess))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **identityToken** | Data | yes | - | Token from Sign In With Apple session |
| **success** | ((Bool) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
# OAuth
This article contains instruction on authenticating a customer in a mobile application with your backend by an OAuth-like method. Prepare your backend for this solution and then you perform part of the configuration on a user interface in the Synerise platform (`app.synerise.com`).
This is the recommended authentication method.
OAuth process diagram
Additionally, in the Synerise platform (`app.synerise.com`) you can define the following settings:
- [Assignment of loyalty card](/docs/settings/tool/iam-for-apps/general#loyalty-card-assignment)
- [JWT longevity](/docs/settings/tool/iam-for-apps/general#jwt-lifetime)
- [Custom ID overwriting](/docs/settings/tool/iam-for-apps/general#custom-id-overwriting)
- [External ID overwriting](/docs/settings/tool/iam-for-apps/general#external-id-overwriting)
## Logic explained
---
The authentication process works in the following way:
1. A customer sign-in to the application generates an authentication request to your backend.
2. Your backend provides the application with an access token.
3. The access token is passed to Synerise by using the following methods:
4. Synerise passes that access token:
- if the access token is JWT, to external JWK service for validation
- if the access token isn't JWT, back to your backend in order to check if it's valid.
5. In response:
- If authentication is successful, Synerise receives customer information such as the email, first name, last name, or other details* (the data can be mapped to fields in our system). For more information, check our [guide](/docs/settings/tool/iam-for-apps/oauth).
- If the access token is not valid, the response type is different than HTTP 2xx.
6. If the authentication was successful, Synerise provides the application with our JWT access token for the customer (if this the first time this customer is authenticated, they are also registered with the provided information).
*You can declare on user interface in Synerise if you want to update the customer's data with each login or only during the first log-in.
## Authentication methods
---
Conditional authentication lets you verify if a customer exists. This way, you can display screens with agreements or processes necessary for the first log-in.
| OS | Method |
|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Android | - [Client.authenticate(token, provider, agreements, attributes, authId)](/developers/mobile-sdk/method-reference/android/client-authentication#authenticate-customer-by-identityprovider) - [Client.authenticateConditionally(token, provider, agreements, attributes, authId)](/developers/mobile-sdk/method-reference/android/client-authentication#authenticate-customer-conditionally-by-identityprovider) |
| iOS | - [Client.authenticate(token:clientIdentityProvider:authID:context:success:failure:)](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-conditionally-by-identityprovider) - [Client.authenticateConditionally(token:clientIdentityProvider:authID:context:success:failure:)](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-conditionally-by-identityprovider) |
| React Native | - [Synerise.Client.authenticate(token, clientIdentityProvider, authID, context, onSuccess, onError)](/developers/mobile-sdk/method-reference/react-native/client-authentication#authenticate-customer-by-identityprovider) - [Synerise.Client.authenticateConditionally(token, clientIdentityProvider, authID context, onSuccess, onError)](/developers/mobile-sdk/method-reference/react-native/client-authentication#authenticate-customer-conditionally-by-identityprovider) |
| Flutter | - [Synerise.client.authenticate(clientAuthContext, clientIdentityProvider, token)](/developers/mobile-sdk/method-reference/flutter/client-authentication#authenticate-customer-by-identityprovider)) |
**authId/authID** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
## Other methods
---
### Check if a customer is signed in
This method checks if a customer is signed in through oAuth, Facebook, Sign in with Apple, or RaaS
This method returns `false` if a customer is authenticated through [Simple Profile Authentication](/developers/mobile-sdk/user-identification-and-authorization/simple-authentication).
| OS | Method |
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| Android | [Client.isSignedIn()](/developers/mobile-sdk/method-reference/android/client-authentication#check-if-a-customer-is-signed-in-via-raas-oauth-facebook-apple) |
| iOS | [Client.isSignedIn()](/developers/mobile-sdk/method-reference/ios/client-authentication#check-if-a-customer-is-signed-in-via-raas-oauth-facebook-apple) |
| React Native | [Synerise.Client.isSignedIn()](/developers/mobile-sdk/method-reference/react-native/client-authentication#check-if-a-customer-is-signed-in-via-raas-oauth-facebook-apple) |
| Flutter | [Synerise.client.isSignedIn()](/developers/mobile-sdk/method-reference/flutter/client-authentication#check-if-a-customer-is-signed-in-via-raas-oauth-facebook-apple) |
### Customer sign out
If you want to provide the customer with a logout feature in your application, use this method. The method terminates the JWT token and ends the customer session.
| OS | Method |
|--------------|-----------------------------------------------------------------------------------------------------------------------|
| Android | [Client.signOut()](/developers/mobile-sdk/method-reference/android/client-authentication#sign-out-customer) |
| iOS | [Client.signOut()](/developers/mobile-sdk/method-reference/ios/client-authentication#sign-out-customer) |
| React Native | [Synerise.Client.signOut()](/developers/mobile-sdk/method-reference/react-native/client-authentication#sign-out-a-customer) |
| Flutter | [Synerise.client.signOut()](/developers/mobile-sdk/method-reference/flutter/client-authentication#sign-out-a-customer) |
## What's next
---
When the customer's is signed in, you can implement [profile management methods](/developers/mobile-sdk/user-identification-and-authorization/identification-and-user-management#profile-management-methods) and [session management methods](/developers/mobile-sdk/user-identification-and-authorization/session-management).
# Events
### TrackerParams
Represents custom parameters that may be added to tracked events.
**Declared In:**
Headers/SNRTrackerParams.h
**Related To:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Inherits From:**
[NSObject](https://developer.apple.com/documentation/objectivec/nsobject)
**Declaration:**
Swift Objective-C
```Swift
class TrackerParams: NSObject
```
```Objective-C
@interface SNRTrackerParams : NSObject
```
**Initializers:**
Swift Objective-C
```Swift
static func makeWithBuilder(_: ((TrackerParamsBuilder) -> ()))
```
```Objective-C
+ (instancetype)makeWithBuilder:(nonnull void (^)(SNRTrackerParamsBuilder *builder))buildBlock
```
---
---
### TrackerParamsBuilder
Object that is used to create parameters for the event classes.
**Declared In:**
Headers/SNRTrackerParamsBuilder.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Inherits From:**
[NSObject](https://developer.apple.com/documentation/objectivec/nsobject)
**Declaration:**
Swift Objective-C
```Swift
class TrackerParamsBuilder: NSObject
```
```Objective-C
@interface SNRTrackerParamsBuilder : NSObject
```
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
**Methods:**
Swift Objective-C
```Swift
func setString(_: String)
```
```Objective-C
- (void)setString:(nonnull NSString *)string forKey:(nonnull NSString *)key
```
---
Swift Objective-C
```Swift
func setInt(_: Int)
```
```Objective-C
- (void)setInt:(NSInteger)integer forKey:(nonnull NSString *)key
```
---
Swift Objective-C
```Swift
func setDouble(_: Double)
```
```Objective-C
- (void)setDouble:(double)doubleValue forKey:(nonnull NSString *)key
```
---
Swift Objective-C
```Swift
func setFloat(_: Float)
```
```Objective-C
- (void)setFloat:(float)floatValue forKey:(nonnull NSString *)key
```
---
Swift Objective-C
```Swift
func setBool(_: Bool)
```
```Objective-C
- (void)setBool:(BOOL)boolValue forKey:(nonnull NSString *)key
```
---
Swift Objective-C
```Swift
func setObject(_: AnyClass)
```
```Objective-C
- (void)setObject:(nonnull id)object forKey:(nonnull NSString *)key
```
---
---
### Event
Main event abstract class for inheriting classes.
This is an abstract class and it is not meant to be instantiated directly. You should use concrete `Event` subclasses instead.
**Declared In:**
Headers/SNREvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[NSObject](https://developer.apple.com/documentation/objectivec/nsobject)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class Event: NSObject
```
```Objective-C
@interface SNREvent : NSObject
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label
```
---
Swift Objective-C
```Swift
init(label: String, params: TrackerParams)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label andParams:(nullable SNRTrackerParams *)params
```
---
---
### CustomEvent
DO NOT send `transaction.charge` events as custom events.
Transactions must be tracked with these endpoints:
- [`/v4/transactions`](https://hub.synerise.com/api-reference/data-management#operation/CreateATransaction) (single transaction)
- [`/v4/transactions/batch`](https://hub.synerise.com/api-reference/data-management#operation/BatchAddOrUpdateTransactions) (multiple transactions)
Represents a custom event.
**Declared In:**
Headers/SNRCustomEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class CustomEvent: Event
```
```Objective-C
@interface SNRCustomEvent : SNREvent
```
**Initializers:**
Swift Objective-C
```Swift
init(type: String, label: String, action: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithType:(nonnull NSString *)type label:(nonnull NSString *)label action:(nonnull NSString *)action andParams:(nullable SNRTrackerParams *)params
```
Swift Objective-C
```Swift
init(label: String, action: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label action:(nonnull NSString *)action andParams:(nullable SNRTrackerParams *)params
```
Swift Objective-C
```Swift
init(label: String, action: String)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label action:(nonnull NSString *)action
```
---
---
### PushViewedEvent
Represents a 'client viewed push' event.
This event is used for push message interaction tracking.
**Declared In:**
Headers/SNRPushViewedEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class PushViewedEvent: Event
```
```Objective-C
@interface SNRPushViewedEvent : SNREvent
```
---
---
### PushClickedEvent
Represents a 'client clicked push' event.
This event is used for push message interaction tracking.
**Declared In:**
Headers/SNRPushClickedEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class PushClickedEvent: Event
```
```Objective-C
@interface SNRPushClickedEvent : SNREvent
```
---
---
### PushCancelledEvent
Represents a 'client viewed push' event.
This event is used for push message interaction tracking.
**Declared In:**
Headers/SNRCancelledPushEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class CancelledPushEvent: Event
```
```Objective-C
@interface SNRCancelledPushEvent : SNREvent
```
---
---
### CartEvent
Main cart action abstract class for inheriting classes.
This is an abstract class and it is not meant to be instantiated directly. You should use concrete `CartEvent` subclasses instead.
**Declared In:**
Headers/SNRCartEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class CartEvent: Event
```
```Objective-C
@interface SNRCartEvent : SNREvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String, sku String, finalPrice: UnitPrice, quantity: Int, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label sku:(nonnull NSString *)sku finalPrice:(nonnull SNRUnitPrice *)unitPrice quantity:(NSInteger)quantity andParams:(nullable SNRTrackerParams *)params
```
---
Swift Objective-C
```Swift
init(label: String, sku: String, finalPrice: UnitPrice, quantity: Int)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label sku:(nonnull NSString *)sku finalPrice:(nonnull SNRUnitPrice *)unitPrice quantity:(NSInteger)quantity
```
**Methods:**
This method sets a value for the `name` parameter.
Swift Objective-C
```Swift
func setName(_: String)
```
```Objective-C
- (void)setName:(nonnull NSString *)name
```
---
This method sets a value for the `category` parameter.
Swift Objective-C
```Swift
func setCategory(_: String)
```
```Objective-C
- (void)setCategory:(nonnull NSString *)category
```
---
This method sets values for the `categories` parameter.
Swift Objective-C
```Swift
func setCategories(_: [String])
```
```Objective-C
- (void)setCategories:(nonnull NSArray *)categories
```
---
This method sets a value for the `offline` parameter.
Swift Objective-C
```Swift
func setOffline(_: Bool)
```
```Objective-C
- (void)setOffline:(BOOL)isOffline
```
---
This method sets the value of the `regularPrice` parameter.
Swift Objective-C
```Swift
func setRegularPrice(_: UnitPrice)
```
```Objective-C
- (void)setRegularPrice:(nonnull SNRUnitPrice *)price
```
---
This method sets the value of the `discountedPrice` parameter.
Swift Objective-C
```Swift
func setDiscountedPrice(_: UnitPrice)
```
```Objective-C
- (void)setDiscountedPrice:(nonnull SNRUnitPrice *)price
```
---
This method sets the value of the `url` parameter.
Swift Objective-C
```Swift
func setURL(_: URL)
```
```Objective-C
- (void)setURL:(nonnull NSURL *)url
```
---
This method sets the value of the `producer` parameter (producer can signify a brand of the item).
Swift Objective-C
```Swift
func setProducer(_: String)
```
```Objective-C
- (void)setProducer:(nonnull NSString *)producer
```
---
---
### UnitPrice
**Declared In:**
Headers/SNRUnitPrice.h
**Inherits From:**
[NSObject](https://developer.apple.com/documentation/objectivec/nsobject)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class UnitPrice: NSObject
```
```Objective-C
@interface SNRUnitPrice : NSObject
```
**Initializers:**
Swift Objective-C
```Swift
init(amount: Float)
```
```Objective-C
- (instancetype)initWithAmount:(float)amount
```
---
Swift Objective-C
```Swift
init(amount: Float, locale: NSLocale)
```
```Objective-C
- (instancetype)initWithAmount:(float)amount locale:(nonnull NSLocale *)locale
```
---
---
### ProductAddedToCartEvent
Represents a 'client added product to cart' event.
**Declared In:**
Headers/SNRProductAddedToCartEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
[CartEvent](/developers/mobile-sdk/class-reference/ios/events#cartevent)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class ProductAddedToCartEvent: CartEvent
```
```Objective-C
@interface SNRProductAddedToCartEvent : SNRCartEvent
```
---
---
### ProductRemovedFromCartEvent
Represents a 'client removed product from cart' event.
**Declared In:**
Headers/SNRProductRemovedFromCartEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
[CartEvent](/developers/mobile-sdk/class-reference/ios/events#cartevent)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class ProductRemovedFromCartEvent: CartEvent
```
```Objective-C
@interface SNRProductRemovedFromCartEvent : SNRCartEvent
```
---
---
### ProductViewedEvent
Represents a 'client viewed product' event.
**Declared In:**
Headers/SNRProductViewedEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class ProductViewedEvent: Event
```
```Objective-C
@interface SNRProductViewedEvent : SNREvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String, productName: String, productId: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label productName:(nonnull NSString *)productName productId:(nonnull NSString *)productId andParams:(nullable SNRTrackerParams *)params
```
**Methods:**
Sets if a product is recommended or not.
Swift Objective-C
```Swift
func setIsRecommended(_: Bool)
```
```Objective-C
- (void)setIsRecommended:(BOOL)isRecommended
```
---
This method sets a value for the `category` parameter.
Swift Objective-C
```Swift
func setCategory(_: String)
```
```Objective-C
- (void)setCategory:(NSString *)category
```
---
This method sets the value of the `url` parameter.
Swift Objective-C
```Swift
func setURL(_: URL)
```
```Objective-C
- (void)setURL:(NSURL *)url
```
---
---
### ProductAddedToFavoritesEvent
Represents a 'client added product to favorites' event.
**Declared In:**
Headers/SNRProductAddedToFavoritesEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class ProductAddedToFavoritesEvent: Event
```
```Objective-C
@interface SNRProductAddedToFavoritesEvent : SNREvent
```
---
---
### LoggedInEvent
Represents a 'client logged in' event.
**Declared In:**
Headers/SNRLoggedInEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events/#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events/#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events/#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class LoggedInEvent: Event
```
```Objective-C
@interface SNRLoggedInEvent : SNREvent
```
---
---
### LoggedOutEvent
Represents a 'client logged out' event.
**Declared In:**
Headers/SNRLoggedOutEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class LoggedOutEvent: Event
```
```Objective-C
@interface SNRLoggedOutEvent : SNREvent
```
---
---
### RegisteredEvent
Represents a 'client registered' event.
**Declared In:**
Headers/SNRCancelledPushEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class RegisteredEvent: Event
```
```Objective-C
@interface SNRRegisteredEvent : SNREvent
```
---
---
### RecommendationEvent
Main recommendation abstract class for inheriting classes.
This is an abstract class and it is not meant to be instantiated directly. You should use concrete `RecommendationEvent` subclasses instead.
**Declared In:**
Headers/SNRRecommendationEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class RecommendationEvent: Event
```
```Objective-C
@interface SNRRecommendationEvent : SNREvent
```
---
---
### RecommendationViewEvent
Represents a 'client viewed a recommendation' event.
**Declared In:**
Headers/SNRRecommendationViewEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
[RecommendationEvent](/developers/mobile-sdk/class-reference/ios/events#recommendationevent)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class RecommendationViewEvent: RecommendationEvent
```
```Objective-C
@interface SNRRecommendationViewEvent : SNRRecommendationEvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String, campaignID: String, campaignHash: String, correlationId: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(NSString *)label campaignID:(NSString *)campaignID campaignHash:(NSString *)campaignHash correlationId:(NSString *)correlationId andParams:(nullable SNRTrackerParams *)params
```
---
Swift Objective-C
```Swift
init(label: String, items: [String], campaignID: String, campaignHash: String, correlationId: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(NSString *)label items:(nullable NSArray *)items campaignID:(NSString *)campaignID campaignHash:(NSString *)campaignHash correlationId:(NSString *)correlationId andParams:(nullable SNRTrackerParams *)params
```
**Methods:**
This method sets a value for the `items` parameter.
Swift Objective-C
```Swift
func setItems(_ items: [String])
```
```Objective-C
- (void)setItems:(NSArray *)items
```
---
---
### RecommendationSeenEvent
Represents a 'client saw a recommendation' event.
**Declared In:**
Headers/SNRRecommendationSeenEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
[RecommendationEvent](/developers/mobile-sdk/class-reference/ios/events#recommendationevent)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class RecommendationSeenEvent: RecommendationEvent
```
```Objective-C
@interface SNRRecommendationSeenEvent : SNRRecommendationEvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String, productName: String, productId: String, campaignID: String, campaignHash: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label productName:(nonnull NSString *)productName productId:(nonnull NSString *)productId campaignID:(nonnull NSString *)campaignID campaignHash:(nonnull NSString *)campaignHash andParams:(nullable SNRTrackerParams *)params
```
**Methods:**
Set a product's category.
Swift Objective-C
```Swift
func setCategory(_: String)
```
```Objective-C
- (void)setCategory:(nonnull NSString *)category
```
---
Set a product's URL.
Swift Objective-C
```Swift
func setURL(_: URL)
```
```Objective-C
- (void)setURL:(nonnull NSURL *)url
```
---
---
### RecommendationClickEvent
Represents a 'client clicked a recommendation' event.
**Declared In:**
Headers/SNRRecommendationSeenEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
[RecommendationEvent](/developers/mobile-sdk/class-reference/ios/events#recommendationevent)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class RecommendationClickEvent: RecommendationEvent
```
```Objective-C
@interface SNRRecommendationClickEvent : SNRRecommendationEvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String, productName: String, productId: String, campaignID: String, campaignHash: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label productName:(nonnull NSString *)productName productId:(nonnull NSString *)productId campaignID:(nonnull NSString *)campaignID campaignHash:(nonnull NSString *)campaignHash andParams:(nullable SNRTrackerParams *)params
```
**Methods:**
Set a product's category.
Swift Objective-C
```Swift
func setCategory(_: String)
```
```Objective-C
- (void)setCategory:(nonnull NSString *)category
```
---
Set a product's URL.
Swift Objective-C
```Swift
func setURL(_: URL)
```
```Objective-C
- (void)setURL:(nonnull NSURL *)url
```
---
---
### VisitedScreenEvent
Represents a 'client visited screen' event.
This can be used for mobile screen usage tracking.
**Declared In:**
Headers/SNRVisitedScreenEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class VisitedScreenEvent: Event
```
```Objective-C
@interface SNRVisitedScreenEvent : SNREvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label
```
---
Swift Objective-C
```Swift
init(label: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label andParams:(nullable SNRTrackerParams *)params
```
---
---
### HitTimerEvent
Represents a 'client hit timer' event.
This could be used for profiling or activity time monitoring - you can send a `HitTimerEvent` when a client starts doing something and send it once again when they finish, but this time with the different time signature. Then you can use our analytics engine to measure, for example, average activity time.
**Declared In:**
Headers/SNRHitTimerEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class HitTimerEvent: Event
```
```Objective-C
@interface SNRHitTimerEvent : SNREvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label
```
---
Swift Objective-C
```Swift
init(label: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label andParams:(nullable SNRTrackerParams *)params
```
---
---
### SearchedEvent
Represents a 'client searched' event.
**Declared In:**
Headers/SNRSearchedEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class SearchedEvent: Event
```
```Objective-C
@interface SNRSearchedEvent : SNREvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label
```
---
Swift Objective-C
```Swift
init(label: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label andParams:(nullable SNRTrackerParams *)params
```
---
---
### SharedEvent
Represents a 'client shared' event.
**Declared In:**
Headers/SNRSharedEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class SharedEvent: Event
```
```Objective-C
@interface SNRSharedEvent : SNREvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label
```
---
Swift Objective-C
```Swift
init(label: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label andParams:(nullable SNRTrackerParams *)params
```
---
---
### AppearedInLocationEvent
Represents a 'client appeared in location' event.
**Declared In:**
Headers/SNRAppearedInLocationEvent.h
**Related To:**
[CCLocation](https://developer.apple.com/documentation/corelocation/cllocation)
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class AppearedInLocationEvent: Event
```
```Objective-C
@interface SNRAppearedInLocationEvent : SNREvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String, location: CCLocation)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label andLocation:(nonnull CLLocation *)location
```
---
Swift Objective-C
```Swift
init(label: String, location: CCLocation, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label andLocation:(nonnull CLLocation *)location andParams:(nullable SNRTrackerParams *)params
```
---
---
### CrashEvent
Represents an 'application crashed' event.
**Declared In:**
Headers/SNRCrashEvent.h
**Related To:**
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
**Conforms To:**
[NSCopying](https://developer.apple.com/documentation/foundation/nscopying)
**Declaration:**
Swift Objective-C
```Swift
class CrashEvent: Event
```
```Objective-C
@interface SNRCrashEvent : SNREvent
```
**Initializers:**
Swift Objective-C
```Swift
init(label: String)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label
```
Swift Objective-C
```Swift
init(label: String, params: TrackerParams?)
```
```Objective-C
- (instancetype)initWithLabel:(nonnull NSString *)label andParams:(nullable SNRTrackerParams *)params
```
**Methods:**
This method sets the exception's `name` parameter.
Swift Objective-C
```Swift
func setExceptionName(_: String)
```
```Objective-C
- (void)setExceptionName:(nonnull NSString *)exceptionName
```
---
This method sets the exception's `reason` parameter.
Swift Objective-C
```Swift
func setExceptionReason(_: String)
```
```Objective-C
- (void)setExceptionReason:(nonnull NSString *)exceptionReason
```
---
This method sets the exception's `stacktrace` parameter.
Swift Objective-C
```Swift
func setExceptionStacktrace(_: String)
```
```Objective-C
- (void)setExceptionStacktrace:(nonnull NSString *)exceptionStacktrace
```
# Customer account management
---
## Get customer account information
---
This method gets a customer’s account information.
This method requires customer authentication.
The API key must have the `API_PERSONAL_INFORMATION_CLIENT_READ` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Related To:**
[ClientAccountInformation](/developers/mobile-sdk/class-reference/flutter/client#clientaccountinformation)
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> getAccount({required void Function(ClientAccountInformation) onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **onSuccess** | Function([ClientAccountInformation](/developers/mobile-sdk/class-reference/flutter/client#clientaccountinformation) clientAccountInformation) | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.getAccount(onSuccess: (ClientAccountInformation result) {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<ClientAccountInformation> getAccount() async
**Return Value:**
[ClientAccountInformation](/developers/mobile-sdk/class-reference/flutter/client#clientaccountinformation)
**Example:**
final ClientAccountInformation clientAccountInformation = await Synerise.client.getAccount().catchError((error)
## Update customer account basic information
---
This method updates a customer’s account’s basic information (without identification data: uuid, customId, email).
This method requires the context object with the customer’s account information. Omitted fields are not modified.
This method does not require customer authentication and can be used by anonymous profiles.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 4.22.0 | 5.21.0 | 0.24.0 | 1.4.0 |
The API key must have the `API_BASIC_INFORMATION_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Related To:**
[ClientAccountUpdateBasicInformationContext](/developers/mobile-sdk/class-reference/flutter/client#clientaccountupdatebasicinformationcontext)
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
**Declaration:**
Future<void> updateAccountBasicInformation(ClientAccountUpdateBasicInformationContext context,
{required void Function() onSuccess,
required void Function(SyneriseError error) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientAccountUpdateBasicInformationContext](/developers/mobile-sdk/class-reference/flutter/client#clientaccountupdatebasicinformationcontext) | yes | - | Object with customer’s first name, phone, and other optional data |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
ClientAccountUpdateBasicInformationContext context = ClientAccountUpdateBasicInformationContext(
email: email,
password: password,
firstName: firstName,
lastName: lastName,
sex: ClientSex.getClientSexFromString(sex));
await Synerise.client.updateAccountBasicInformation(clientAccountUpdateContext, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
## Update customer account information
---
This method updates a customer’s account information.
This method requires the context object with the customer’s account information. Omitted fields are not modified.
This method requires customer authentication.
The API key must have the `API_PERSONAL_INFORMATION_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Related To:**
[ClientAccountUpdateContext](/developers/mobile-sdk/class-reference/flutter/client#clientaccountupdatecontext)
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> updateAccount(ClientAccountUpdateContext context,
{required void Function() onSuccess,
required void Function(SyneriseError error) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientAccountUpdateContext](/developers/mobile-sdk/class-reference/flutter/client#clientaccountupdatecontext) | yes | - | Object with customer's email, password, and other optional data |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
ClientAccountUpdateContext clientAccountUpdateContext = ClientAccountUpdateContext(
email: email,
password: password,
firstName: firstName,
lastName: lastName,
sex: ClientSex.getClientSexFromString(sex));
await Synerise.client.updateAccount(clientAccountUpdateContext, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> updateAccount(ClientAccountUpdateContext context) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **context** | [ClientAccountUpdateContext](/developers/mobile-sdk/class-reference/flutter/client#clientaccountupdatecontext) | yes | - | Object with customer's email, password, and other optional data |
**Return Value:**
No value is returned.
**Example:**
ClientAccountUpdateContext clientAccountUpdateContext = ClientAccountUpdateContext(
email: email,
password: password,
firstName: firstName,
lastName: lastName,
sex: ClientSex.getClientSexFromString(sex));
await Synerise.client.updateAccount(clientAccountUpdateContext).catchError((error) {
//onError handling
});
## Change customer's account password
---
This method changes a customer’s password.
This method requires customer authentication.
Returns the HTTP 403 status code if the provided old password is invalid.
The API key must have the `SAUTH_CHANGE_PASSWORD_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> changePassword(String oldPassword, String newPassword,
{required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **oldPassword** | String | yes | - | Customer’s old password |
| **newPassword** | String | yes | - | Customer’s new password |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.changePassword(oldPassword, newPassword, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> changePassword(String oldPassword, String password) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **newPassword** | String | yes | - | Customer’s new password |
| **oldPassword** | String | yes | - | Customer’s old password |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.changePassword(oldPassword, password).catchError((error)
## Request password reset for customer account
---
This method requests a customer’s password reset with email. The customer will receive a token to the provided email address. That token is then used for the confirmation of password reset.
This method requires the customer’s email.
This method is a global operation and doesn't require customer authentication.
The API key must have the `SAUTH_PASSWORD_RESET_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> requestPasswordReset(String email, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer’s email |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.requestPasswordReset(email, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> requestPasswordReset(String email) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer’s email |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.requestPasswordReset(email).catchError((error)
## Confirm password reset for customer account
---
This method confirm a customer’s password reset with the new password and token provided by password reset request.
This method requires the customer’s new password and the confirmation token received by e-mail.
This method is a global operation and doesn't require customer authentication.
The API key must have the `SAUTH_PASSWORD_RESET_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> confirmPasswordReset(String password, String token, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **password** | String | yes | - | New password for the customer |
| **token** | String | yes | - | Customer's token provided in an email |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.confirmPasswordReset(password, token, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> confirmPasswordReset(String password, String token) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer’s email |
| **token** | String | yes | - | Customer's token provided in an email |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.confirmPasswordReset(email, token).catchError((error)
## Delete customer account
---
This method deletes a customer's account.
This method requires customer authentication.
| | **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.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | n/a | n/a |
Returns the HTTP 403 status code is returned if the provided password is invalid.
The API key must have the `SAUTH_CLIENT_DELETE` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Related To:**
[ClientIdentityProvider](/developers/mobile-sdk/class-reference/flutter/client#clientidentityprovider)
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> deleteAccount(String clientAuthFactor, IdentityProvider identityProvider, {String? authId, required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **clientAuthFactor** | String | yes | - | Customer’s password or token from the identity provider |
| **identityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/flutter/client#clientidentityprovider) | yes | - | Customer's identity provider |
| **authID** | String | no | null | Optional identifier of authorization |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.deleteAccount(clientAuthFactor, identityProvider, authId, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> deleteAccount(String clientAuthFactor, IdentityProvider identityProvider, String? authId) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **clientAuthFactor** | String | yes | - | Customer’s password or token from the identity provider |
| **identityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/flutter/client#clientidentityprovider) | yes | - | Customer's identity provider |
| **authID** | String | yes | null | Optional identifier of authorization |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.deleteAccount(clientAuthFactor, identityProvider, authId).catchError((error)
## Request email change for customer account
---
This method requests a customer's email change.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided token or the password is invalid.
The API key must have the `SAUTH_CHANGE_EMAIL_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> requestEmailChange(String email, String password, {String? externalToken, String? authID, required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **email** | String | yes | Customer's new email |
| **password** | String | yes | Customer's password |
| **externalToken** | String | no | Customer's token (if OAuth, Facebook, and so on) |
| **authID** | String | no | Optional identifier of authorization |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.requestEmailChange(email, password, externalToken: externalToken, authID: authID, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declared In:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
**Declaration:**
Future<void> requestEmailChange(String email, String password, [String? externalToken, String? authID]) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **email** | String | yes | Customer's new email |
| **password** | String | yes | Customer's password |
| **externalToken** | String | no | Customer's token (if OAuth, Facebook, and so on) |
| **authID** | String | no | Optional identifier of authorization |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.requestEmailChange(email, password).catchError((error) {
## Confirm email change for customer account
---
This method confirms an email change.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided token is invalid.
The API key must have the `SAUTH_CHANGE_EMAIL_CLIENT_UPDATE` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> confirmEmailChange(String token, bool newsletterAgreement,
{required void Function() onSuccess,
required void Function(SyneriseError error) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **token** | String | yes | Customer's token provided in an email |
| **newsletterAgreement** | bool | yes | Agreement for sending newsletters to the provided email |
| **onSuccess** | Function() | yes | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.confirmAccountActivationByPin(email, pinCode, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> confirmEmailChange(String token, bool newsletterAgreement) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **token** | String | yes | Customer's token provided in an email |
| **newsletterAgreement** | bool | yes | Agreement for sending newsletters to the provided email |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.confirmEmailChange(token, true).catchError((error) {
## Request phone update on customer account
---
This method requests a customer's phone update. A confirmation code is sent to the phone number.
This method is a global operation and doesn't require customer authentication.
The API key must have the `API_PERSONAL_PHONE_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> requestPhoneUpdate(String phone, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **phone** | String | yes | Customer's new phone number |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.requestPhoneUpdate(phone, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> requestPhoneUpdate(String phone) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **phone** | String | yes | Customer's new phone number |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.requestPhoneUpdate(phone).catchError((error) {
## Confirm phone update on customer account
---
This method confirms a phone number update. This action requires the new phone number and confirmation code as parameters.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided UUID does not exist or the password is invalid.
The API key must have the `API_PERSONAL_PHONE_CLIENT_CREATE` permission from the **Client** group.
**Declared In:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> confirmPhoneUpdate(String phone, String confirmationCode, bool smsAgreement, {required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **phone** | String | yes | New phone number |
| **confirmationCode** | String | yes | A confirmation code received by a text message |
| **smsAgreement** | bool | yes | Agreement for sending SMS to the provided number |
| **onSuccess** | Function() | yes | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.confirmPhoneUpdate(phone, confirmationCode, smsAgreement, onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> confirmPhoneUpdate(String phone, String confirmationCode, bool smsAgreement) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **phone** | String | yes | New phone number |
| **confirmationCode** | String | yes | A confirmation code received by a text message |
| **smsAgreement** | bool | yes | Agreement for sending SMS to the provided number |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.confirmPhoneUpdate(phone, confirmationCode, true).catchError((error) {
# Events
### Event
Class model for events.
**Declared In:**
`com.synerise.sdk.event.Event`
**Declaration:**
Java Kotlin
```Java
public abstract class Event implements Serializable
```
```Kotlin
abstract class Event : Serializable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **eventTime** | Date | no | - | Event time |
| **type** | String | no | - | Event type |
| **action** | String | no | - | Event action |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **clientParams** | HashMap | no | - | Profile parameters |
| **params** | HashMap | no | - | Event params |
All properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method retrieves the value of the `label` parameter.
public String getLabel()
---
This method retrieves the value of the `action` parameter.
public String getAction()
---
This method retrieves the values of the `clientParams` object.
public HashMap<String, Object> getClientParams()
---
This method retrieves the value of the `eventTime` parameter.
public Date getEventTime()
---
This method retrieves the value of the `type` parameter.
public String getType()
---
This method retrieves the values of the `eventParams` object.
public HashMap<String, Object> getParams()
---
---
---
### CustomEvent
DO NOT send `transaction.charge` events as custom events.
Transactions must be tracked with these endpoints:
- [`/v4/transactions`](https://hub.synerise.com/api-reference/data-management#operation/CreateATransaction) (single transaction)
- [`/v4/transactions/batch`](https://hub.synerise.com/api-reference/data-management#operation/BatchAddOrUpdateTransactions) (multiple transactions)
Class model for _custom_ event.
**Declared In:**
`com.synerise.sdk.event.model.CustomEvent`
**Declaration:**
Java Kotlin
```Java
public class CustomEvent extends Event
```
```Kotlin
class CustomEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **action** | String | no | - | Event action |
| **params** | TrackerParams | yes | - | Event tracker parameters |
**Initializers:**
The following constructors are available:
public CustomEvent(@NonNull String action, @NonNull String label)
public CustomEvent(@NonNull String action, @NonNull String label, @Nullable TrackerParams params)
public CustomEvent(@NonNull String type, @NonNull String action, @NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### AppStartedEvent
Class model for the application started event.
**Declared In:**
`com.synerise.sdk.event.model.interaction.AppStartedEvent`
**Declaration:**
Java Kotlin
```Java
public class AppStartedEvent extends Event
```
```Kotlin
class AppStartedEvent : Event
```
This event will be sent every time an application is started.
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hub. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker parameters |
#### Parameters tracked
| Parameter | Description |
| --- | --- |
| **currentSDKVersion** | Current SDK version |
| **lastSDKVersion** | Last SDK version |
| **sdkVersionCode** | Current SDK version code |
| **applicationName** | Application name |
| **version** | Application version |
| **appVersionCode** | Application version code |
| **deviceId** | Device ID. Can be null |
| **deviceModel** | Device model |
| **deviceManufacturer** | Device manufacturer |
| **deviceResolution** | Device resolution |
| **deviceType** | Device type |
| **os** | OS type |
| **osVersion** | OS version |
| **osLanguage** | System language |
| **systemPushConsent** | System push agreement |
| **networkType** | Network type |
| **origin** | Origin of SDK |
| **networkCountry** | Country of network |
| **cellType** | Cell type |
| **cellCarrier** | Cell carrier |
| **cellCountry** | Cell country |
| **cellRoaming** | Cell roaming |
**Initializers:**
The following constructors are available:
public AppStartedEvent(@NonNull String label)
public AppStartedEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### AutoTrackingEvent
Class model for _autotracking_ events.
**Declared In:**
`com.synerise.sdk.event.model.interaction.AutoTrackingEvent`
**Declaration:**
Java Kotlin
```Java
public class AutoTrackingEvent extends Event
```
```Kotlin
class AutoTrackingEvent : Event
```
This event is sent only by the Synerise SDK. Sending this event in your application on your own is **not recommended**.
**Properties:**
There are no public properties.
The `screen.interaction` and `screen.view` events are sent by the [auto-tracking module](/developers/mobile-sdk/event-tracking#events-tracked-automatically).
**Initializers:**
There are no public constructors.
**Methods:**
There are no methods.
---
---
### ViewedPushEvent
Class model for the `push.view` event.
**Declared In:**
`com.synerise.sdk.event.model.push.ViewedPushEvent`
**Declaration:**
Java Kotlin
```Java
public class ViewedPushEvent extends Event
```
```Kotlin
class ViewedPushEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker parameters |
**Initializers:**
The following constructors are available:
public ViewedPushEvent(@NonNull String label)
public ViewedPushEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### ClickedPushEvent
Class model for the `push.click` event.
**Declared In:**
`com.synerise.sdk.event.model.push.ClickedPushEvent`
**Declaration:**
Java Kotlin
```Java
public class ClickedPushEvent extends Event
```
```Kotlin
class ClickedPushEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hub. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker parameters |
**Initializers:**
The following constructors are available:
public ClickedPushEvent(@NonNull String label)
public ClickedPushEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### CancelledPushEvent
Class model for the cancel push event generated.
**Declared In:**
`com.synerise.sdk.event.model.push.CancelledPushEvent`
**Declaration:**
Java Kotlin
```Java
public class CancelledPushEvent extends Event
```
```Kotlin
class CancelledPushEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hub. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker parameters |
**Initializers:**
The following constructors are available:
public CancelledPushEvent(@NonNull String label)
public CancelledPushEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### CartEvent
Class model for the events related to a cart.
**Declared In:**
`com.synerise.sdk.event.model.products.cart.CartEvent`
**Declaration:**
Java Kotlin
```Java
public abstract class CartEvent extends Event
```
```Kotlin
abstract class CartEvent : Event
```
#### Inheriting classes
[AddedToCartEvent](/developers/mobile-sdk/class-reference/ios/events#productaddedtocartevent)
[RemovedFromCartEvent](/developers/mobile-sdk/class-reference/ios/events#productremovedfromcartevent)
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **type** | String | no | - | Event type |
| **sku** | String | no | - | SKU of the item |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hub. It isn't shown on a Profile card. |
| **finalPrice** | `UnitPrice` | no | - | Final price of the item |
| **quantity** | int | no | - | Quantity of the item |
| **params** | TrackerParams | yes | - | Event tracker parameters |
The following keys: `sku`, `name`, `category`, `categories`, `offline`, `regularUnitPrice`, `discountedUnitPrice`, `finalUnitPrice`, `url`, `producer`, `quantity` are reserved by Synerise for the `params` object.
**Initializers:**
CartEvent(@NonNull String type, @NonNull String label, @NonNull String sku, @NonNull UnitPrice finalPrice, int quantity,
@Nullable TrackerParams params)
**Methods:**
This method sets a value for the `name` parameter.
public void setName(String name)
---
This method sets a value for the `category` parameter.
public void setCategory(String category)
---
This method sets values for the `categories` parameter.
public void setCategories(List<String> categories)
---
This method sets a value for the `offline` parameter.
public void setOffline(boolean offline)
---
This method sets the value of the `regularPrice` parameter.
public void setRegularPrice(UnitPrice regularPrice)
---
This method sets the value of the `discountedPrice` parameter.
public void setDiscountedPrice(UnitPrice discountedPrice)
---
This method sets the value of the `url` parameter.
public void setUrl(String url)
---
This method sets the value of the `producer` parameter (producer can signify a brand of the item).
public void setProducer(String producer)
---
---
---
### AddedToCartEvent
Class model for _add to cart_ event.
**Declared In:**
`com.synerise.sdk.event.model.products.cart.AddedToCartEvent`
**Declaration:**
Java Kotlin
```Java
public class AddedToCartEvent extends CartEvent
```
```Kotlin
class AddedToCartEvent : CartEvent
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **type** | String | no | - | Event type |
| **sku** | String | no | - | SKU of the product |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **finalPrice** | UnitPrice | no | - | Final price of the product |
| **quantity** | int | no | - | Quantity of the product |
| **params** | TrackerParams | yes | - | Event tracker params |
The `"sku"`, `"name"`, `"category"`, `"categories"`, `"offline"` , `"regularUnitPrice"`, `"discountedUnitPrice"`, `"finalUnitPrice"`, `"url"`, `"producer"` , `"quantity"` keys are reserved by Synerise in params.
**Initializers:**
The following constructors are available:
public AddedToCartEvent(@NonNull String label, @NonNull String sku, @NonNull UnitPrice finalPrice, int quantity)
public AddedToCartEvent(@NonNull String label, @NonNull String sku, @NonNull UnitPrice finalPrice, int quantity,
@Nullable TrackerParams params)
**Methods:**
This method defines the value of the `name` parameter.
public void setName(String name)
---
This method defines the value of the `category` parameter.
public void setCategory(String category)
---
This method defines the values of the `categories` parameter.
public void setCategories(List<String> categories)
---
This method defines the value of the `offline` parameter.
The offline parameter describes whether an event occurred outside website, for example in a cash register.
public void setOffline(boolean offline)
---
This method defines the value of the `regularPrice` parameter.
public void setRegularPrice(UnitPrice regularPrice)
---
This method defines the value of the `discountedPrice` parameter.
public void setDiscountedPrice(UnitPrice discountedPrice)
---
This method defines the value of the `url` parameter.
public void setUrl(String url)
---
This method defines the value of the `producer` parameter.
A producer is a manufacturer of the item.
public void setProducer(String producer)
---
---
---
### RemovedFromCartEvent
Class model for _remove from cart_ event.
**Declared In:**
`com.synerise.sdk.event.model.products.cart.RemovedFromCartEvent`
**Declaration:**
Java Kotlin
```Java
public class RemovedFromCartEvent extends CartEvent
```
```Kotlin
class RemovedFromCartEvent : CartEvent
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **type** | String | no | - | Event type |
| **sku** | String | no | - | SKU of the product |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **finalPrice** | `UnitPrice` | no | - | Final price of the product |
| **quantity** | int | no | - | Quantity of the product |
| **params** | TrackerParams | yes | - | Event tracker params |
The keys `"sku"`, `"name"`, `"category"`, `"categories"`, `"offline"` , `"regularUnitPrice"`, `"discountedUnitPrice"`, `"finalUnitPrice"`, `"url"`, `"producer"` , `"quantity"` are reserved by Synerise in params.
**Initializers:**
The following constructors are available:
public RemovedFromCartEvent(@NonNull String label, @NonNull String sku, @NonNull UnitPrice finalPrice, int quantity)
public RemovedFromCartEvent(@NonNull String label, @NonNull String sku, @NonNull UnitPrice finalPrice, int quantity,
@Nullable TrackerParams params)
**Methods:**
This method defines the value of the `name` parameter.
public void setName(String name)
---
This method defines the value of the `category` parameter.
public void setCategory(String category)
---
This method defines the values of the `categories` parameter.
public void setCategories(List<String> categories)
---
This method defines the value of the `offline` parameter.
The offline parameter describes whether an event occurred outside website, for example in a cash register.
public void setOffline(boolean offline)
---
This method defines the value of the `regularPrice` parameter.
public void setRegularPrice(UnitPrice regularPrice)
---
This method defines the value of the `discountedPrice` parameter.
public void setDiscountedPrice(UnitPrice discountedPrice)
---
This method defines the value of the `url` parameter.
public void setUrl(String url)
---
This method defines the value of the `producer` parameter.
A producer is a manufacturer of the item.
public void setProducer(String producer)
---
---
---
### ProductEvent
Class model for _product_ events.
**Declared In:**
`com.synerise.sdk.event.model.ai.ProductEvent`
**Declaration:**
Java Kotlin
```Java
public class ProductEvent extends Event
```
```Kotlin
class ProductEvent : Event
```
#### Inheriting classes
ProductViewEvent
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **name** | String | no | - | Product name |
| **type** | String | no | - | Event type |
| **productId** | String | no | - | Product ID |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
The `"productId"`, `"name"`, `"category"`, `"url"` keys are reserved by Synerise in params.
**Initializers:**
public ProductEvent(@NonNull String type, @NonNull String label, @NonNull String productId, @NonNull String name,
@Nullable TrackerParams params)
**Methods:**
This method defines the value of the `category` parameter.
public void setCategory(String category)
---
This method defines the value of the `url` parameter.
public void setUrl(String url)
---
---
---
### ProductViewEvent
Class model for _the product view_ event.
**Declared In:**
`com.synerise.sdk.event.model.ai.ProductViewEvent`
**Declaration:**
Java Kotlin
```Java
public class ProductViewEvent extends ProductEvent
```
```Kotlin
class ProductViewEvent : ProductEvent
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **name** | String | no | - | Product name |
| **productId** | String | no | - | Product ID |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
The `"productId"`, `"name"`, `"category"`, `"url"` keys are reserved by Synerise in params.
**Initializers:**
The following constructors are available:
public ProductViewEvent(@NonNull String label, @NonNull String productId, @NonNull String name)
public ProductViewEvent(@NonNull String label, @NonNull String productId, @NonNull String name,
@Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### AddedToFavoritesEvent
Class model for _add to favourites_ event.
**Declared In:**
`com.synerise.sdk.event.model.products.AddedToFavoritesEvent`
**Declaration:**
Java Kotlin
```Java
public class AddedToFavoritesEvent extends Event
```
```Kotlin
class AddedToFavoritesEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
**Initializers:**
The following constructors are available:
public AddedToFavoritesEvent(@NonNull String label)
public AddedToFavoritesEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### LoggedInEvent
Class model for _Log in_ event.
**Declared In:**
`com.synerise.sdk.event.model.session.LoggedInEvent`
**Declaration:**
Java Kotlin
```Java
public class LoggedInEvent extends Event
```
```Kotlin
class LoggedInEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
**Initializers:**
The following constructors are available:
public LoggedInEvent(@NonNull String label)
public LoggedInEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### LoggedOutEvent
Class model for _Log out_ event.
**Declared In:**
`com.synerise.sdk.event.model.session.LoggedOutEvent`
**Declaration:**
Java Kotlin
```Java
public class LoggedOutEvent extends Event
```
```Kotlin
class LoggedOutEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
**Initializers:**
The following constructors are available:
public LoggedOutEvent(@NonNull String label)
public LoggedOutEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### RegisteredEvent
Class model for _client register_ event.
.
**Declared In:**
`com.synerise.sdk.event.model.session.RegisteredEvent`
**Declaration:**
Java Kotlin
```Java
public class RegisteredEvent extends Event
```
```Kotlin
class RegisteredEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
**Initializers:**
The following constructors are available:
public RegisteredEvent(@NonNull String label)
public RegisteredEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### RecommendationEvent
Class model for _recommendation_ events.
**Declared In:**
`com.synerise.sdk.event.model.ai.RecommendationEvent`
**Declaration:**
Java Kotlin
```Java
public class RecommendationEvent extends Event
```
```Kotlin
class RecommendationEvent : Event
```
#### Inheriting classes
RecommendationClickEvent
RecommendationSeenEvent
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **name** | String | no | - | Product name |
| **type** | String | no | - | Event type |
| **productId** | String | no | - | Product ID |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **campaignId** | String | no | - | Recommendation campaign ID |
| **campaignHash** | String | no | - | Recommendation campaign hash |
| **params** | TrackerParams | yes | - | Event tracker params |
The `"productId"`, `"name"`, `"category"`, `"url"`, `"campaignId"` , `"campaignHash"` keys are reserved by Synerise in params.
**Initializers:**
public RecommendationEvent(@NonNull String type, @NonNull String label, @NonNull String productId, @NonNull String name,
@NonNull String campaignId, @NonNull String campaignHash,
@Nullable TrackerParams params)
**Methods:**
This method defines the value of the `category` parameter.
public void setCategory(String category)
---
This method defines the value of the `url` parameter.
public void setUrl(String url)
---
---
---
### RecommendationViewEvent
Class model for _recommendation_ events.
**Declared In:**
`com.synerise.sdk.event.model.ai.RecommendationViewEvent`
**Declaration:**
Java Kotlin
```Java
public class RecommendationViewEvent extends Event
```
```Kotlin
class RecommendationViewEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **productId** | String | no | - | Product ID. If this parameter is used, it is translated into a single-item `items` list automatically. If `items` is used, this parameter should be omitted. |
| **items** | `List` | no | - | List of product IDs. If `productId` is used to define a single item in the event, this parameter should be omitted. |
| **correlationId** | String | no | - | Correlation ID of the recommendation |
| **campaignId** | String | no | - | Campaign ID |
| **campaignHash** | String | no | - | Campaign hash |
The `"items"`, `"correlationId"`, `"category"`, `"url"`, `"campaignId"` , `"campaignHash"` keys are reserved by Synerise in params.
**Initializers:**
public RecommendationViewEvent(@NonNull String productId, @NonNull String correlationId,
@NonNull String campaignId, @NonNull String campaignHash)
public RecommendationViewEvent(@NonNull String label, @NonNull String productId, @NonNull String correlationId,
@NonNull String campaignId, @NonNull String campaignHash, @Nullable TrackerParams params)
public RecommendationViewEvent(@NonNull List<String> items, @NonNull String correlationId,
@NonNull String campaignId, @NonNull String campaignHash)
public RecommendationViewEvent(@NonNull String label, @NonNull List<String> items, @NonNull String correlationId,
@NonNull String campaignId, @NonNull String campaignHash, @Nullable TrackerParams params)
**Methods:**
This method defines the value of the `category` parameter.
public void setCategory(String category)
---
This method defines the value of the `url` parameter.
public void setUrl(String url)
---
---
---
### RecommendationSeenEvent
Class model for _recommendation seen_ event.
**Declared In:**
`com.synerise.sdk.event.model.ai.RecommendationSeenEvent`
**Declaration:**
Java Kotlin
```Java
public class RecommendationSeenEvent extends RecommendationEvent
```
```Kotlin
class RecommendationSeenEvent : RecommendationEvent
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **name** | String | no | - | Product name |
| **productId** | String | no | - | Product ID |
| **campaignId** | String | no | - | Recommendation campaign ID |
| **campaignHash** | String | no | - | Recommendation campaign hash |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
The `"productId"`, `"name"`, `"category"`, `"url"`, `"campaignId"` , `"campaignHash"` keys are reserved by Synerise in params.
**Initializers:**
The following constructors are available:
public RecommendationSeenEvent(@NonNull String label, @NonNull String productId, @NonNull String name,
@NonNull String campaignId, @NonNull String campaignHash)
public RecommendationSeenEvent(@NonNull String label, @NonNull String productId, @NonNull String name,
@NonNull String campaignId, @NonNull String campaignHash, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### RecommendationClickEvent
Class model for _recommendation click_ event.
**Declared In:**
`com.synerise.sdk.event.model.ai.RecommendationClickEvent`
**Declaration:**
Java Kotlin
```Java
public class RecommendationClickEvent extends RecommendationEvent
```
```Kotlin
class RecommendationClickEvent : RecommendationEvent
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **name** | String | no | - | Product name |
| **productId** | String | no | - | Product ID |
| **campaignId** | String | no | - | Recommendation campaign ID |
| **campaignHash** | String | no | - | Recommendation campaign hash |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
The `"productId"`, `"name"`, `"category"`, `"url"`, `"campaignId"` , `"campaignHash"` keys are reserved by Synerise in params.
**Initializers:**
The following constructors are available:
public RecommendationClickEvent(@NonNull String label, @NonNull String productId, @NonNull String name,
@NonNull String campaignId, @NonNull String campaignHash)
public RecommendationClickEvent(@NonNull String label, @NonNull String productId, @NonNull String name,
@NonNull String campaignId, @NonNull String campaignHash, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### VisitedScreenEvent
Class model for _visited screen_ event.
**Declared In:**
`com.synerise.sdk.event.model.interaction.VisitedScreenEvent`
**Declaration:**
Java Kotlin
```Java
public class VisitedScreenEvent extends Event
```
```Kotlin
class VisitedScreenEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
**Initializers:**
The following constructors are available:
public VisitedScreenEvent(@NonNull String label)
public VisitedScreenEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### HitTimerEvent
Class model for _hit timer_ event.
Record a "customer hit timer" event. This could be used for profiling or activity time monitoring - you can send "hit timer"
when your customer starts doing something and send it once again when they finish, but this time with a different time signature.
Then you can use [Decision Hub](/docs/analytics) to measure, for example, average activity time.
**Declared In:**
`com.synerise.sdk.event.model.interaction.HitTimerEvent`
**Declaration:**
Java Kotlin
```Java
public class HitTimerEvent extends Event
```
```Kotlin
class HitTimerEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
**Initializers:**
The following constructors are available:
public HitTimerEvent(@NonNull String label)
public HitTimerEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### SearchedEvent
Class model for _client searched_ event.
**Declared In:**
`com.synerise.sdk.event.model.interaction.SearchedEvent`
**Declaration:**
Java Kotlin
```Java
public class SearchedEvent extends Event
```
```Kotlin
class SearchedEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
**Initializers:**
The following constructors are available:
public SearchedEvent(@NonNull String label)
public SearchedEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### SharedEvent
Class model for _client shared_ event.
**Declared In:**
`com.synerise.sdk.event.model.interaction.SharedEvent`
**Declaration:**
Java Kotlin
```Java
public class SharedEvent extends Event
```
```Kotlin
class SharedEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
**Initializers:**
The following constructors are available:
public SharedEvent(@NonNull String label)
public SharedEvent(@NonNull String label, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### AppearedInLocationEvent
Class model for _appeared in location_ event.
**Declared In:**
`com.synerise.sdk.event.model.interaction.AppearedInLocationEvent`
**Declaration:**
Java Kotlin
```Java
public class AppearedInLocationEvent extends Event
```
```Kotlin
class AppearedInLocationEvent : Event
```
This event will be transformed into `client.location` in the database.
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hub. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
| **lon** | Double | no | - | Longitude |
| **lat** | Double | no | - | Latitude |
The `"lat"` and `"lon"` keys are reserved by Synerise in params.
**Initializers:**
The following constructors are available:
public AppearedInLocationEvent(@NonNull String label, double lat, double lon)
public AppearedInLocationEvent(@NonNull String label, double lat, double lon, @Nullable TrackerParams params)
**Methods:**
There are no methods.
---
---
### CrashEvent
Class model for _crash_ event.
**Declared In:**
`com.synerise.sdk.event.model.crash.CrashEvent`
**Declaration:**
Java Kotlin
```Java
public class CrashEvent extends Event
```
```Kotlin
class CrashEvent : Event
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **label** | String | no | - | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hub. It isn't shown on a Profile card. |
| **params** | TrackerParams | yes | - | Event tracker params |
**Initializers:**
There is a constructor.
public CrashEvent(@NonNull String label, @NonNull TrackerParams params)
**Methods:**
There are no methods.
# Customer authentication
## Set Client State Change listener
---
Set your own ClientStateChangeListener to get optional callbacks.
**Method name:**
Client.setOnClientStateChangeListener(listener);
**Declaration:**
Java Kotlin
```Java
public static void setOnClientStateChangeListener(OnClientStateChangeListener listener)
```
```Kotlin
fun setOnClientStateChangeListener(listener:OnClientStateChangeListener)
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **listener** | OnClientStateChangeListener | yes | - | interface to handle client state change |
**Return Value:**
No value is returned.
**Example:**
Java Kotlin
```Java
Client.setOnClientStateChangeListener(listener);
```
```Kotlin
Client.setOnClientStateChangeListener(listener)
```
## Remove Client State Change listener
---
Remove your own ClientStateChangeListener.
**Method name:**
Client.removeClientStateChangeListener();
**Declaration:**
Java Kotlin
```Java
public static void removeClientStateChangeListener()
```
```Kotlin
fun removeClientStateChangeListener()
```
**Parameters:**
No parameters required.
**Return Value:**
No value is returned.
**Example:**
Java Kotlin
```Java
Client.removeClientStateChangeListener();
```
```Kotlin
Client.removeClientStateChangeListener()
```
## 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](/developers/mobile-sdk/user-identification-and-authorization/overview).
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.
**Method name:**
Client.registerAccount(registerClient)
**Declaration:**
Java Kotlin
```Java
public static IApiCall registerAccount(@NonNull RegisterClient registerClient)
```
```Kotlin
fun registerAccount(registerClient: RegisterClient): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default |
| --- | --- | --- | --- |
| **registerClient** | [RegisterClient](/developers/mobile-sdk/class-reference/android/client#registerclient) | yes | - |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
private IApiCall signUpCall;
private void signUp(RegisterClient registerClient) {
if (signUpCall != null) signUpCall.cancel();
signUpCall = Client.registerAccount(registerClient);
signUpCall.onSubscribe(() -> toggleLoading(true))
.doFinally(() -> toggleLoading(false))
.execute(this::onSignUpSuccessful, this::onSignUpFailure);
}
```
```Kotlin
private var signUpCall: IApiCall
private fun signUp(registerClient: RegisterClient) {
signUpCall!!.cancel()
signUpCall = Client.registerAccount(registerClient)
signUpCall!!.onSubscribe({ toggleLoading(true) })
.doFinally({ toggleLoading(false) })
.execute(({ this.onSignUpSuccessful() }), ({ this.onSignUpFailure() }))
}
```
## 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.
**Method name:**
Client.requestAccountActivation(email)
**Declaration:**
java kotlin
```java
public static IApiCall requestAccountActivation(String email)
```
```kotlin
fun requestAccountActivation(email: String): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - |Customer's email|
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
java kotlin
```java
private IApiCall call;
if (call != null) call.cancel();
call = Client.requestAccountActivation(email);
call.execute(this::onSuccess, this::onError);
```
```kotlin
private val call: IApiCall? = null
call.cancel();
call = Client.requestAccountActivation(email);
call.execute(this::onSuccess, this::onError);
```
## 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.
**Method name:**
Client.confirmAccountActivation(token)
**Declaration:**
java kotlin
```java
public static IApiCall confirmAccountActivation(String token)
```
```kotlin
fun confirmAccountActivation(token: String): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | String | yes | - | Customer's token |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
java kotlin
```java
private IApiCall call;
if (call != null) call.cancel();
call = Client.confirmAccountActivation(token);
call.execute(this::onSuccess, this::onError);
```
```kotlin
private val call: IApiCall? = null
call.cancel();
call = Client.confirmAccountActivation(token);
call.execute(this::onSuccess, this::onError);
```
## 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.
**Method name:**
Client.requestAccountActivationByPin(email)
**Declaration:**
Java Kotlin
```Java
public static IApiCall requestAccountActivationByPin(String email)
```
```Kotlin
fun requestAccountActivationByPin(email:String):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Email to which the pinCode will be sent |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
IApiCall apiCall;
apiCall = Client.requestAccountActivationByPin(email);
apiCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
val apiCall:IApiCall
apiCall = Client.requestAccountActivationByPin(email)
apiCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## 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.
**Method name:**
Client.confirmAccountActivationByPin(pinCode, email)
**Declaration:**
Java Kotlin
```Java
public static IApiCall confirmAccountActivationByPin(String pinCode, String email)
```
```Kotlin
fun confirmAccountActivationByPin(pinCode: String, email:String):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **pinCode** | String | yes | - | Code sent to the customer's email |
| **email** | String | yes | - | Email used in the registration process |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
IApiCall apiCall;
apiCall = Client.confirmAccountActivationByPin(pinCode, email);
apiCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
val apiCall:IApiCall
apiCall = Client.confirmAccountActivationByPin(pinCode, email)
apiCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## 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.
**Method name:**
Client.signIn(email, password)
**Declaration:**
Java Kotlin
```Java
public static IApiCall signIn(@NonNull String email, @NonNull String password)
```
```Kotlin
fun signIn(email: String, password: String): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer's email |
| **password** | String | yes | - | Customer's password |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
private IApiCall signInCall;
private void signIn(String login, String password) {
if (signInCall != null) signInCall.cancel();
signInCall = Client.signIn(login, password);
signInCall.onSubscribe(() -> toggleLoading(true))
.execute(() -> onSignInSuccessful(login), () -> onSignInFailure());
}
```
```Kotlin
private var signInCall: IApiCall
private fun signIn(login: String, password: String) {
signInCall!!.cancel()
signInCall = Client.signIn(login, password)
signInCall!!.onSubscribe({ toggleLoading(true) })
.execute({ onSignInSuccessful(login) }, { onSignInFailure() })
}
```
## 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 |
**Method name:**
Client.signInConditionally(email, password)
**Declaration:**
java kotlin
```java
public static IDataApiCall
signInConditionally(@NonNull String email, @NonNull String password)
```
```kotlin
fun signInConditionally(
email: String,
password: String,
): IDataApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Client's email |
| **password** | String | yes | - | Client's password |
**Return Value:**
IDataApiCall<[AuthConditions](/developers/mobile-sdk/class-reference/android/client#authconditions)> object to execute the request.
**Example:**
java kotlin
```java
private IDataApiCall
call;
if (call != null) call.cancel();
call = Client.signInConditionally(email, password));
call.execute(this::onSuccess, this::onFailure);
```
```kotlin
val call:IDataApiCall
call.cancel()
call = Client.signInConditionally(email, password)
call.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## 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 |
**Method name:**
Client.authenticate(token, clientIdentityProvider, agreements, attributes, authId)
**Declaration:**
java kotlin
```java
public static IApiCall authenticate(String token, ClientIdentityProvider provider, Agreements agreements, Attributes attributes, String authId)
```
```kotlin
fun authenticate(
token: String,
provider: ClientIdentityProvider,
agreements: Agreements?,
attributes: Attributes?,
authId: String?
): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | String | yes | - | Token retrieved from provider |
| **provider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/android/client#clientidentityprovider) | yes | - | Provider of your token |
| **agreements** | [Agreements](/developers/mobile-sdk/class-reference/android/client#agreements) | no | - | Optional agreements |
| **attributes** | [Attributes](/developers/mobile-sdk/class-reference/android/client#attributes) | no | - | Optional attributes |
| **authId** | String | no | - | Optional identifier of authorization |
**authId** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
java kotlin
```java
private IApiCall call;
if (call != null) call.cancel();
call = Client.authenticate(token, provider, null, null, null);
call.execute(this::onSuccess, this::onFailure);
```
```kotlin
val call:IApiCall
call.cancel()
call = Client.authenticate(token, provider, null, null, null)
call.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## 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 |
**Method name:**
Client.authenticateConditionally(token, clientIdentityProvider, agreements, attributes, authId)
**Declaration:**
java kotlin
```java
public static IDataApiCall
authenticateConditionally(@NonNull String token, @NonNull ClientIdentityProvider provider, @Nullable Agreements agreements, @Nullable Attributes attributes, @Nullable String authId)
```
```kotlin
fun authenticateConditionally(
token: String,
provider: ClientIdentityProvider,
agreements: Agreements?,
attributes: Attributes?,
authId: String?
): IDataApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | String | yes | - | Token retrieved from provider |
| **provider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/android/client#clientidentityprovider) | yes | - | Provider of your token |
| **agreements** | [Agreements](/developers/mobile-sdk/class-reference/android/client#agreements) | no | - | Optional agreements |
| **attributes** | [Attributes](/developers/mobile-sdk/class-reference/android/client#attributes) | no | - | Optional attributes |
| **authId** | String | no | - | Optional identifier of authorization |
**authId** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
**Return Value:**
IDataApiCall<[AuthConditions](/developers/mobile-sdk/class-reference/android/client#authconditions)> object to execute the request.
**Example:**
java kotlin
```java
private IDataApiCall
call;
if (call != null) call.cancel();
call = Client.authenticateConditionally(token, clientIdentityProvider, agreements, attributes, authId));
call.execute(this::onSuccess, this::onFailure);
```
```kotlin
val call:IDataApiCall
call.cancel()
call = Client.authenticateConditionally(token, clientIdentityProvider, agreements, attributes, authId)
call.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## 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 |
**Method name:**
Client.authenticateWithTokenPayload()
**Declaration:**
Java Kotlin
```Java
public static IApiCall authenticateWithTokenPayload(TokenPayload tokenPayload, @NonNull String authId)
```
```Kotlin
fun authenticateWithTokenPayload(
tokenPayload: TokenPayload,
authId: String
): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **tokenPayload** | [TokenPayload](/developers/mobile-sdk/class-reference/android/client#tokenpayload) | yes | - | Object which contains a token's payload |
| **authId** | String | yes | - | Required customer's identifier of authorization |
**authId** parameter is used for decreasion the number of UUID refreshes so it must be unique for every customer.
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
java kotlin
```java
private IApiCall call;
if (call != null) call.cancel();
call = Client.authenticateWithTokenPayload(tokenPayload, authId);
call.execute(this::onSuccess, this::onFailure);
```
```kotlin
val call:IApiCall
call.cancel()
call = Client.authenticateWithTokenPayload(tokenPayload, authId)
call.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## 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.
**Method name:**
Client.simpleAuthentication(clientData, authId)
**Declaration:**
java kotlin
```java
public static IApiCall simpleAuthentication(ClientData clientData, String authId)
```
```kotlin
fun simpleAuthentication(
clientData: ClientData,
authId: String
): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **clientData** | [ClientData](/developers/mobile-sdk/class-reference/android/client#clientdata) | yes | - | Object which contains customer data |
| **authId** | String | yes | - | Required identifier of authorization |
**authId** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
## 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).
**Method name:**
Client.isSignedIn()
**Declaration:**
Java Kotlin
```Java
public static boolean isSignedIn()
```
```Kotlin
fun isSignedIn():Boolean
```
**Parameters:**
No parameters.
**Return Value:**
Boolean defining whether a customer is signed in or not.
**Example:**
Java Kotlin
```Java
boolean isSignedIn = Client.isSignedIn()
```
```Kotlin
var isSignedIn = Client.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 |
**Method name:**
Client.isSignedIn()
**Declaration:**
Java Kotlin
```Java
public static boolean isSignedInViaSimpleAuthentication()
```
```Kotlin
fun isSignedInViaSimpleAuthentication():Boolean
```
**Parameters:**
No parameters.
**Return Value:**
**true** if the customer is signed in (via Simple Profile Authentication), otherwise returns **false**.
**Example:**
Java Kotlin
```Java
boolean isSignedInViaSimpleAuthentication = Client.isSignedInViaSimpleAuthentication()
```
```Kotlin
var isSignedInViaSimpleAuthentication = Client.isSignedInViaSimpleAuthentication()
```
## 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).
**Method name:**
Client.signOut()
**Declaration:**
Java Kotlin
```Java
public static void signOut()
```
```Kotlin
fun signOut()
```
**Parameters:**
No parameters.
**Return Value:**
Nothing is returned.
**Example:**
Java Kotlin
```Java
Client.signOut();
```
```Kotlin
Client.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:
- `.signOut` mode signs out the customer.
- `.signOutWithSessionDestroy` mode 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).
**Class:**
[Client](/developers/mobile-sdk/class-reference/android/modules#client)
**Declaration:**
java kotlin
```java
public static IApiCall signOut(ClientSignOutMode mode, Boolean signOutFromAllDevices)
```
```kotlin
fun signOut(mode: ClientSignOutMode, signOutFromAllDevices: Boolean): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **mode** | [ClientSignOutMode](/developers/mobile-sdk/class-reference/android/client#clientsignoutmode) | yes | - | Client sign out mode |
| **signOutFromAllDevices** | Boolean | yes | - | Determines if the method should sign out all devices |
**Return Value:**
Nothing is returned.
**Example:**
java kotlin
```java
private IApiCall signOutCall;
private void signOut() {
if (signOutCall != null) signOutCall.cancel();
signOutCall = Client.signOut(ClientSignOutMode.SIGN_OUT_WITH_SESSION_CLEARING, true);
signOutCall.onSubscribe(() -> toggleLoading(true))
.execute(() -> onSignOutSuccessful(login), () -> onSignOutFailure());
}
```
```kotlin
private var signOutCall: IApiCall
private fun signOut(login: String, password: String) {
signOutCall!!.cancel()
signOutCall = Client.signOut(.SIGN_OUT_WITH_SESSION_CLEARING, true)
signOutCall!!.onSubscribe({ toggleLoading(true) })
.execute({ onSignOutSuccessful(login) }, { onSignOutFailure() })
}
```
## Removed methods
### Authenticate customer by OAuth with registration {#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.
**Method name:**
Client.authenticateByOAuth(accessToken, agreements, attributes, authId)
**Declaration:**
java kotlin
```java
public static IApiCall authenticateByOAuth(@NonNull String accessToken, @Nullable Agreements agreements, @Nullable Attributes attributes, @Nullable String authId)
```
```kotlin
fun authenticateByOAuth(
accessToken: String,
agreements: Agreements?,
attributes: Attributes?,
authId: String?
): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **accessToken** | String | yes | - | OAuth Access Token |
| **agreements** | [Agreements](/developers/mobile-sdk/class-reference/android/client#agreements) | no | --- | Optional agreements |
| **attributes** | [Attributes](/developers/mobile-sdk/class-reference/android/client#attributes) | no | --- | Optional attributes |
| **authId** | String | no | --- | Optional identifier of authorization |
**authId** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
java kotlin
```java
private IApiCall call;
if (call != null) call.cancel();
call = Client.authenticateByOAuth(token, null, null, null);
call.execute(this::onSuccess, this::onFailure);
```
```kotlin
val call:IApiCall
call.cancel()
call = Client.authenticateByOAuth(token, null, null, null)
call.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
### Authenticate customer by OAuth without registration {#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.
**Method name:**
Client.authenticateByOAuthIfRegistered(accessToken, authId)
**Declaration:**
java kotlin
```java
public static IApiCall authenticateByOAuthIfRegistered(@NonNull String accessToken, @Nullable String authId)
```
```kotlin
fun authenticateByOAuthIfRegistered(
accessToken: String,
authId: String?
): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **accessToken** | String | yes | - | OAuth Access Token |
| **authId** | String | no | --- | Optional identifier of authorization |
**authId** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
java kotlin
```java
private IApiCall call;
if (call != null) call.cancel();
call = Client.authenticateByOAuthIfRegistered(token, null);
call.execute(this::onSuccess, this::onFailure);
```
```kotlin
val call:IApiCall
call.cancel()
call = Client.authenticateByOAuthIfRegistered(token, null)
call.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
### Authenticate customer by Facebook with registration {#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.
**Method name:**
Client.authenticateByFacebook(facebookToken, agreements, attributes, authId)
**Declaration:**
java kotlin
```java
public static IApiCall authenticateByFacebook(@NonNull String facebookToken, @Nullable Agreements agreements, @Nullable Attributes attributes, @Nullable String authId)
```
```kotlin
fun authenticateByFacebook(
facebookToken: String,
agreements: Agreements?,
attributes: Attributes?,
authId: String?
): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **facebookToken** | String | yes | - | Facebook Access Token |
| **agreements** | [Agreements](/developers/mobile-sdk/class-reference/android/client#agreements)| no | --- | Marketing agreements |
| **attributes** | [Attributes](/developers/mobile-sdk/class-reference/android/client#attributes) | no | --- | Additional attributes |
| **authId** | String | no | --- | Optional identifier of authorization |
**authId** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
private IApiCall signInFacebookCall;
private void signInFacebook(String facebookToken) {
if (signInFacebookCall != null) signInFacebookCall.cancel();
signInFacebookCall = Client.authenticateByFacebook(facebookToken, null, null, null);
signInFacebookCall.onSubscribe(() -> toggleFacebookLoading(true))
.execute(this::onSignInFacebookSuccess, this::onSignInFacebookError);
}
```
```Kotlin
private var signInFacebookCall: IApiCall? = null
private fun signInFacebook(facebookToken: String) {
if (signInFacebookCall != null) signInFacebookCall!!.cancel()
signInFacebookCall = Client.authenticateByFacebook(facebookToken, null, null, null)
signInFacebookCall!!.onSubscribe({ toggleFacebookLoading(true) })
.execute(({ this.onSignInFacebookSuccess() }), ({ this.onSignInFacebookError() }))
}
```
### Authenticate customer by Facebook without registration {#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.
**Method name:**
Client.authenticateByFacebookRegistered(facebookToken, authId)
**Declaration:**
java kotlin
```java
public static IApiCall authenticateByFacebookRegistered(@NonNull String facebookToken, @Nullable String authId)
```
```kotlin
fun authenticateByFacebookRegistered(facebookToken: String, authId: String?): IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **facebookToken** | String | yes | - | Facebook Access Token|
| **authId** | String | no | --- | Optional identifier of authorization |
**authId** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
java kotlin
```java
private IApiCall signInFacebookRegisteredCall;
private void signInFacebookRegistered(String facebookToken) {
if (signInFacebookRegisteredCall != null) signInFacebookRegisteredCall.cancel();
signInFacebookRegisteredCall = Client.authenticateByFacebookRegistered(facebookToken, null);
signInFacebookRegisteredCall.onSubscribe(() -> toggleFacebookLoading(true))
.execute(this::onSignInFacebookSuccess, this::onSignInFacebookError);
}
```
```kotlin
private var signInFacebookRegisteredCall: IApiCall? = null
private fun signInFacebook(facebookToken: String) {
signInFacebookRegisteredCall!!.cancel()
signInFacebookRegisteredCall = Client.authenticateByFacebookRegistered(facebookToken, null)
signInFacebookRegisteredCall!!.onSubscribe({ toggleFacebookLoading(true) })
.execute(({ this.onSignInFacebookSuccess() }), ({ this.onSignInFacebookError() }))
}
```
### Sign out customer with mode {#sign-out-customer-with-mode}
---
This method signs out a customer out 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 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).
**Class:**
[Client](/developers/mobile-sdk/class-reference/android/modules#client)
**Declaration:**
java kotlin
```java
public static void signOut(ClientSignOutMode mode)
```
```kotlin
fun signOut()
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **mode** | [ClientSignOutMode](/developers/mobile-sdk/class-reference/android/client#clientsignoutmode) | yes | - | Client sign out mode |
**Return Value:**
Nothing is returned.
**Example:**
Java Kotlin
```Java
Client.signOut(mode);
```
```Kotlin
Client.signOut(mode);
```
# React Native
## Configuring push notifications (React Native)
### Configuring Firebase
---
Google Firebase Cloud Messaging is necessary to handle [push notifications](/docs/campaign/Mobile) sent from Synerise.
1. Follow the instructions in [this article](https://firebase.google.com/docs/storage/ios/start).
2. Integrate the Firebase project with Synerise. See [this article](/docs/settings/tool/firebase).
### Setting up - Android {id=setting-up-android}
---
#### Requirements {id=android-requirements}
After configuring Firebase, add the `google-services.json` file to your project/android/app catalog.
#### Firebase Cloud Messaging integration {id=android-firebase-cloud-messaging-integration}
1. Add the google-services dependency to your project's `build.gradle` file.
dependencies {
...
classpath 'com.google.gms:google-services:4.3.3'
...
}
2. Configure the application's `build.gradle` as follows:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // from node_modules
// FCM
implementation "com.google.firebase:firebase-messaging:20.0.1"
implementation "com.google.android.gms:play-services-base:17.1.0"
implementation "com.google.firebase:firebase-core:17.2.1"
implementation "com.google.firebase:firebase-analytics:17.2.1"
...
}
1. Make sure that at the end of the application gradle file, you add plugin: 'com.google.gms.google-services'
1. In your MainApplication class, include `setPushListener` to listen for the changes of the Firebase token.
Java Kotlin
```Java
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
getReactNativeHost().getReactInstanceManager().createReactContextInBackground();
RNNotifications.setPushListener(new OnRegisterPushListener() {
@Override
public void onRegisterPushRequired() {
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(instanceIdResult -> {
String refreshedToken = instanceIdResult.getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
RNNotifications.setRegistrationToken(refreshedToken);
});
}
});
}
```
```Kotlin
fun onCreate() {
super.onCreate()
SoLoader.init(this, /* native exopackage */ false)
getReactNativeHost().getReactInstanceManager().createReactContextInBackground()
RNNotifications.setPushListener(object:OnRegisterPushListener() {
fun onRegisterPushRequired() {
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener({ instanceIdResult->
val refreshedToken = instanceIdResult.getToken()
Log.d(TAG, "Refreshed token: " + refreshedToken)
RNNotifications.setRegistrationToken(refreshedToken)
})
}
})
}
```
#### Receiving push notifications {id=android-receiving-push-notifications}
In order to handle Synerise push notifications, you must pass the incoming push payload to the Synerise SDK.
1. Create a class extending `FirebaseMessagingService`:
Java Kotlin
```Java
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = MyFirebaseMessagingService.class.getSimpleName();
@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Map data = remoteMessage.getData();
RNNotifications.onNotificationReceive(data);
}
@Override
public void onNewToken(String refreshedToken) {
super.onNewToken(refreshedToken);
Log.d(TAG, "Refreshed token: " + refreshedToken);
if (refreshedToken != null) {
RNNotifications.setRegistrationToken(refreshedToken);
}
}
}
```
```Kotlin
class MyFirebaseMessagingService:FirebaseMessagingService() {
fun onMessageReceived(@NonNull remoteMessage:RemoteMessage) {
super.onMessageReceived(remoteMessage)
val data = remoteMessage.getData()
RNNotifications.onNotificationReceive(data)
}
fun onNewToken(refreshedToken:String) {
super.onNewToken(refreshedToken)
Log.d(TAG, "Refreshed token: " + refreshedToken)
if (refreshedToken != null)
{
RNNotifications.setRegistrationToken(refreshedToken)
}
}
}
```
1. To enable banners, handle the intent when the app starts. You can do it in your `MainActivity` by calling `RNNotifications.onNotificationReceive` in your `onCreate` and `onNewIntent`.
Java Kotlin
```Java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RNNotifications.onNotificationReceive(getIntent().getExtras());
}
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
RNNotifications.onNotificationReceive(intent.getExtras());
}
```
```Kotlin
protected fun onCreate(savedInstanceState:Bundle) {
super.onCreate(savedInstanceState)
RNNotifications.onNotificationReceive(getIntent().getExtras())
}
fun onNewIntent(intent:Intent) {
super.onNewIntent(intent)
RNNotifications.onNotificationReceive(intent.getExtras())
}
```
### Setting up - iOS {id=setting-up-ios}
---
#### Requirements {id=ios-requirements}
Configure handling Push Notifications in your application. See [Apple Notifications](https://developer.apple.com/notifications/).
#### Firebase Cloud Messaging integration {id=ios-firebase-cloud-messaging-integration}
1. Import `RNNotifications.h`
Swift Objective-C
```Swift
import react-native-synerise-sdk
```
```Objective-C
#import
```
2. Extend the Firebase Messaging Delegate so our SDK can receive the Firebase token that is required to deliver push notifications from Synerise.
Swift Objective-C
```Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Messaging.messaging().delegate = self
if #available(iOS 10, *) {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in
}
} else {
let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
}
// MARK: - MessagingDelegate
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
RNNotifications.didChangeRegistrationToken(fcmToken)
}
```
```Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure];
[FIRMessaging messaging].delegate = self;
if (@available(iOS 10, *)) {
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
UNAuthorizationOptions authOptions = (UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge);
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError *error) {
}];
} else {
UIUserNotificationType allNotificationTypes = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
#pragma mark - FIRMessagingDelegate
- (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken {
[RNNotifications didChangeRegistrationToken:fcmToken];
}
```
Make sure that the Firebase token is always up-to-date. When it changes, use `RNNotifications.didChangeRegistrationToken(registrationToken:)` again.
#### Receiving push notifications {id=ios-receiving-push-notifications}
The following code shows how to receive push notifications in the `AppDelegate.h` and pass these to the React Native part of the application:
To properly receive notifications, all of these methods must be implemented.
Swift Objective-C
```Swift
// iOS 9
// Push Notifications
// Silent Push Notifications
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
RNNotifications.didReceiveNotification(userInfo)
completionHandler(.noData)
}
func application(_ application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [AnyHashable : Any], completionHandler: @escaping () -> Void) {
RNNotifications.didReceiveNotification(userInfo, actionIdentifier:identifier)
completionHandler()
}
// iOS 10 and above
// Push Notifications
// MARK: - UNUserNotificationCenterDelegate
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
RNNotifications.didReceiveNotification(response.notification.request.content.userInfo, actionIdentifier:response.actionIdentifier)
completionHandler()
}
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
RNNotifications.didReceiveNotification(notification.request.content.userInfo)
completionHandler(UNNotificationPresentationOptions.init(rawValue: 0))
}
```
```Objective-C
// iOS 9
// Push Notifications
// Silent Push Notifications
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[RNNotifications didReceiveNotification:userInfo];
completionHandler(UIBackgroundFetchResultNoData);
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(nullable NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler {
[RNNotifications didReceiveNotification:userInfo actionIdentifier:identifier];
completionHandler();
}
// iOS 10 and above
// Push Notifications
#pragma mark - UNUserNotificationCenterDelegate
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler NS_AVAILABLE_IOS(10) {
[RNotifications didReceiveNotification:response.notification.request.content.userInfo actionIdentifier:response.actionIdentifier];
completionHandler();
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler NS_AVAILABLE_IOS(10) {
[RNNotifications didReceiveNotification:notification.request.content.userInfo];
completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound);
}
```
#### Extensions for push notifications {id=ios-extensions-for-push-notifications}
##### Notification Service Extension {id=synerise-notification-service-extension-for-ios}
**Synerise Notification Service Extension** is an object that adds the notification functionality to the SDK.
It implements the following operations:
- Decrypting **Simple Push** communication data (if encryption is enabled).
- Tracking events from **Simple Push** communication.
- Adding action buttons to **Simple Push** communication (if the communication contains any).
- Improving the appearance of **Simple Push** communication (Rich Media - Single Image) with an image thumbnail.
**Notification Service Extension** should be implemented in the native part of the application. Follow the instructions in [this article](/developers/mobile-sdk/configuring-push-notifications/ios#synerise-notification-service-extension-configuration).
##### Rich Media Notification Content Extensions {id=synerise-notification-content-extension-for-ios}
**Synerise Rich Media Notification Content Extension** is an object that allows rendering your own appearance of a push notification when the notification is expanded (by tapping the notification).
**Synerise Rich Media Notification Content Extensions** should be implemented in the native part of the application. Follow the instructions in [this article](/developers/mobile-sdk/configuring-push-notifications/ios#rich-media-in-push-notifications).
### Set up Firebase FCM token registration for Synerise SDK
---
Get Firebase FCM token from the native part of the application so our SDK can receive the Firebase token that is required to deliver push notifications from Synerise. Make sure that the Firebase FCM token is always up-to-date by implementing the [onRegistrationRequired()](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#notifications-listener) method.
JavaScript
```JavaScript
Synerise.Notifications.setListener({
onRegistrationToken: function(token) {
Synerise.Notifications.registerForNotifications(token, true, function() {
// success
}, function(error) {
// failure
});
},
onRegistrationRequired: function() {
let registrationToken = getLastPushRegistrationToken();
let mobilePushAgreement = true; // true or false, should depend on device permissions and customer's agreement in the application
Synerise.Notifications.registerForNotifications(registrationToken, mobilePushAgreement, function() {
// success
}, function(error) {
// failure
});
}
//...
});
```
The second parameter of the registration method is the agreement for mobile push campaigns. In the Profile's card in Synerise, you can find it in the **Subscriptions** section (if you have the required access permission). Learn more about the [Synerise.Notifications.registerForNotifications(registrationToken:mobilePushAgreement:onSuccess:onError:) method in the method reference](/developers/mobile-sdk/method-reference/react-native/campaigns#register-for-push-notifications).
You must always keep the Firebase token updated. In many cases in the application lifecycle, such as authorization, destroy session, user context change, and so on, the registration needs to be updated. In these situations, the SDK invokes the [onRegistrationRequired()](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#notifications-listener) method (see code snippet above).
### Configure Notification Encryption
---
#### Android {id=android-notification-encryption-configuration}
See [Configure Notification Encryption](/developers/mobile-sdk/configuring-push-notifications/android#configure-notification-encryption).
#### iOS {id=ios-notification-encryption-configuration}
See [Synerise Notification Service Extension](#synerise-notification-service-extension-for-ios) and [Configure Notification Encryption](/developers/mobile-sdk/configuring-push-notifications/ios#configure-notification-encryption).
#### Application implementation {id=application-notification-encryption-configuration}
In the application, you must set `encryption` to `true` in the SDK initializer or in the SDK settings.
JavaScript
```JavaScript
// The first way
// WARNING: This option must be configured before Synerise SDK is initialized!
Synerise.Settings.notifications.encryption = true;
// The second way
Synerise.Initializer()
.withApiKey('XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX')
.withBaseUrl(null)
.withDebugModeEnabled(true)
.withCrashHandlingEnabled(true)
.withSettings({
notifications: {
enabled: true,
encryption: true
}
//...
})
.init()
```
### Handling incoming push notifications
---
You may disable handling push notifications in the SDK at any time. See [Enable/disable notifications](/developers/mobile-sdk/settings#enabledisable-notifications).
#### Synerise payload
The following code shows how to handle push notifications:
JavaScript
```JavaScript
Synerise.Notifications.setListener({
//...
onNotification: function(payload, actionIdentifier) {
if (Synerise.Notifications.isSyneriseNotification(payload)) {
Synerise.Notifications.handleNotification(payload, actionIdentifier);
}
}
//...
});
```
#### Custom payload
You may send both custom push notifications and custom campaigns in [Synerise](https://app.synerise.com). The code below of one sample delegate method checks the notification origin and then handles it.
JavaScript
```JavaScript
Synerise.Notifications.setListener({
//...
onNotification: function(payload, actionIdentifier) {
if (Synerise.Notifications.isSyneriseNotification(payload)) {
Synerise.Notifications.handleNotification(payload, actionIdentifier);
} else {
// Handle other notification in your own way
}
}
//...
});
```
#### Encrypted payloads
If you handle the Synerise notification, you do not have to do anything. The SDK decrypts Synerise notification's payload:
- In [Notification Service Extension](#synerise-notification-service-extension-for-ios) for push notifications
- In the SDK, after invoking [`Synerise.Notifications.handleNotification(payload, actionIdentifier)`](/developers/mobile-sdk/method-reference/react-native/campaigns#handle-synerise-push-notification) for silent push notifications
Otherwise, if it is a custom encrypted push notification sent by Synerise, or you need decrypt data from the push notification, there are two methods for dealing with it:
- [`Synerise.Notifications.isNotificationEncrypted(payload)`](/developers/mobile-sdk/method-reference/react-native/campaigns#check-if-push-notification-is-encrypted) - checks if the notification payload is encrypted by Synerise.
- [`Synerise.Notifications.decryptNotification(payload)`](/developers/mobile-sdk/method-reference/react-native/campaigns#decrypt-push-notification) - decrypts a notification payload.
JavaScript
```JavaScript
Synerise.onReady(function() {
//...
onNotification: function(payload, actionIdentifier) {
if (Synerise.Notifications.isSyneriseNotification(payload)) {
let isNotificationEncrypted = Synerise.Notifications.isNotificationEncrypted(payload)
var decryptedPayload
if (isNotificationEncrypted) {
decryptedPayload = Synerise.Notifications.decryptNotification(payload)
} else {
decryptedPayload = payload
}
Synerise.Notifications.handleNotification(decryptedPayload, actionIdentifier)
}
}
//...
})
})
```
The `Synerise.Notifications.decryptNotification(payload)` method returns raw data when the payload is not encrypted. If the operation fails, the method returns null.
### Handling actions from push notifications
---
- [Read more about types of actions in campaigns](/developers/mobile-sdk/campaigns/action-handling#types-of-actions-in-campaigns)
- [Read more about handling actions from push notifications](/developers/mobile-sdk/campaigns/action-handling#handling-actions-from-campaigns-in-react-native)
### Additional in-app alert from push notifications
---
The React Native SDK on iOS devices can display an additional alert in the application after a push notification is received. See [this article](/developers/mobile-sdk/campaigns/simple-push#additional-in-app-alert-when-simple-push-is-received) to read more about this feature.
Simple Push campaign with in-app alert
### Limitations compared to native platforms
---
Due to platform limitations, not all notification functionalities may work as in native SDKs.
# Client
### ClientIdentityProvider
**Declared In:**
lib/enums/client/identity_provider.dart
**Declaration:**
enum IdentityProvider {
synerise('SYNERISE'),
facebook('FACEBOOK'),
google('GOOGLE'),
oauth('OAUTH'),
apple('APPLE'),
unknown('UNKNOWN');
}
---
---
### ClientAuthContext
**Declared In:**
lib/model/client/client_auth_context.dart
**Related To:**
[ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements)
**Declaration:**
class ClientAuthContext
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **authId** | String | yes | null | Optional identifier of authorization |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements) | yes | null | Object that stores all agreements of a customer |
| **attributes** | HashMap | yes | null | Additional custom attributes of a customer |
**authId** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
**Initializers:**
ClientAuthContext({this.authId, this.agreements, this.attributes})
**Example:**
Dart
```Dart
ClientAuthContext clientAuthContext = ClientAuthContext(
authId: 'AUTH_ID',
agreements: agreements,
attributes: attributes
);
```
---
---
### ClientConditionalAuthContext
**Declared In:**
lib/model/client/client_conditional_auth_context.dart
**Related To:**
[ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements)
**Declaration:**
class ClientCondtitionalAuthContext {
**Properties:**
Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements) | yes | Object that stores all agreements of a customer |
| **attributes** | Map | yes | Additional custom attributes of a customer |
**Initializers:**
ClientCondtitionalAuthContext({this.agreements, this.attributes});
---
---
### ClientAccountInformation
Model representating the customer information.
This is a read-only class and it is not meant to be instantiated directly.
**Declared In:**
lib/model/client/client_account_information.dart
**Related To:**
[ClientSex](/developers/mobile-sdk/class-reference/flutter/client#clientsex)
[ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements)
**Declaration:**
class ClientAccountInformation
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **clientId** | int | no | Customer's ID |
| **email** | String | no | Customer's email |
| **phone** | String | yes | Customer's phone |
| **customId** | String | yes | Customer's custom ID |
| **uuid** | String | no | Customer's UUID |
| **firstName** | String | yes | Customer's first name |
| **lastName** | String | yes | Customer's last name |
| **displayName** | String | yes | Customer's display name |
| **sex** | [ClientSex](/developers/mobile-sdk/class-reference/flutter/client#clientsex) | no | Customer's sex |
| **company** | String | yes | Customer's company |
| **address** | String | yes | Customer's address |
| **city** | String | yes | Customer's city |
| **province** | String | yes | Customer's province |
| **zipCode** | String | yes | Customer's ZIP code |
| **countryCode** | String | yes | Customer's country code |
| **birthDate** | String | yes | Customer's birthdate |
| **lastActivityDate** | Date | no | Customer's last activity date |
| **avatarUrl** | String | yes | Customer's avatar URL |
| **anonymous** | bool | no | Customer's anonymous flag |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements) | no | Customer's agreements |
| **attributes** | HashMap | yes | Customer's attributes |
| **tags** | List | yes | Customer's tags |
---
---
### ClientAccountUpdateBasicInformationContext
**Declared In:**
lib/model/client/client_account_update_basic_information_context.dart
**Related To:**
[ClientSex](/developers/mobile-sdk/class-reference/flutter/client#clientsex)
[ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements)
**Declaration:**
class ClientAccountUpdateBasicInformationContext
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **firstName** | String | yes | Customer's first name |
| **lastName** | String | yes | Customer's last name |
| **displayName** | String | yes | Customer's display name |
| **sex** | [ClientSex](/developers/mobile-sdk/class-reference/flutter/client#clientsex) | yes | Customer's sex |
| **phone** | String | yes | Customer's phone number |
| **company** | String | yes | Customer's company |
| **address** | String | yes | Customer's address |
| **city** | String | yes | Customer's city |
| **province** | String | yes | Customer's province |
| **zipCode** | String | yes | Customer's ZIP code |
| **countryCode** | String | yes | Customer's country code |
| **birthDate** | String | yes | Customer's birthdate |
| **avatarUrl** | String | yes | Customer's avatar URL |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements) | yes | Customer's agreements |
| **attributes** | HashMap | yes | Customer's attributes |
**Initializers:**
ClientAccountUpdateBasicInformationContext({
this.firstName,
this.lastName,
this.displayName,
this.sex,
this.phone,
this.company,
this.address,
this.city,
this.province,
this.zipcode,
this.countrycode,
this.agreements,
this.attributes
});
**Example:**
Dart
```Dart
ClientAccountUpdateBasicInformationContext context = ClientAccountUpdateBasicInformationContext(
firstName: firstName,
lastName: lastName,
sex: sex,
phone: phone,
company: company,
address: address,
city: city,
province: province,
zipcode: zipcode,
countrycode: countrycode);
```
---
---
### ClientAccountUpdateContext
**Declared In:**
lib/model/client/client_account_update_context.dart
**Related To:**
[ClientSex](/developers/mobile-sdk/class-reference/flutter/client#clientsex)
[ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements)
**Declaration:**
class ClientAccountUpdateContext
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **email** | String | yes | Customer's email |
| **customId** | String | yes | Customer's custom ID |
| **uuid** | String | yes | Customer's UUID |
| **firstName** | String | yes | Customer's first name |
| **lastName** | String | yes | Customer's last name |
| **displayName** | String | yes | Customer's display name |
| **sex** | [ClientSex](/developers/mobile-sdk/class-reference/flutter/client#clientsex) | yes | Customer's sex |
| **phone** | String | yes | Customer's phone number |
| **company** | String | yes | Customer's company |
| **address** | String | yes | Customer's address |
| **city** | String | yes | Customer's city |
| **province** | String | yes | Customer's province |
| **zipCode** | String | yes | Customer's ZIP code |
| **countryCode** | String | yes | Customer's country code |
| **birthDate** | String | yes | Customer's birthdate |
| **avatarUrl** | String | yes | Customer's avatar URL |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements) | yes | Customer's agreements |
| **attributes** | HashMap | yes | Customer's attributes |
**Initializers:**
ClientAccountUpdateContext({
this.email,
this.customId,
this.uuid,
this.firstName,
this.lastName,
this.sex,
this.phone,
this.company,
this.address,
this.city,
this.province,
this.zipcode,
this.countrycode,
this.agreements,
this.attributes
});
**Example:**
Dart
```Dart
ClientAccountUpdateContext clientAccountUpdateContext = ClientAccountUpdateContext(
email: email,
firstName: firstName,
lastName: lastName,
sex: sex,
phone: phone,
company: company,
address: address,
city: city,
zipcode: zipcode,
countrycode: countrycode,
province: province);
```
---
---
### ClientAccountRegisterContext
**Declared In:**
lib/model/client/client_account_register_context.dart
**Related To:**
[ClientSex](/developers/mobile-sdk/class-reference/flutter/client#clientsex)
[ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements)
**Declaration:**
class ClientAccountRegisterContext
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **email** | String | no | Customer's email |
| **password** | String | no | Customer's password |
| **firstName** | String | yes | Customer's first name |
| **lastName** | String | yes | Customer's last name |
| **customId** | String | yes | Customer's custom ID |
| **sex** | [ClientSex](/developers/mobile-sdk/class-reference/flutter/client#clientsex) | yes | Customer's sex |
| **phone** | String | yes | Customer's phone |
| **company** | String | yes | Customer's company |
| **address** | String | yes | Customer's address |
| **city** | String | yes | Customer's city |
| **province** | String | yes | Customer's province code |
| **zipCode** | String | yes | Customer's ZIP code |
| **countryCode** | String | yes | Customer's country code |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements) | yes | Customer's agreements |
| **attributes** | HashMap | yes | Customer's attributes |
**Initializers:**
ClientAccountRegisterContext({
required this.email,
required this.password,
this.firstName,
this.lastName,
this.sex,
this.phone,
this.company,
this.address,
this.city,
this.zipcode,
this.countrycode,
this.province,
this.uuid,
this.customId,
this.agreements,
this.attributes
})
**Example:**
Dart
```Dart
ClientAccountRegisterContext clientAccountRegisterContext = ClientAccountRegisterContext(email: "EMAIL", password: "PASSWORD");
```
---
---
### ClientSimpleAuthenticationData
**Declared In:**
lib/model/client/client_simple_authentication_data.dart
**Related To:**
[ClientSex](/developers/mobile-sdk/class-reference/flutter/client#clientsex)
[ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements)
**Declaration:**
class ClientSimpleAuthenticationData
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **email** | String | yes | Customer's email |
| **phone** | String | yes | Customer's phone |
| **customId** | String | yes | Customer's custom ID |
| **uuid** | String | yes | Customer's UUID |
| **firstName** | String | yes | Customer's first name |
| **lastName** | String | yes | Customer's last name |
| **displayName** | String | yes | Customer's display name |
| **sex** | [ClientSex](/developers/mobile-sdk/class-reference/flutter/client#clientsex) | yes | Customer's sex |
| **company** | String | yes | Customer's company |
| **address** | String | yes | Customer's address |
| **city** | String | yes | Customer's city |
| **province** | String | yes | Customer's province |
| **zipCode** | String | yes | Customer's ZIP code |
| **countryCode** | String | yes | Customer's country code |
| **birthDate** | String | yes | Customer's birthdate |
| **avatarUrl** | String | yes | Customer's avatar URL |
| **agreements** | [ClientAgreements](/developers/mobile-sdk/class-reference/flutter/client#clientagreements) | yes | Customer's agreements |
| **attributes** | Map | yes | Customer's attributes |
**Initializers:**
ClientAccountUpdateContext({
this.email,
this.password,
this.firstName,
this.lastName,
this.sex,
this.phone,
this.company,
this.address,
this.city,
this.zipcode,
this.countrycode,
this.province,
this.uuid,
this.customId,
this.agreements,
this.attributes
});
---
---
### ClientSex
**Declared In:**
lib/enums/client/client_sex.dart
**Declaration:**
enum ClientSex {
notSpecified('NOT_SPECIFIED'),
male('MALE'),
female('FEMALE'),
other('OTHER');
}
---
---
### ClientAgreements
**Declared In:**
lib/model/client/client_agreements.dart
**Declaration:**
class ClientAgreements
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **email** | bool | no | Email agreement |
| **sms** | bool | no | SMS agreement |
| **push** | bool | no | Push notifications agreement |
| **bluetooth** | bool | no | Bluetooth agreement |
| **rfid** | bool | no | RFID agreement |
| **wifi** | bool | no | WIFI agreement |
**Initializers:**
ClientAgreements({this.email, this.sms, this.push, this.bluetooth, this.rfid, this.wifi})
---
---
### Token
**Declared In:**
lib/model/client/token.dart
**Related To:**
[TokenOrigin](/developers/mobile-sdk/class-reference/flutter/client#tokenorigin)
**Declaration:**
class Token
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **tokenString** | String | no | Token as a raw string |
| **origin** | [TokenOrigin](/developers/mobile-sdk/class-reference/flutter/client#tokenorigin) | no | Token's origin |
| **expirationDate** | DateTime | no | Token's expiration time |
---
---
### TokenOrigin
**Declared In:**
lib/enums/client/token_origin.dart
**Declaration:**
enum TokenOrigin {
synerise('SYNERISE'),
facebook('FACEBOOK'),
google('GOOGLE'),
oauth('OAUTH'),
apple('APPLE'),
simpleAuth('SIMPLE_AUTH'),
anonymous('ANONYMOUS'),
unknown('UNKNOWN');
}
---
---
### ClientConditionalAuthResult
**Declared In:**
lib/model/client/client_conditional_auth_result.dart
**Declaration:**
class ClientConditionalAuthResult
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **status** | [ClientConditionalAuthStatus](/developers/mobile-sdk/class-reference/flutter/client#clientconditionalauthstatus) | no | Status of the authentication |
| **conditions** | List | yes | Authentication conditions |
All properties are read-only.
---
---
### ClientConditionalAuthStatus
**Declared In:**
lib/enums/client/client_conditional_auth_status.dart
**Declaration:**
enum ClientConditionalAuthStatus {
success('SUCCESS'),
unauthorized('UNAUTHORIZED'),
activationRequired('ACTIVATION_REQUIRED'),
registrationRequired('REGISTRATION_REQUIRED'),
approvalRequired('APPROVAL_REQUIRED'),
termsAcceptanceRequired('TERMS_ACCEPTANCE_REQUIRED'),
mfaRequired('MFA_REQUIRED');
}
**Functions:**
Converts from **ClientConditionalAuthStatus** to **String**.
Dart
```Dart
String getClientConditionalAuthStatusAsString() {
```
---
Converts from **String** to **ClientConditionalAuthStatus**.
Dart
```Dart
static ClientConditionalAuthStatus? getClientConditionalAuthStatusFromString(String string) {
```
---
---
### ClientSignOutMode
**Declared In:**
lib/enums/client/client_sign_out_mode.dart
**Declaration:**
enum ClientSignOutMode {
signOut('SIGN_OUT'),
signOutWithSessionDestroy('SIGN_OUT_WITH_SESSION_DESTROY');
**Functions:**
Converts from **ClientSignOutMode** to **String**.
Dart
```Dart
String clientSignOutModeAsString() {
```
---
Converts from **String** to **ClientSignOutMode**.
Dart
```Dart
static ClientSignOutMode? getClientSignOutModeFromString(String string) {
```
# React Native
## Installation and configuration (React Native)
In this article, you will find out how to install and initialize the Synerise SDK in a React Native mobile application. While performing the actions from this guide, keep the presented order presented.
The [Settings](/developers/mobile-sdk/settings#pre-initialization-settings) article contains additional information about SDK behaviors you may need prior to configuration.
### Requirements
---
You need:
* Access to a [workspace](/docs/settings/workspace)
* A Profile [API Key](/docs/settings/tool/api#adding-api-keys)
When creating the API key, use allowlisting or denylisting to only allow the events you intend to use.
#### Android {id=requirements-android}
* Recommended environment:
- Minimum Android SDK version - 24
- Supported targetSDKVersion - 34
#### iOS {id=requirements-ios}
* Recommended environment:
- Xcode 16
- iOS SDK 18
* Target deployment:
- **iOS 13.0+** for SDK versions 1.0.0 and higher
- **iOS 9.0+** for SDK versions lower than 1.0.0
Bitcode is not supported in SDK version 1.0.0 and higher. Xcode ignores bitcode.
### Setting up Android
---
1. Install the module with npm:
npm install react-native-synerise-sdk --save
2. Install dependencies:
- **React Native 0.60 or lower:** In your `android` build.gradle top-level build file, add:
...
allprojects {
repositories {
google()
jcenter()
maven { url 'https://pkgs.dev.azure.com/Synerise/AndroidSDK/_packaging/prod/maven/v1' }
}
}
- **React Native newer than 0.60**: Link the native dependency:
react-native link react-native-synerise-sdk
1. **If you DON'T use autolinking**: In your app's `build.gradle` file, add the following dependency: `implementation 'com.synerise.sdk.react:react-native-synerise-sdk:RN_SDK_VERSION'`
where `RN_SDK_VERSION` is the SDK version. You can check the latest version in our [Github repository](https://github.com/Synerise/react-native-synerise-sdk/blob/master/CHANGELOG.md).
Doing this together with autolinking causes a build error.
2. In the app's main class, to your list of packages, add `RNSyneriseSdkPackage`
Java
```Java
@Override
protected List getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List packages = new PackageList(this).getPackages();
packages.add(new RNSyneriseSdkPackage());;
return packages;
}
```
### Setting up iOS
---
Starting from React Native 0.60, CocoaPods is the default integration approach for React Native iOS projects.
1. Install the module with npm:
npm install react-native-synerise-sdk --save
2. Install dependencies:
- **React Native 0.60 or lower**: Install the native dependencies by using CocoaPods from your `ios` directory:
pod install
- **React Native newer than 0.60**:
1. Link the native dependency.
react-native link react-native-synerise-sdk
1. Install from your iOS:
pod install --repo-update
1. In your `ios/Podfile`, add the following dependency: `pod 'react-native-synerise-sdk', :path => '../node_modules/react-native-synerise-sdk'`
**Result**: Your Podfile looks as follows:
target 'YourTarget' do
# Pods for your target
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
# ... other React dependencies
# Add react-native-synerise-sdk
pod 'react-native-synerise-sdk', :path => '../node_modules/react-native-synerise-sdk'
use_native_modules!
end
3. From your `ios` directory, run `pod install`
If you prefer linking manually, check [React Native - Linking Libraries](https://reactnative.dev/docs/linking-libraries-ios/#manual-linking) to link your libraries that contain native code.
### Initialization
---
When you use the **react-native-synerise-sdk** module, use the following native **Synerise SDK** frameworks:
- [Android](/developers/mobile-sdk/installation-and-configuration/android)
- [iOS](/developers/mobile-sdk/installation-and-configuration/ios)
#### Importing Synerise SDK
You will need to import the **Synerise** object from the **react-native-synerise-sdk** module.
JavaScript
```JavaScript
import { Synerise } from 'react-native-synerise-sdk';
```
You must always import suitable objects from the **react-native-synerise-sdk** module into the files that contain the code that relates to the Synerise SDK.
#### Basic initialization
Initialize the Synerise SDK and provide the [Profile API Key](/docs/settings/tool/api).
You may initialize it wherever you want and when you need.
JavaScript
```JavaScript
Synerise.Initializer()
.withApiKey('YOUR_PROFILE_API_KEY') // 1
.withRequestValidationSalt('YOUR_REQUEST_VALIDATION_SALT') // 2
.withDebugModeEnabled(false) // 3
.withCrashHandlingEnabled(true) // 4
.init();
```
1. `.withApiKey('YOUR_PROFILE_API_KEY')` - Sets Profile API Key for Synerise SDK initialization.
2. `.withRequestValidationSalt('YOUR_REQUEST_VALIDATION_SALT')` - Sets salt string for request validation.
3. `.withDebugModeEnabled(false)` - Enables debug mode. See [Debug mode](/developers/mobile-sdk/installation-and-configuration/react-native#debug-mode) section for more information.
4. `.withCrashHandlingEnabled(true)` - Enables crash handling. Synerise SDK sends a crash event automatically when an uncaught exception occurs.
#### Initialization with custom API environment
You can change the base URL of the API for on-premise installations.
Use the following initialization method:
JavaScript
```JavaScript
Synerise.Initializer()
.withApiKey('YOUR_PROFILE_API_KEY')
.withBaseUrl("YOUR_API_BASE_URL")
.init();
```
#### Advanced initialization
This is an example of advanced initialization with:
- custom API base URL for on-premise installations
- request validation salt configured
- debug mode enabled
- crash handling enabled
- most settings options available
- initialization listeners set
Secure sensitive keys (for example, `clientApiKey` and `requestValidationSalt`) with mechanisms like string obfuscation or encryption.
JavaScript
```JavaScript
Synerise.Initializer()
.withBaseUrl("YOUR_API_BASE_URL")
.withApiKey('YOUR_PROFILE_API_KEY')
.withRequestValidationSalt('YOUR_REQUEST_VALIDATION_SALT')
.withDebugModeEnabled(true)
.withCrashHandlingEnabled(true)
.withSettings({
sdk: {
enabled: true,
minTokenRefreshInterval: 5000,
shouldDestroySessionOnApiKeyChange: true
},
notifications: {
enabled: true,
encryption: false,
},
injector: {
automatic: true,
},
tracker: {
isBackendTimeSyncRequired: true,
minBatchSize: 20,
maxBatchSize: 30,
autoFlushTimeout: 60
}
})
.init();
Synerise.onReady(function() {
// This function is called when Synerise is fully initialized and ready.
});
Synerise.onError(function(error) {
// This function is called when an error occurs during Synerise initialization.
});
```
### Debug mode
---
You can enable debug logs for Synerise SDK by using the `.withDebugModeEnabled(true)` method in `Synerise.Initializer` when you initialize the SDK.
Do not use debug mode in a release version of your application.
You can receive logs about:
- **Core**: push notifications
- **Tracker**: auto-tracked events, declarative events, sending process
- **Client**: customer state, authorization
- **Injector**: campaigns
- **Promotions**: promotions, vouchers
- **Content**: content widget, documents, recommendations
### Main Synerise listeners
---
You can handle Synerise SDK initialization result by two listener methods:
- `Synerise.onReady()` - This method is called when Synerise is initialized.
- `Synerise.onError(error: Error)` - This method is called when an error occurs during Synerise initialization.
You can specify your custom action when a customer clicks a simple push, banner or walkthrough. Synerise SDK implements two main actions that a customer may invoke - open URL and Deeplink:
- `IInjectorListener.onOpenUrl(url: string)` - This method is called when Synerise handles the open URL action from campaign activities.
- `IInjectorListener.onDeepLink(deepLink: string)` - This method is called when Synerise handles the deeplink action from campaign activities.
For more information about handling actions from the Synerise SDK, see the [Campaigns](/developers/mobile-sdk/campaigns/action-handling#handling-actions-from-campaigns-in-react-native) section.
When you want to deal with Push Notifications:
- `INotificationsListener.onRegistrationToken?(token: string)` - This method is called when a native part of the application passes a registration token.
- `INotificationsListener.onRegistrationRequired?()` - This method is called when Synerise needs registration for Push Notifications.
- `INotificationsListener.onNotification(payload: object)` - This method is called when a native part of the application passes a notification payload.
- For more information about notifications in Android SDK, see [Configuring push notifications](/developers/mobile-sdk/configuring-push-notifications/android) section.
- For more information about notifications in iOS SDK, see [Configuring push notifications](/developers/mobile-sdk/configuring-push-notifications/ios) section.
- For more information about SDK listeners and delegates, see [Listeners and delegates](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners) section.
# Flutter
## Installation and configuration (Flutter)
In this article you will find out how to install and initialize SDK in a Flutter mobile application. While performing the actions from this guide, keep the order presented in this article.
The [Settings](/developers/mobile-sdk/settings#pre-initialization-settings) article contains additional information about SDK behaviors you may need prior to configuration.
### Requirements
You need:
* Access to [workspace](/docs/settings/workspace)
* A Profile [API Key](/docs/settings/tool/api#adding-api-keys)
When creating the API key, use allowlisting or denylisting to only allow the events you intend to use.
* Flutter configured on your machine - [Getting Started](https://docs.flutter.dev)
* VS Code / Android Studio / Xcode
### Android{id=requirements-android}
For the **Android** platform it uses the [Synerise Android SDK](https://github.com/Synerise/android-sdk).
The development and debugging can be done with Android Studio.
* Recommended environment:
- Minimum Android SDK version - 24
- Supported targetSDKVersion - 34
### iOS {id=requirements-ios}
For the **iOS** platform it uses the [Synerise iOS SDK](https://github.com/Synerise/synerise-ios-sdk).
The development and debugging can be done with Xcode.
* Recommended environment:
- Xcode 16
- iOS SDK 18
* Target deployment:
* iOS 13.0+ for SDK versions 2.0.0 and higher
* iOS 9.0+ for SDK versions lower than 2.0.0
---
### Installation
#### CLI
```shell
$ flutter pub add synerise_flutter_sdk
```
This will add a line similar to this to your package's `pubspec.yaml` and run an implicit `flutter pub get`:
```yaml
dependencies:
synerise_flutter_sdk: ^0.7.4
```
Alternatively, your editor might support `flutter pub get`. Check the docs for your editor to learn more.
#### Path dependency
First you will need to add the Synerise Flutter SDK to your mobile application. To do that you can use the path dependency method in your `pubspec.yaml` as follows:
via ssh:
```yaml
synerise_flutter_sdk:
git:
url: git@github.com:Synerise/synerise-flutter-sdk.git
```
or
via https:
```yaml
synerise_flutter_sdk:
git:
url: https://github.com/Synerise/synerise-flutter-sdk.git
```
After that you can run `flutter pub get` to resolve the new dependency.
---
#### Importing Synerise SDK
You will need to import **Synerise.dart** from the **synerise_flutter_sdk** plugin.
Dart
```Dart
import 'package:synerise_flutter_sdk/synerise.dart';
```
### Android gradle & configuration
1. In the Android part of your application, add
``maven { url 'https://pkgs.dev.azure.com/Synerise/AndroidSDK/_packaging/prod/maven/v1' }``
to the `android/build.gradle`:
2. Make sure you included the following repositories:
``
google()
mavenCentral()
``
The whole build.gradle snippet must look as follows:
```groovy
repositories {
google()
mavenCentral()
maven { url 'https://pkgs.dev.azure.com/Synerise/AndroidSDK/_packaging/prod/maven/v1' }
}
```
then in your MainActivity file add:
Dart
```Dart
public class MainActivity extends FlutterActivity {
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
super.configureFlutterEngine(flutterEngine);
SyneriseMethodChannel.configureChannel(flutterEngine);
}}
```
### iOS configuration
In iOS portion of your application (/ios) you will need to run
`pod update`
### Initialization
---
#### Basic initialization
Initialize the Synerise SDK and provide the [Profile API Key](/docs/settings/tool/api).
Initialize Synerise SDK in the application workflow as early as possible.
Dart
```Dart
Synerise.initializer()
.withApiKey("YOUR_PROFILE_API_KEY") // 1
.setRequestValidationSalt("YOUR_REQUEST_VALIDATION_SALT") // 2
.withDebugModeEnabled(false) // 3
.withCrashHandlingEnabled(true) // 4
.setMessagingServiceType(MessagingServiceType.SERVICE_TYPE) // 5
.init();
```
1. `.withApiKey('YOUR_PROFILE_API_KEY')` - Sets Profile API Key for Synerise SDK initialization.
2. `.withRequestValidationSalt('YOUR_REQUEST_VALIDATION_SALT')` - Sets salt string for request validation.
3. `.withDebugModeEnabled(false)` - Enables debug mode. See [Debug mode](/developers/mobile-sdk/installation-and-configuration/react-native#debug-mode) section for more information.
4. `.withCrashHandlingEnabled(true)` - Enables crash handling. Synerise SDK sends a crash event automatically when an uncaught exception occurs.
5. `.setMessagingServiceType(MessagingServiceType.SERVICE_TYPE)` - defines the messaging services your app uses:
- `gms` for Google Mobile Services. This is the default option.
- `hms` for Huawei Mobile Services. This can only be used on Huawei devices.
Secure sensitive keys (for example, `apiKey` and `requestValidationSalt`) with mechanisms like string obfuscation or encryption.
#### Initialization with custom API environment
You can change the base URL of the API for on-premise installations.
Use the following initialization method:
Dart
```Dart
Synerise.initializer()
.withApiKey('YOUR_PROFILE_API_KEY')
.withBaseUrl("YOUR_API_BASE_URL")
.init();
```
### Running example app
- Open project folder in selected IDE
- `flutter pub get` in the terminal (dependencies pull)
- select the device/emulator in your IDE (for ios part it is required to run `pod update` in example/ios directory)
- `cd example` and `flutter run`
### Debug mode
---
You can enable debug logs for Synerise SDK by using the `.withDebugModeEnabled(true)` method in `Synerise.initializer` when you initialize the SDK.
Do not use debug mode in a release version of your application.
You can receive logs about:
- **Core**: push notifications
- **Tracker**: declarative events, sending process
- **Client**: customer state, authorization
- **Injector**: campaigns
- **Content**: content widget, documents, recommendations
### Main Synerise listeners
---
#### Injector Listeners
You can specify your custom action when a customer clicks on simple push, banner or walkthrough. Synerise SDK implements two main actions that a customer may invoke - open URL and Deeplink:
- listener.onOpenUrl = (url) - This method is called when Synerise handles URL action from campaign activities.
- listener.onDeepLink = (deepLink) - This method is called when Synerise handles deeplink action from campaign activities.
Note: For more information about handling actions from the Synerise SDK, see the Campaigns section.
Dart
```Dart
Synerise.injector.listener((listener) {
listener.onOpenUrl = (url) {
...
};
listener.onDeepLink = (deepLink) {
...
};
});
### Notifications Listeners
When you want to deal with Push Notifications:
- listener.onRegistrationRequired - This method is called when Synerise needs registration for Push Notifications.
Synerise.notifications.listener((listener) {
listener.onRegistrationRequired = () {
FirebaseMessaging.instance.getToken().then((value) {
if (value != null) {
Synerise.notifications.registerForNotifications(value, true);
}
});
};
});
```
# Campaigns
### SyneriseSource
This enum contains values which describe the source of campaign.
**Declared In:**
`com.synerise.sdk.injector.callback.SyneriseSource`
**Declaration:**
Java Kotlin
```Java
public enum SyneriseSource
```
```Kotlin
public enum SyneriseSource
```
**Values:**
| Property | Description |
| --- | --- |
| **SIMPLE_PUSH** | Simple push campaign |
| **IN_APP_MESSAGE** | In-app message campaign |
---
---
### Campaign
Class model for campaigns.
**Declared In:**
`com.synerise.sdk.injector.net.model.Campaign`
**Declaration:**
Java Kotlin
```Java
public class Campaign implements Serializable
```
```Kotlin
class Campaign : Serializable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **hashId** | String | no | - | Campaign hash ID |
| **variantId** | int | no | - | Campaign variant's ID |
| **title** | String | no | - | Campaign title |
| **type** | String | no | - | Campaign type |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method retrieves a value for the `hashId` parameter.
public String getHashId()
---
This method retrieves a value for the `variantId` parameter.
public int getVariantId()
---
This method retrieves a value for the `title` parameter.
public String getTitle()
---
This method retrieves a value for the `type` parameter.
public String getType()
---
---
---
### SynerisePushResponse
Class model for SynerisePushResponse.
**Declared In:**
`com.synerise.sdk.injector.net.model.push.notification.SynerisePushResponse`
**Declaration:**
Java Kotlin
```Java
public class SynerisePushResponse
```
```Kotlin
class SynerisePushResponse
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **contentAvailable** | Boolean | no | - | Informs if content is available |
| **data** | SynerisePush | no | - | Synerise push data |
| **notification** | [SimpleNotification](/developers/mobile-sdk/class-reference/android/campaigns#simplenotification) | no | - | Synerise simple notification |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method checks if content is available.
public boolean isContentAvailable()
---
This method retrieves a value for the `data` parameter.
public SyneriseData getData()
---
This method retrieves a value for the `notification` parameter.
public SimpleNotification getNotification()
---
This method checks if the push is a simple push.
public boolean isSimplePush()
---
---
---
### SimpleNotification
Class model for simple notification.
**Declared In:**
`com.synerise.sdk.injector.net.model.push.notification.SimpleNotification`
**Declaration:**
Java Kotlin
```Java
public class SimpleNotification implements Serializable
```
```Kotlin
class SimpleNotification : Serializable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **title** | String | no | - | Notification title |
| **body** | String | no | - | Notification body |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method checks if the notification has a title.
public boolean hasTitle()
---
This method retrieves a value for the `title` parameter (notification title).
public String getTitle()
---
This method checks if the notification has a body.
public boolean hasBody()
---
This method retrieves a value for the `body` parameter (notification body).
public String getBody()
---
---
---
### NotificationInfo
This enum contains values for a voucher code status.
**Declared In:**
`com.synerise.sdk.injector.callback.model`
**Declaration:**
Java Kotlin
```Java
public class NotificationInfo
```
```Kotlin
public class NotificationInfo
```
#### Values
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **campaignHashId** | String | no | - | Identifier of the notification campaign. |
| **campaignTitle** | String | no | - | Identifier of the notification title. |
| **payload** | HashMap | no | - | Payload of the notification. |
**Methods:**
This method retrieves the value of the `campaignHashId` parameter.
public String getCampaignHashId()
---
This method defines the value of the `campaignHashId` parameter.
public void setCampaignHashId(String campaignHashId)
---
This method retrieves the value of the `CampaignTitle` parameter.
public String getCampaignTitle()
---
This method defines the value of the `CampaignTitle` parameter.
public void setCampaignTitle(String campaignTitle)
---
This method retrieves the contents of the `payload` parameter.
public HashMap<String, String> getPayload()
---
This method defines the contents of the `payload` parameter.
public void setPayload(HashMap<String, String> payload)
---
---
---
### PushRegistrationOrigin
This enum contains values for the `origin` parameter of push registration listener methods.
**Declared In:**
`com.synerise.sdk.core.types.enums`
**Declaration:**
Java Kotlin
```Java
public enum PushRegistrationOrigin
```
```Kotlin
public enum PushRegistrationOrigin
```
**Values:**
| Property | Value | Description |
| --- | --- | --- |
| **APP_STARTED** | "APP_STARTED" | After a `client.applicationStarted` event is sent. |
| **CLIENT_CONTEXT_CHANGE** | "CLIENT_CONTEXT_CHANGE" | After the client context changes. |
| **PERIODIC_JOB** | "PERIODIC_JOB" | After a periodic job of a background task starts. |
| **SECURITY_REASON** | "SECURITY_REASON" | After a security threat |
**Methods:**
There are no methods.
---
---
---
### TemplateBanner
Class model for banners.
**Declared In:**
`com.synerise.sdk.injector.net.model.push.banner.TemplateBanner`
**Declaration:**
Java Kotlin
```Java
public class TemplateBanner extends BasePageMapper implements Parcelable, Validable
```
```Kotlin
class TemplateBanner : BasePageMapper(), Parcelable, Validable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **campaign** | [Campaign](/developers/mobile-sdk/class-reference/android/campaigns#campaign) | no | - | Campaign class |
| **trigger** | String | yes | - | Banner trigger |
| **notification** | [SimpleNotification](/developers/mobile-sdk/class-reference/android/campaigns#simplenotification) | no | - | Notification class |
| **autoDisappear** | [AutoDisappear](/developers/mobile-sdk/class-reference/android/campaigns#autodisappear) | no | - | Auto disappear |
| **page** | NetGenericPageData | yes | - | Page data |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method retrieves the value of the `campaign` parameter.
public Campaign getCampaign()
---
This method retrieves the value of the `value` object.
public Object getValue()
---
This method checks if a banner has a trigger.
public boolean hasTrigger()
---
This method retrieves the `trigger` parameter from a banner.
public String getTrigger()
---
This method retrieves the value of the `notification` parameter.
public SimpleNotification getNotification()
---
This method retrieves the value of the `page` parameter.
public PageItem getPage()
---
This method retrieves the value of the `autodisappear` parameter.
public AutoDisappear getAutoDisappear()
---
---
---
### SilentCommand
Class model for silent command.
**Declared In:**
`com.synerise.sdk.injector.SilentCommand`
**Declaration:**
Java Kotlin
```Java
public class SilentCommand implements Validable
```
```Kotlin
class SilentCommand : Validable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **className** | String | no | - | Class name |
| **methodName** | String | no | - | Method name |
| **methodParameterList** | List<[MethodParameter](/developers/mobile-sdk/class-reference/android/campaigns#methodparameter)> | no | - | Method parameters |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method retrieves a value of the `className` parameter.
public String getClassName()
---
This method retrieves a value of the `methodName` parameter.
public String getMethodName()
---
This method retrieves a list of values of the `methodParameters` parameter.
public List<MethodParameter> getMethodParameterList()
---
---
---
### MethodParameter
Class model for method parameter.
**Declared In:**
`com.synerise.sdk.injector.MethodParameter`
**Declaration:**
Java Kotlin
```Java
public class MethodParameter implements Validable
```
```Kotlin
class MethodParameter : Validable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **className** | String | no | - | Class name |
| **value** | Object | no | - | Parameter value |
| **position** | int | no | - | Parameter position |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method retrieves a value of the `className` parameter.
public String getClassName()
---
This method retrieves a value of the `value` parameter.
public Object getValue()
---
This method retrieves a value of the `position` parameter.
public int getPosition()
---
---
---
### AutoDisappear
Class model for AutoDisappear.
**Declared In:**
`com.synerise.sdk.injector.net.model.push.model.banner.AutoDisappear`
**Declaration:**
Java Kotlin
```Java
public class AutoDisappear implements Serializable
```
```Kotlin
class AutoDisappear : Serializable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **isEnabled** | Boolean | no | - | Informs if auto disappear is enabled |
| **timeout** | int | no | - | Disappear timeout |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method checks if auto disappear is enabled.
public boolean isEnabled()
---
This method retrieves the value of the `timeout` parameter.
public int getTimeout()
---
---
---
### InAppMessageData
Model for in-app messaging communication.
**Declared In:**
com.synerise.sdk.injector.inapp.InAppMessageData
**Declaration:**
Java Kotlin
```Java
public InAppMessageData(String campaignHash, String variantId, HashMap additionalParameters, Boolean isTest)
```
```Kotlin
public InAppMessageData(campaignHash: String, variantId: String, additionalParameters: HashMap , isTest: Boolean)
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **campaignHash** | String | no | Identifier of the in-app message campaign. | | **variantId** | String | no | Identifier of the in-app message campaign variant. |
| **additionalParameters** | HashMap | yes | Parameters additionally provided by the campaign. | | **url** | URL | yes | URL value from the action of the activity. |
| **deeplink** | String | yes | Deep link value from the action of the activity. | | **isTest** | Bool | no | Specifies if the object is from a test campaign. |
All the properties above are accessible by using getters.
**Methods:**
There are only getters for the above properties.
---
---
### SyneriseMethod
Enum with a list of SDK methods that can be called from JavaScript in an in-app.
See [Using in-app template builder](/docs/campaign/in-app-messages/creating-inapp-templates/creating-inapp-template#use-a-mobile-sdk-method)
# Customer session
---
## 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> refreshToken({required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.refreshToken(onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<bool> refreshToken() async
**Return Value:**
**true** if the operation is success, otherwise it throws an error.
**Example:**
await Synerise.client.refreshToken().catchError((error)
## 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:**
lib/modules/client/client_impl.dart
**Related To:**
[Token](/developers/mobile-sdk/class-reference/flutter/client#token)
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> retrieveToken({required void Function(Token) onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Description |
| --- | --- | --- | --- |
| **onSuccess** | Function([Token](/developers/mobile-sdk/class-reference/flutter/client#token) token) | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.retrieveToken(onSuccess: (Token token) {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<Token> retrieveToken() async
**Return Value:**
[Token](/developers/mobile-sdk/class-reference/flutter/client#token)
**Example:**
Token token = await Synerise.client.retrieveToken().catchError((error)
## Get current customer UUID
---
This method retrieves the customer’s current UUID.
**Declared In:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<String> getUUID() async
**Return Value:**
String
**Example:**
await Synerise.client
.getUUID()
.then((result) => {
//result handling
});
**Declaration:**
Future<String> getUUID() async
**Return Value:**
String
**Example:**
String uuid = await Synerise.client.getUUID().catchError((error)
## 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
**Declaration:**
Future<void> regenerateUUID() async
**Return Value:**
No value is returned.
**Example:**
await Synerise.client
.regenerateUUID()
.then((result) => {
//result handling
});
## 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
**Declaration:**
Future<void> regenerateUUIDWithClientIdentifier(String clientIdentifier) async
**Parameters:**
| Parameter | Type | Mandatory | 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.
**Example:**
await Synerise.client
.regenerateUUIDWithClientIdentifier(clientIdentifier)
.then((result) => {
//result handling
});
## 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:**
lib/modules/client/client_impl.dart
**Class:**
[ClientImpl](/developers/mobile-sdk/class-reference/flutter/modules#client)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> destroySession({required void Function() onSuccess, required void Function(SyneriseError) onError}) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.destroySession(onSuccess: () {
//onSuccess handling
}, onError: (SyneriseError error) {
//onError handling
});
**Declaration:**
Future<void> destroySession() async
**Return Value:**
No value is returned.
**Example:**
await Synerise.client.destroySession().catchError((error)
# Customer session
---
## 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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public refreshToken(onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.refreshToken(function(token) {
// success
}, function(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:**
lib/main/modules/ClientModule.js
**Related To:**
[Token](/developers/mobile-sdk/class-reference/react-native/client#token)
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public retrieveToken(onSuccess: (token: Token) => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.retrieveToken(function(token) {
// success
}, function(error) {
// failure
});
```
## Get current customer UUID
---
This method retrieves the customer’s current UUID.
**Declared In:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public getUUID(): string
**Return Value:**
The method returns the customer's UUID as string.
**Example:**
JavaScript
```JavaScript
let uuid = Synerise.Client.getUUID();
```
## 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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public regenerateUUID()
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.regenerateUUID();
```
## 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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public regenerateUUIDWithClientIdentifier(clientIdentifier: string)
**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:**
lib/main/modules/ClientModule.js
**Class:**
[ClientModule](/developers/mobile-sdk/class-reference/react-native/modules#client)
**Declaration:**
public destroySession()
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Client.destroySession();
```
# Campaigns
### SyneriseSource
**Declared In:**
lib/classes/models/Misc/SyneriseSource.js
**Declaration:**
enum SyneriseSource {
NotSpecified = 'NOT_SPECIFIED',
SimplePush = 'SIMPLE_PUSH',
Banner = 'BANNER',
Walkthrough = 'WALKTHROUGH',
InAppMessage = 'IN_APP_MESSAGE'
}
**Functions:**
Converts from **SyneriseSource** to **string**.
function SyneriseSourceToString(source: SyneriseSourceToString): string
---
Converts from **string** to **SyneriseSource**.
function SyneriseSourceFromString(string: string): SyneriseSource
---
---
### InAppMessageData
Model representing an in-app message data.
This is a read-only class and it is not meant to be instantiated directly.
**Declared In:**
lib/classes/models/Misc/InAppMessageData.js
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class InAppMessageData extends BaseModel
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **campaignHash** | string | no | Identifier of the in-app message campaign. |
| **variantIdentifier** | string | no | Identifier of the in-app message campaign variant. |
| **additionalParameters** | Object | yes | Parameters additionally provided by the campaign. |
| **isTest** | boolean | no | Specifies if the object is from a test campaign. |
# Flutter
## Method reference - Flutter
# Configuring push notifications
In this section, you will learn how to implement push notifications in your mobile application.
# Flutter
## Flutter listeners
#### NotificationsListener {id=notifications-listener}
A listener to handle actions from the notifications module.
Dart
```Dart
Synerise.notifications.listener((listener) {
// The following method is called when registration for Push Notifications is needed.
listener.onRegistrationRequired = () {
...
};
});
```
After invoking **onRegistrationRequired()** function, you must invoke the [Synerise.notifications.registerForNotifications(registrationToken, mobileAgreement)](/developers/mobile-sdk/method-reference/flutter/campaigns#register-for-push-notifications) method again.
---
---
#### InjectorListener {id=injector-listener}
A listener to handle URL and deeplink actions from the injector module.
Dart
```Dart
Synerise.injector.listener((listener) {
// The following method is called when Synerise handles URL action from campaign activities
// It is required function
listener.onOpenUrl = (url) {
...
};
// The following method is called when Synerise handles deep link action from campaign activities
// It is required function
listener.onDeepLink = (deepLink) {
...
};
});
```
---
---
#### InjectorInAppMessageListener {id=injector-in-app-message-listener}
A listener to handle the states of [in-app messages](/developers/mobile-sdk/campaigns/in-app-message).
Dart
```Dart
Synerise.injector.inAppMessageListener((listener) {
// The following method is called after an in-app message appears
listener.onPresent = (data) {
...
};
// The following method is called after an in-app message disappears
listener.onHide = (data) {
...
};
// This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
listener.onOpenUrl = (data, url) {
...
};
// This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
listener.onDeepLink = (data, deepLink) {
...
};
// This method is called when the
// SRInApp.handleCustomAction(name, params) method is used in an in-app message.
listener.onCustomAction = (data, name, parameters) {
...
};
})
```
---
---
### InjectorWalkthroughListener {id=injector-walkthrough-listener}
**InjectorWalkthroughListener** was removed in SDK version 2.0.0.
---
---
### InjectorBannerListener {id=injector-banner-listener}
**InjectorBannerListener** was removed in SDK version 2.0.0.
# Flutter
## Configuring push notifications (Flutter)
### Prerequisites
---
#### Firebase Cloud Messaging
Google Firebase Cloud Messaging is necessary to handle [push notifications](/docs/campaign/Mobile) sent from Synerise.
1. Follow the instructions in [this article](https://firebase.google.com/docs/flutter/setup) and integrate the Firebase plugin with your application.
2. Follow the instructions in [this article](https://firebase.flutter.dev/docs/messaging/overview/) and integrate cloud messaging in your application.
3. Integrate Firebase with Synerise. See [Integration](/docs/settings/tool/firebase) section.
It's important that the Firebase plugin is initialized as early as possible in the application lifecycle and also after the Synerise SDK. Late initialization may cause compilation problems.
### Setting up - Android {id=setting-up-android}
---
#### Requirements {id=android-requirements}
1. After configuring Firebase, add the `google-services.json` file to your project.
2. Add the google-services dependency to your project's `build.gradle` file.
dependencies {
...
classpath 'com.google.gms:google-services:4.3.3'
...
}
### Setting up - iOS {id=setting-up-ios}
---
#### Requirements {id=ios-requirements}
1. Configure handling Push Notifications in your application. See [Apple Notifications](https://developer.apple.com/notifications/).
2. After configuring Firebase, add the `GoogleService-Info.plist` file to your project.
3. Make sure your `Info.plist` file contains the following snippet:
```xml
FirebaseAppDelegateProxyEnabled
```
#### Extensions for push notifications {id=ios-extensions-for-push-notifications}
##### Notification Service Extension {id=synerise-notification-service-extension-for-ios}
**Synerise Notification Service Extension** is an object that adds the notification functionality to the SDK.
It implements the following operations:
- Decrypting **Simple Push** communication data (if encryption is enabled).
- Tracking events from **Simple Push** communication.
- Adding action buttons to **Simple Push** communication (if the communication contains any).
- Improving the appearance of **Simple Push** communication (Rich Media - Single Image) with an image thumbnail.
**Notification Service Extension** should be implemented in the native part of the application. Follow the instructions in [this article](/developers/mobile-sdk/configuring-push-notifications/ios#synerise-notification-service-extension-configuration).
##### Rich Media Notification Content Extensions {id=synerise-notification-content-extension-for-ios}
**Synerise Rich Media Notification Content Extension** is an object that allows rendering your own appearance of a push notification when the notification is expanded (by tapping the notification).
**Synerise Rich Media Notification Content Extensions** should be implemented in the native part of the application. Follow the instructions in [this article](/developers/mobile-sdk/configuring-push-notifications/ios#rich-media-in-push-notifications).
### Set up Firebase Cloud Messaging for Synerise SDK
---
The following code example explains how to implement Firebase Cloud Messaging integration with Synerise:
1. Define a top-level function for handling notifications when the app is in the terminated state.
2. Request permissions from the user.
3. Set presentation options for foreground state.
4. Get Firebase FCM token and set it to deliver push notifications from Synerise.
5. Make sure that the Firebase FCM token is always up-to-date.
6. Set Firebase listener method for handling notifications when the app is in the foreground.
7. Set Firebase listener method for handling notification clicks when the app is in the background.
8. Invoke method for handling notification clicks when a user opens a notification in the app’s closed state.
Dart
```Dart
class InitialViewState extends State {
@override
void initState() {
// Initialize Synerise SDK
initializeSynerise();
// Setup notifications with Firebase
setupNotifications();
// 8. Invoke method for handling notification clicks when a user opens a notification in the app’s closed state (see below for definition of the method).
checkForInitialNotificationMessage();
super.initState();
}
Future initializeSynerise() async {
Synerise.initializer()
.withApiKey('YOUR_PROFILE_API_KEY')
.withBaseUrl("YOUR_API_BASE_URL")
.withDebugModeEnabled(true)
.init();
}
Future setupNotifications() async {
await Firebase.initializeApp();
// 1. Define a top-level function for handling notifications when the app is in the terminated state (see below for definition of the method).
FirebaseMessaging.onBackgroundMessage(backgroundHandlerForFCM);
// 2. Request permissions from the user
await FirebaseMessaging.instance.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
// 3. Set presentation options for the foreground state
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
// 4. Get Firebase FCM token and set it to deliver push notifications from Synerise
FirebaseMessaging.instance.getToken().then((token) {
if (token != null) {
Synerise.notifications.registerForNotifications(token, true);
}
});
// 5. Make sure that the Firebase FCM token is always up-to-date
FirebaseMessaging.instance.onTokenRefresh.listen((event) {
FirebaseMessaging.instance.getToken().then((token) {
if (token != null) {
Synerise.notifications.registerForNotifications(
firebaseToken!,
mobileAgreement: true, // true or false, should depend on device permissions and customer's agreement in the application
onSuccess: () {},
onError: (error) {},
);
}
});
});
Synerise.notifications.listener((listener) {
listener.onRegistrationRequired = () {
FirebaseMessaging.instance.getToken().then((token) {
if (token != null) {
Synerise.notifications.registerForNotifications(
firebaseToken!,
mobileAgreement: true, // true or false, should depend on device permissions and customer's agreement in the application
onSuccess: () {},
onError: (error) {},
);
}
});
};
});
// 6. Set Firebase listener method for handling notifications when the app is in the foreground
FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
Map messageMap = message.toMap();
bool isSyneriseNotification = await Synerise.notifications.isSyneriseNotification(messageMap);
if (isSyneriseNotification == true) {
Synerise.notifications.handleNotification(messageMap);
}
});
// 7. Set Firebase listener method for handling notification clicks when the app is in the background
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async {
Map messageMap = message.toMap();
bool isSyneriseNotification = await Synerise.notifications.isSyneriseNotification(messageMap);
if (isSyneriseNotification == true) {
Synerise.notifications.handleNotificationClick(messageMap);
}
});
}
@pragma('vm:entry-point')
Future backgroundHandlerForFCM(RemoteMessage message) async {
await Firebase.initializeApp();
await initializeSynerise();
Map messageMap = message.toMap();
bool isSyneriseNotification = await Synerise.notifications.isSyneriseNotification(messageMap);
if (isSyneriseNotification) {
Synerise.notifications.handleNotification(remoteMessageMap);
}
}
Future checkForInitialNotificationMessage() async {
await Firebase.initializeApp();
RemoteMessage? message = await FirebaseMessaging.instance.getInitialMessage();
if (message != null) {
Map messageMap = message.toMap();
bool isSyneriseNotification = await Synerise.notifications.isSyneriseNotification(messageMap);
if (isSyneriseNotification == true) {
Synerise.notifications.handleNotificationClick(messageMap);
}
}
}
//...
}
```
The second parameter of the registration method is the agreement for mobile push campaigns. In the Profile's card in Synerise, you can find it in the **Subscriptions** section (if you have the required access permission). Learn more about the [Synerise.notifications.registerForNotifications(registrationToken, mobileAgreement) method in the method reference](/developers/mobile-sdk/method-reference/flutter/campaigns#register-for-push-notifications).
You must always keep the Firebase token updated. In many cases in the application lifecycle, such as authorization, destroy session, user context change, and so on, the registration needs to be updated. In these situations, the SDK invokes the [onRegistrationRequired()](/developers/mobile-sdk/listeners-and-delegates/flutter-listeners#notifications-listener) method (see code snippet above).
### Configure Notification Encryption
---
#### Android {id=android-notification-encryption-configuration}
See [Configure Notification Encryption](/developers/mobile-sdk/configuring-push-notifications/android#configure-notification-encryption).
#### iOS {id=ios-notification-encryption-configuration}
See [Synerise Notification Service Extension](#synerise-notification-service-extension-for-ios) and [Configure Notification Encryption](/developers/mobile-sdk/configuring-push-notifications/ios#configure-notification-encryption).
#### Application implementation {id=application-notification-encryption-configuration}
In the application, you must set `encryption` to `true` in the SDK initializer or in the SDK settings.
JavaScript
```JavaScript
// WARNING: This option must be configured before Synerise SDK is initialized!
Synerise.settings.notifications.encryption = true;
```
### Handling incoming push notifications
---
You may disable handling push notifications in the SDK at any time. See [Enable/disable notifications](/developers/mobile-sdk/settings#enabledisable-notifications).
#### Synerise payload
The following sample code shows how to handle notifications and check if they are from Synerise:
Dart
```Dart
//...
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
Map messageMap = message.toMap();
bool isSyneriseNotification = await Synerise.notifications.isSyneriseNotification(messageMap);
if (isSyneriseNotification == true) {
Synerise.notifications.handleNotification(messageMap);
}
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
Map messageMap = message.toMap();
bool isSyneriseNotification = await Synerise.notifications.isSyneriseNotification(messageMap);
if (isSyneriseNotification == true) {
Synerise.notifications.handleNotificationClick(messageMap);
}
});
//...
```
#### Custom payload
You may send both custom push notifications and custom campaigns in [Synerise](https://app.synerise.com). The code below of one sample Firebase listener method checks the notification origin and then handles it:
Dart
```Dart
//...
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
Map messageMap = message.toMap();
bool isSyneriseNotification = await Synerise.notifications.isSyneriseNotification(messageMap);
if (isSyneriseNotification == true) {
Synerise.notifications.handleNotification(messageMap);
} else {
// Handle other notifications in your own way
}
});
//...
```
### Handling actions from push notifications
---
- [Read more about types of actions in campaigns](/developers/mobile-sdk/campaigns/action-handling#types-of-actions-in-campaigns)
- [Read more about handling actions from push notifications](/developers/mobile-sdk/campaigns/action-handling#handling-actions-from-campaigns-in-flutter)
### Additional in-app alert from push notifications
---
The Flutter SDK on iOS devices can display an additional alert in the application after a push notification is received. See [this article](/developers/mobile-sdk/campaigns/simple-push#additional-in-app-alert-when-simple-push-is-received) to read more about this feature.
Simple Push campaign with in-app alert
### Limitations compared to native platforms
---
Due to platform limitations, not all notification functionalities may work as in native SDKs.
- **iOS only**: Native-configured button from a Simple Push campaign always invokes the default action (if configured) or displays an in-app alert with buttons to choose.
# External providers
This article contains instruction to implement third parties approaches to authenticating a customer in a mobile application.
## Facebook Login
---
For those Applications that rely on Facebook Login as authentication, Synerise has a separate method that provides you with a Synerise JWT token based on Facebook login. Currently, there are no dedicated settings related to Facebook authentication on the user interface in the Synerise platform. You just have to implement RESTful API or SDK methods to authenticate through Facebook.
To authenticate a customer using Facebook, implement the following methods:
| OS | Method |
|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Android | - [Client.authenticate()](/developers/mobile-sdk/method-reference/android/client-authentication#authenticate-customer-by-identityprovider) |
| iOS | - [Client.authenticate(token:clientIdentityProvider:authID:context:success:failure:)](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-by-identityprovider) - [Client.authenticateConditionally(token:clientIdentityProvider:authID:context:success:failure:)](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-conditionally-by-identityprovider) |
| React Native | - [Synerise.Client.authenticate(token, clientIdentityProvider, authID, context, onSuccess, onError)](/developers/mobile-sdk/method-reference/react-native/client-authentication#authenticate-customer-by-identityprovider) - [Synerise.Client.authenticateConditionally(token, clientIdentityProvider, authID context, onSuccess, onError)](/developers/mobile-sdk/method-reference/react-native/client-authentication#authenticate-customer-conditionally-by-identityprovider) |
| Flutter | - [Synerise.client.authenticate(clientAuthContext, clientIdentityProvider, token)](/developers/mobile-sdk/method-reference/flutter/client-authentication#authenticate-customer-by-identityprovider)) |
**authId/authID** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
Additionally, in the Synerise platform (`app.synerise.com`) you can define the following settings:
- [Assignment of loyalty card](/docs/settings/tool/iam-for-apps/general#loyalty-card-assignment)
- [JWT longevity](/docs/settings/tool/iam-for-apps/general#jwt-lifetime)
- [Custom ID overwriting](/docs/settings/tool/iam-for-apps/general#custom-id-overwriting)
- [External ID overwriting](/docs/settings/tool/iam-for-apps/general#external-id-overwriting)
## Sign in with Apple
---
For integrating with the Apple platform, Synerise has a separate method that returns a Synerise JWT token based on Sign in with Apple credentials. You can read more about the configuration of the Sign in with Apple option in the Synerise platform [here](/docs/settings/tool/iam-for-apps/third-party#apple).
In this case, the authentication process works in the following way:
1. A customer authenticates by Sign in with Apple.
2. Apple provides authentication credentials.
3. Your app uses these credentials and creates `ClientAppleSignInAuthenticationContext`.
4. The context is passed to Synerise by using:
| OS | Method |
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| iOS | - [Client.authenticate(token:clientIdentityProvider:authID:context:success:failure:)](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-conditionally-by-identityprovider) - [Client.authenticateConditionally(token:clientIdentityProvider:authID:context:success:failure:)](/developers/mobile-sdk/method-reference/ios/client-authentication#authenticate-customer-conditionally-by-identityprovider) |
| React Native | - [Synerise.Client.authenticate(token, clientIdentityProvider, authID, context, onSuccess, onError)](/developers/mobile-sdk/method-reference/react-native/client-authentication#authenticate-customer-by-identityprovider) - [Synerise.Client.authenticateConditionally(token, clientIdentityProvider, authID context, onSuccess, onError)](/developers/mobile-sdk/method-reference/react-native/client-authentication#authenticate-customer-conditionally-by-identityprovider) |
| Flutter | - [Synerise.client.authenticate(clientAuthContext, clientIdentityProvider, token)](/developers/mobile-sdk/method-reference/flutter/client-authentication#authenticate-customer-by-identityprovider)) |
**authId/authID** parameter is used for decreasing the number of UUID refreshes, so it must be unique for every customer.
5. If the authentication was successful, Synerise provides your application with our JWT access token for the customer.
Additionally, in the Synerise platform (`app.synerise.com`) you can define the following settings:
- [Assignment of loyalty card](/docs/settings/tool/iam-for-apps/general#loyalty-card-assignment)
- [JWT longevity](/docs/settings/tool/iam-for-apps/general#jwt-lifetime)
- [Custom ID overwriting](/docs/settings/tool/iam-for-apps/general#custom-id-overwriting)
- [External ID overwriting](/docs/settings/tool/iam-for-apps/general#external-id-overwriting)
## The list of methods
---
### Check if a customer is signed in
This method checks if a customer is signed in through oAuth, Facebook, Sign in with Apple, or RaaS.
This method returns `false` if a customer is authenticated through [Simple Profile Authentication](/developers/mobile-sdk/user-identification-and-authorization/simple-authentication).
| OS | Method |
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| Android | [Client.isSignedIn()](/developers/mobile-sdk/method-reference/android/client-authentication#check-if-a-customer-is-signed-in-via-raas-oauth-facebook-apple) |
| iOS | [Client.isSignedIn()](/developers/mobile-sdk/method-reference/ios/client-authentication#check-if-a-customer-is-signed-in-via-raas-oauth-facebook-apple) |
| React Native | [Synerise.Client.isSignedIn()](/developers/mobile-sdk/method-reference/react-native/client-authentication#check-if-a-customer-is-signed-in-via-raas-oauth-facebook-apple) |
| Flutter | [Synerise.client.isSignedIn()](/developers/mobile-sdk/method-reference/flutter/client-authentication#check-if-a-customer-is-signed-in-via-raas-oauth-facebook-apple) |
### Customer sign out
This method signs out the customer. The method terminates the JWT token and ends the customer session.
| OS | Method |
|--------------|-----------------------------------------------------------------------------------------------------------------------|
| Android | - [Client.signOut()](/developers/mobile-sdk/method-reference/android/client-authentication#sign-out-customer) - [Client.signOut(mode, signOutFromAllDevices)](/developers/mobile-sdk/method-reference/android/client-authentication#sign-out-customer-with-mode-or-from-all-devices) |
| iOS | - [Client.signOut()](/developers/mobile-sdk/method-reference/ios/client-authentication#sign-out-customer) - [Client.signOut(mode:fromAllDevices:success:failure:)](/developers/mobile-sdk/method-reference/ios/client-authentication#sign-out-customer-with-mode-or-from-all-devices) |
| React Native | - [Synerise.Client.signOut()](/developers/mobile-sdk/method-reference/react-native/client-authentication#sign-out-a-customer) - [Synerise.Client.signOutWithMode(mode, fromAllDevices, onSuccess, onError)](/developers/mobile-sdk/method-reference/react-native/client-authentication#sign-out-customer-with-mode-or-from-all-devices) |
| Flutter | [Synerise.client.signOut()](/developers/mobile-sdk/method-reference/flutter/client-authentication#sign-out-a-customer) |
## What's next
---
When the customer's is signed in, you can implement [profile management methods](/developers/mobile-sdk/user-identification-and-authorization/identification-and-user-management#profile-management-methods) and [session management methods](/developers/mobile-sdk/user-identification-and-authorization/session-management).
# Huawei integration in Flutter SDK
## Enable integration in the Synerise platform
Before you start integrating Huawei services in your app, you must configure the integration in Synerise platform. For instructions, see ["Huawei integration"](/docs/settings/tool/huawei-integration).
## Configuration
In order to integrate Huawei Mobile Services (HMS) with Synerise, you must add `.setMesaggingServiceType(MessagingServiceType.hms)` to your `Synerise.initializer`.
We recommend passing `MessagingServiceType.hms` as an argument when you build the app for AppGallery.
More information about `Synerise.initializer` is available in ["Initialization"](/developers/mobile-sdk/installation-and-configuration/flutter#initialization).
## Implementing Huawei notifications in applications
1. Add the Huawei push library as a dependency and integrate it: [https://pub.dev/packages/huawei_push](https://pub.dev/packages/huawei_push).
2. Add an `onTokenEvent` callback to receive the HMS token. In the callback, send the token to Synerise by using [`Synerise.notifications.registerForNotifications`](/developers/mobile-sdk/method-reference/flutter/campaigns#register-for-push-notifications) method:
void _onTokenEvent(String event) {
// Requested tokens can be obtained here
setState(() {
_token = event;
});
if (event != null && event.isNotEmpty) {
Synerise.notifications.registerForNotifications(
event,
mobileAgreement: true,
onSuccess: () {},
onError: (error) {},
);
print("TokenEvent: " + _token);
}
}
3. Add a listener to trigger `getToken()` from the Huawei push library whenever the [`onRegistrationRequired`](/developers/mobile-sdk/listeners-and-delegates/flutter-listeners#notifications-listener) callback is called:
Synerise.notifications.listener((listener) {
listener.onRegistrationRequired = () {
getToken();
};
});
4. Add the `onMessageReceived` callback from the Huawei push library and pass the data to Synerise SDK:
Future<void> _onMessageReceived(RemoteMessage remoteMessage) async {
// Called when a data message is received
Map<String, String>? data = remoteMessage.getDataOfMap;
if (data != null) {
bool isSyneriseNotification =
await Synerise.notifications.isSyneriseNotification(data);
if (isSyneriseNotification == true) {
Synerise.notifications.handleNotification(data);
bool isSyneriseNotificationEncrypted = await Synerise.notifications
.isNotificationEncrypted(data);
if (isSyneriseNotificationEncrypted) {
Map decryptedPayload =
await Synerise.notifications.decryptNotification(data);
developer.log(decryptedPayload.toString());
}
}
}
}
5. To make sure your callbacks work, use streams:
Future<void> initTokenStream() async {
if (!mounted) return;
Push.getTokenStream.listen(_onTokenEvent, onError: _onTokenError);
}
void getToken() {
// Call this method to request for a token
Push.getToken("");
}
Future<void> initMessageStream() async {
if (!mounted) return;
Push.onMessageReceivedStream
.listen(_onMessageReceived, onError: _onMessageReceiveError);
}
## Links and Deep Links
In order to implement links and deep links, refer to [this](/developers/mobile-sdk/campaigns/action-handling#handling-actions-from-campaigns-in-android) instruction.
## Configuring notification encryption
Instructions for encrypting push notifications are available [here](/developers/mobile-sdk/configuring-push-notifications/flutter#configure-notification-encryption).
# Flutter
## Class reference - Flutter
# Customer account management
## Get customer account information
---
This method gets a customer’s account information.
This method requires customer authentication.
The API key must have the `API_PERSONAL_INFORMATION_CLIENT_READ` permission from the **Client** group.
**Method name:**
Client.getAccount()
**Declaration:**
Java Kotlin
```Java
public static IDataApiCall getAccount()
```
```Kotlin
fun getAccount():IDataApiCall
```
**Parameters:**
No parameters required.
**Return Value:**
[IDataApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#idataapicall)<[GetAccountInformation](/developers/mobile-sdk/class-reference/android/client#getaccountinformation)> object to execute the request.
**Example:**
Java Kotlin
```Java
private IDataApiCall getAccountCall;
private void getAccount(boolean isFacebook) {
if (getAccountCall != null) getAccountCall.cancel();
getAccountCall = Client.getAccount();
getAccountCall.execute(({ this.onGetAccountSuccessful() }), ({ this.onGetAccountFailure() });
}
```
```Kotlin
private val getAccountCall:IDataApiCall
private fun getAccount(isFacebook:Boolean) {
if (getAccountCall != null) getAccountCall.cancel()
getAccountCall = Client.getAccount()
getAccountCall.execute(({ this.onGetAccountSuccessful() }), ({ this.onGetAccountFailure() })
}
```
## Get customer's events
---
This method retrieves events for an authenticated customer.
This method requires customer authentication.
**Method name:**
Client.getEvents(clientEventsQuery)
**Declaration:**
Java Kotlin
```Java
public static IDataApiCall> getEvents(ClientEventsQuery clientEventsQuery)
```
```Kotlin
fun getEvents(clientEventsQuery:ClientEventsQuery):IDataApiCall>
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **clientEventsQuery** | ClientEventsQuery | yes | - | Object to create clientEvent query |
**Return Value:**
[IDataApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#idataapicall)> object to execute the request.
**Example:**
Java Kotlin
```Java
private IDataApiCall> getEventClientsCall;
if (getEventClientsCall != null) getEventClientsCall.cancel();
getEventClientsCall = Client.getEvents(clientEventsQuery);
getEventClientsCall.execute(({ this.onSuccess() }), ({ this.onFailure() });
```
```Kotlin
private val getEventClientsCall:IDataApiCall>
if (getEventClientsCall != null) getEventClientsCall.cancel()
getEventClientsCall = Client.getEvents(clientEventsQuery)
getEventClientsCall.execute(({ this.onSuccess() }), ({ this.onFailure() })
```
## Update customer account basic information
---
This method updates a customer’s account’s basic information (without identification data: uuid, customId, email).
This method requires the context object with the customer’s account information. Omitted fields are not modified.
This method does not require customer authentication and can be used by anonymous profiles.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 4.22.0 | 5.21.0 | 0.24.0 | 1.4.0 |
The API key must have the `API_BASIC_INFORMATION_CLIENT_UPDATE` permission from the **Client** group.
**Method name:**
Client.updateAccountBasicInformation(accountInformation)
**Declaration:**
Java Kotlin
```Java
public static IApiCall updateAccountBasicInformation(@NonNull UpdateAccountBasicInformation accountInformation)
```
```Kotlin
fun updateAccountBasicInformation(@NonNull accountInformation:UpdateAccountBasicInformation):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **accountInformation** | [UpdateAccountBasicInformation](/developers/mobile-sdk/class-reference/android/client#updateaccountbasicinformation) | yes | - | Builder Pattern object with the Customer's basic account information |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
if (apiCall != null) apiCall.cancel();
apiCall = Client.updateAccountBasicInformation(accountInformation);
apiCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
if (apiCall != null) apiCall.cancel()
apiCall = Client.updateAccountBasicInformation(accountInformation)
apiCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## Update customer account information
---
This method updates a customer’s account information.
This method requires the context object with the customer’s account information. Omitted fields are not modified.
This method requires customer authentication.
The API key must have the `API_PERSONAL_INFORMATION_CLIENT_UPDATE` permission from the **Client** group.
**Method name:**
Client.updateAccount(accountInformation)
**Declaration:**
Java Kotlin
```Java
public static IApiCall updateAccount(@NonNull UpdateAccountInformation accountInformation)
```
```Kotlin
fun updateAccount(@NonNull accountInformation:UpdateAccountInformation):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **accountInformation** | [UpdateAccountInformation](/developers/mobile-sdk/class-reference/android/client#updateaccountinformation) | yes | - | Builder Pattern object with the Customer's account information |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
if (apiCall != null) apiCall.cancel();
apiCall = Client.updateAccount(accountInformation);
apiCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
if (apiCall != null) apiCall.cancel()
apiCall = Client.updateAccount(accountInformation)
apiCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## Change customer's account password
---
This method changes a customer’s password.
This method requires customer authentication.
Returns the HTTP 403 status code if the provided old password is invalid.
The API key must have the `SAUTH_CHANGE_PASSWORD_CLIENT_UPDATE` permission from the **Client** group.
**Method name:**
Client.changePassword(oldPassword, password)
**Declaration:**
java kotlin
```java
public static IApiCall changePassword(@NonNull String oldPassword, @NonNull String password)
```
```kotlin
fun changePassword(@NonNull oldPassword:String, @NonNull password:String):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **oldPassword** | String | yes | - | Client's old password |
| **password** | String | yes | --- | Client's new password |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
java kotlin
```java
private IApiCall apiCall;
if (apiCall != null) apiCall.cancel();
apiCall = Client.changePassword(oldPassword, password);
apiCall.execute(this::onSuccess, this::onFailure);
```
```kotlin
val apiCall:IApiCall
if (apiCall != null) apiCall.cancel()
apiCall = Client.changePassword(oldPassword, password)
apiCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## Request password reset for customer account
---
This method requests a customer’s password reset with email. The customer will receive a token to the provided email address. That token is then used for the confirmation of password reset.
This method requires the customer’s email.
This method is a global operation and doesn't require customer authentication.
The API key must have the `SAUTH_PASSWORD_RESET_CLIENT_CREATE` permission from the **Client** group.
**Method name:**
Client.requestPasswordReset(resetRequest)
**Declaration:**
Java Kotlin
```Java
public static IApiCall requestPasswordReset(@NonNull PasswordResetRequest resetRequest)
```
```Kotlin
fun requestPasswordReset(@NonNull resetRequest:PasswordResetRequest):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **resetRequest** | PasswordResetRequest | yes | - | PasswordResetRequest object with the Client's email. |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
if (call != null) call.cancel();
call = Client.requestPasswordReset(new PasswordResetRequest(email));
EspressoTestingIdlingResource.increment();
call.execute(this::onSuccess, this::onFailure);
```
```Kotlin
if (call != null) call.cancel()
call = Client.requestPasswordReset(PasswordResetRequest(email))
call.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## Confirm password reset for customer account
---
This method confirm a customer’s password reset with the new password and token provided by password reset request.
This method requires the customer’s new password and the confirmation token received by e-mail.
This method is a global operation and doesn't require customer authentication.
The API key must have the `SAUTH_PASSWORD_RESET_CLIENT_CREATE` permission from the **Client** group.
**Method name:**
Client.confirmPasswordReset(resetConfirmation)
**Declaration:**
java kotlin
```java
public static IApiCall confirmPasswordReset(@NonNull PasswordResetConfirmation resetConfirmation)
```
```kotlin
fun confirmPasswordReset(@NonNull resetConfirmation:PasswordResetConfirmation):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **resetConfirmation** | PasswordResetConfirmation | yes | - | PasswordResetConfirmation object with the Client's new password and confirmation token. |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
private IApiCall call;
if (call != null) call.cancel();
call = Client.confirmPasswordReset(confirmation);
call.execute(this::onSuccess, this::onFailure);
```
```Kotlin
val call:IApiCall
if (call != null) call.cancel()
call = Client.confirmPasswordReset(confirmation)
call.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## Request email change for customer account
---
This method requests a customer's email change.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided token or the password is invalid.
The API key must have the `SAUTH_CHANGE_EMAIL_CLIENT_UPDATE` permission from the **Client** group.
**Method name:**
Client.requestEmailChange(email, password, externalToken, authId)
**Declaration:**
Java Kotlin
```Java
public static IApiCall requestEmailChange(String email, String password, @Nullable String externalToken, @Nullable String authId)
```
```Kotlin
fun requestEmailChange(email:String, password:String, @Nullable externalToken:String, @Nullable authId: String):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer's email |
| **password** | String | yes | -| Customer's password |
| **externalToken** | String | no | - | ExternalToken should be used for Facebook, Oauth. For Synerise account, pass null |
| **authId** | String | no | - | Optional identifier of authorization. For Synerise account, pass null. |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
IApiCall apiCall;
apiCall = Client.requestEmailChange(email, password, null, null);
apiCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
val apiCall:IApiCall
apiCall = Client.requestEmailChange(email, password, null, null)
apiCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## Confirm email change for customer account
---
This method confirms an email change.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided token is invalid.
The API key must have the `SAUTH_CHANGE_EMAIL_CLIENT_UPDATE` permission from the **Client** group.
**Method name:**
Client.confirmEmailChange(token, newsletterAgreement)
**Declaration:**
java kotlin
```java
public static IApiCall confirmEmailChange(String token, boolean newsletterAgreement)
```
```kotlin
fun confirmEmailChange(token:String, newsletterAgreement:Boolean):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **token** | String | yes | - | Token from customer's email |
| **newsletterAgreement** | boolean | yes | - | Newsletter agreement |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
java kotlin
```java
IApiCall apiCall;
apiCall = Client.confirmEmailChange(token, newsletterAgreement.isChecked());
apiCall.execute(this::onSuccess, this::onFailure);
```
```kotlin
val apiCall:IApiCall
apiCall = Client.confirmEmailChange(token, newsletterAgreement.isChecked())
apiCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## Request phone update on customer account
---
This method requests a customer's phone update. A confirmation code is sent to the phone number.
This method is a global operation and doesn't require customer authentication.
The API key must have the `API_PERSONAL_PHONE_CLIENT_CREATE` permission from the **Client** group.
**Method name:**
Client.requestPhoneUpdate(phone)
**Declaration:**
Java Kotlin
```Java
public static IApiCall requestPhoneUpdate(String phone)
```
```Kotlin
fun requestPhoneUpdate(phone:String):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **phone** | String | yes | - | Customer's phone number. |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
IApiCall apiCall;
apiCall = Client.requestPhoneUpdate(phone);
apiCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
val apiCall:IApiCall
apiCall = Client.requestPhoneUpdate(phone)
apiCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## Confirm phone update on customer account
---
This method confirms a phone number update. This action requires the new phone number and confirmation code as parameters.
This method is a global operation and doesn't require customer authentication.
Returns the HTTP 403 status code if the provided UUID does not exist or the password is invalid.
The API key must have the `API_PERSONAL_PHONE_CLIENT_CREATE` permission from the **Client** group.
**Method name:**
Client.confirmPhoneUpdate(phone, confirmationCode, smsAgreement)
**Declaration:**
Java Kotlin
```Java
public static IApiCall confirmPhoneUpdate(String phone, String confirmationCode, @Nullable Boolean smsAgreement)
```
```Kotlin
fun confirmPhoneUpdate(phone:String, confirmationCode:String, @Nullable smsAgreement:Boolean):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **phone** | String | yes | - | Phone number that will be confirmed |
| **confirmationCode** | String | yes | - | Code received in SMS |
| **smsAgreement** | Boolean | no | - | Optional SMS marketing agreement |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
IApiCall apiCall;
apiCall = Client.confirmPhoneUpdate(phone, code, enableAgreement.isChecked() ? null : smsAgreement.isChecked());
apiCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
val apiCall:IApiCall
apiCall = Client.confirmPhoneUpdate(phone, code, if (enableAgreement.isChecked()) null else smsAgreement.isChecked())
apiCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## Delete customer account by Identity Provider
---
This method deletes a customer's account.
This method requires customer authentication.
HTTP 403 status code is returned if the provided password or token is invalid.
The API key must have the `SAUTH_CLIENT_DELETE`, `SAUTH_OAUTH_CLIENT_DELETE`, `SAUTH_FACEBOOK_CLIENT_DELETE`, `SAUTH_APPLE_CLIENT_DELETE` permissions from the **Client** group.
**Method name:**
Client.deleteAccount(clientAuthFactor, clientIdentityProvider, authId)
**Declaration:**
Java Kotlin
```Java
public static IApiCall deleteAccount(String clientAuthFactor, ClientIdentityProvider clientIdentityProvider, @Nullable String authId)
```
```Kotlin
fun deleteAccount(clientAuthFactor:String, clientIdentityProvider:ClientIdentityProvider, authId:String):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **clientAuthFactor** | String | yes | - | In case of oauth, fb, or google this is token. If you have synerise account this is password. |
| **clientIdentityProvider** | [ClientIdentityProvider](/developers/mobile-sdk/class-reference/android/client#clientidentityprovider) | yes | - | Provider of your account. Example: FACEBOOK, OAUTH, SYNERISE, GOOGLE |
| **authId** | String | no | - | Customer's optional unique identifier |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
IApiCall deleteCall = Client.deleteAccount(password, ClientIdentityProvider.SYNERISE, null);
deleteCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
val deleteCall = Client.deleteAccount(password, ClientIdentityProvider.SYNERISE, null)
deleteCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
## Removed methods
### Delete customer account {#delete-customer-account}
---
This method deletes a customer's account.
This method requires customer authentication.
| | **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.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | n/a | n/a |
Returns the HTTP 403 status code is returned if the provided password is invalid.
The API key must have the `SAUTH_CLIENT_DELETE` permission from the **Client** group.
**Replaced By:**
[Delete customer account by Identity Provider](/developers/mobile-sdk/method-reference/android/client-account#delete-customer-account-by-identity-provider)
**Method name:**
Client.deleteAccount(password)
**Declaration:**
Java Kotlin
```Java
public static IApiCall deleteAccount(String password)
```
```Kotlin
fun deleteAccount(password:String):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **password** | String | yes | - | Customer's current password. |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
IApiCall deleteCall = Client.deleteAccount(password);
deleteCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
val deleteCall = Client.deleteAccount(password)
deleteCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
### Delete customer account by OAuth {#delete-customer-account-by-oauth}
---
This method deletes a customer's account by OAuth.
This method requires customer authentication.
| | **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.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | n/a | n/a |
The API key must have the `SAUTH_CLIENT_DELETE` and `SAUTH_OAUTH_CLIENT_DELETE` permissions from the **Client** group.
**Replaced By:**
[Delete customer account by Identity Provider](/developers/mobile-sdk/method-reference/android/client-account#delete-customer-account-by-identity-provider)
**Method name:**
Client.deleteAccountByOAuth(accessToken, uuid)
**Declaration:**
Java Kotlin
```Java
public static IApiCall deleteAccountByOAuth(String accessToken, @Nullable String uuid)
```
```Kotlin
fun deleteAccountByOAuth(accessToken:String, @Nullable uuid:String):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **accessToken** | String | yes | - | user's token |
| **uuid** | String | no | --- | Optional Customer UUID, internal UUID is used if this parameter is null |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
IApiCall deleteCall = Client.deleteAccountByOAuth(accessToken, uuid)
deleteCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
val deleteCall = Client.deleteAccountByOAuth(accessToken, uuid)
deleteCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
### Delete customer account by Facebook {#delete-customer-account-by-facebook}
---
This method deletes a customer's account by Facebook.
This method requires customer authentication.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 3.3.8 | 3.3.0 | 0.9.12 | n/a |
| Deprecated in: | 3.6.19 | 3.6.19 | 0.14.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | n/a | n/a |
The API key must have the `SAUTH_CLIENT_DELETE` and `SAUTH_FACEBOOK_CLIENT_DELETE` permissions from the **Client** group.
**Replaced By:**
[Delete customer account by Identity Provider](/developers/mobile-sdk/method-reference/android/client-account#delete-customer-account-by-identity-provider)
**Method name:**
Client.deleteAccountByFacebook(facebookToken, uuid)
**Declaration:**
Java Kotlin
```Java
public static IApiCall deleteAccountByFacebook(String facebookToken, @Nullable String uuid)
```
```Kotlin
fun deleteAccountByFacebook(facebookToken:String, @Nullable uuid:String):IApiCall
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **facebookToken** | String | yes | - | Customer's facebook token |
| **uuid** | String | no | --- | Optional Customer UUID, internal UUID is used if this parameter is null |
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
IApiCall deleteCall = Client.deleteAccountByFacebook(facebookToken, uuid)
deleteCall.execute(this::onSuccess, this::onFailure);
```
```Kotlin
val deleteCall = Client.deleteAccountByFacebook(facebookToken, uuid)
deleteCall.execute(({ this.onSuccess() }), ({ this.onFailure() }))
```
# Campaigns
### SyneriseSource
**Declared In:**
lib/enums/injector/synerise_source.dart
**Declaration:**
enum SyneriseSource {
notSpecified('NOT_SPECIFIED'),
simplePush('SIMPLE_PUSH'),
banner('BANNER'),
walkthrough('WALKTHROUGH'),
inAppMessage('IN_APP_MESSAGE');
**Functions:**
Converts from **String** to **SyneriseSource**.
Dart
```Dart
static SyneriseSource getSyneriseSourceFromString(String string)
```
---
---
### InAppMessageData
Model representing an in-app message data.
This is a read-only class and it is not meant to be instantiated directly.
**Declared In:**
lib/model/in_app/in_app_message_data.dart
**Declaration:**
class InAppMessageData
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **campaignHash** | String | no | Identifier of the in-app message campaign. |
| **variantIdentifier** | String | no | Identifier of the in-app message campaign variant. |
| **additionalParameters** | Map | yes | Parameters additionally provided by the campaign. |
| **isTest** | bool | no | Specifies if the object is from a test campaign. |
# Customer session
## 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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func refreshToken(success: (() -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
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
})
```
```Objective-C
[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](/developers/mobile-sdk/class-reference/ios/client#token)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func retrieveToken(success: ((Token) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
Client.retrieveToken(success: { (token) in
// success
let tokenString: String = token.tokenString
let tokenOrigin: TokenOrigin = token.tokenOrigin
}, failure: { (error) in
// failure
})
```
```Objective-C
[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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func getUUID() -> String
```
```Objective-C
+ (NSString *)getUUID;
```
**Return Value:**
The method returns the customer's UUID as string.
**Example:**
Swift Objective-C
```Swift
let clientUUID: String = Client.getUUID()
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func getUUIDForAuthentication(authID: String) -> String
```
```Objective-C
+ (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:**
Swift Objective-C
```Swift
let clientUUID: String = Client.getUUIDForAuthentication(authID: "AUTH_ID")
```
```Objective-C
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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func regenerateUUID() -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func regenerateUUID(clientIdentifier: String?) -> Void
```
```Objective-C
+ (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](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func destroySession()
```
```Objective-C
+ (void)destroySession
```
**Return Value:**
No value is returned.
**Example:**
Swift Objective-C
```Swift
Client.destroySession()
```
```Objective-C
[SNRClient destroySession];
```
# Campaigns
## SyneriseSource
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 5.0.0 | 6.0.0 | 0.18.0 | 0.8.0 |
**Declared In:**
Headers/SNRSyneriseSource.h
**Declaration:**
Swift Objective-C
```Swift
enum SyneriseSource: Int {
simplePush,
inAppMessage
}
```
```Objective-C
typedef NS_ENUM(NSInteger, SNRSyneriseSource) {
SNRSyneriseActivitySimplePush,
SNRSyneriseActivityInAppMessage
}
```
---
---
## NotificationInfo
**Declared In:**
Headers/SNRNotificationInfo.h
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class NotificationInfo: BaseModel
```
```Objective-C
@interface SNRNotificationInfo : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **campaignHashId** | String | no | Identifier of the notification campaign. |
| **campaignTitle** | String | no | Identifier of the notification title. |
| **payload** | [AnyHashable: Any] | yes | Payload of the notification. |
All properties are read-only.
---
---
## PushNotificationsRegistrationOrigin
**Declared In:**
Headers/SNRSynerise.h
**Declaration:**
Swift Objective-C
```Swift
enum PushNotificationsRegistrationOrigin: Int {
.appStarted,
.clientContextChange,
.securityReason,
.periodicJob
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRPushNotificationsRegistrationOrigin) {
SNRPushNotificationsRegistrationOriginAppStarted,
SNRPushNotificationsRegistrationOriginClientContextChange,
SNRPushNotificationsRegistrationOriginSecurityReason,
SNRPushNotificationsRegistrationOriginPeriodicJob
}
```
---
---
## InAppMessageData
Model representing an in-app message data.
This is a read-only class and it is not meant to be instantiated directly.
**Declared In:**
Headers/SNRInAppMessageData.h
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class InAppMessageData: BaseModel
```
```Objective-C
@interface SNRInAppMessageData : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **campaignHash** | String | no | Identifier of the in-app message campaign. |
| **variantIdentifier** | String | no | Identifier of the in-app message campaign variant. |
| **additionalParameters** | [AnyHashable: Any] | yes | Parameters additionally provided by the campaign. |
| **isTest** | Bool | no | Specifies if the object is from a test campaign. |
All properties are read-only.
---
---
### SyneriseMethod
Enum with a list of SDK methods that can be called from JavaScript in an in-app.
See [Using in-app template builder](/docs/campaign/in-app-messages/creating-inapp-templates/creating-inapp-template#use-a-mobile-sdk-method)
## Deprecated symbols
### *SyneriseActivity*
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Deprecated in: | 5.0.0 | n/a | n/a | n/a |
**Declared In:**
Headers/SNRSyneriseActivity.h
**Declaration:**
Swift Objective-C
```Swift
enum SyneriseActivity: Int {
simplePush,
banner,
walkthrough,
inAppMessage
}
```
```Objective-C
typedef NS_ENUM(NSInteger, SNRSyneriseActivity) {
SNRSyneriseActivitySimplePush,
SNRSyneriseActivityBanner,
SNRSyneriseActivityWalkthrough,
SNRSyneriseActivityInAppMessage
}
```
---
---
### *SyneriseActivityAction*
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Deprecated in: | 5.0.0 | n/a | n/a | n/a |
**Declared In:**
Headers/SNRSynerise.h
**Declaration:**
Swift Objective-C
```Swift
enum SyneriseActivityAction: Int {
none,
hide
}
```
```Objective-C
typedef NS_ENUM(NSInteger, SNRSyneriseActivityAction) {
SNRSyneriseActivityActionNone,
SNRSyneriseActivityActionHide
}
```
# Events
### Event
Main event abstract class for inheriting classes.
This is an abstract class and it is not meant to be instantiated directly. You should use concrete subclasses instead.
**Declared In:**
lib/model/tracker/event.dart
**Declaration:**
abstract class Event
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **type** | String | no | Event type |
| **label** | String | no | Can't be empty. This value isn't saved in persistent storage and can't be used in Decision or Automation Hubs. It isn't shown on a Profile card. |
| **action** | String | no | Event action |
| **parameters** | bool | no | Event parameters |
---
---
### CustomEvent
DO NOT send `transaction.charge` events as custom events.
Transactions must be tracked with these endpoints:
- [`/v4/transactions`](https://hub.synerise.com/api-reference/data-management#operation/CreateATransaction) (single transaction)
- [`/v4/transactions/batch`](https://hub.synerise.com/api-reference/data-management#operation/BatchAddOrUpdateTransactions) (multiple transactions)
Represents a custom client event.
**Declared In:**
lib/model/tracker/custom_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
**Declaration:**
class CustomEvent extends Event
**Initializers:**
CustomEvent(String label, String action, Map<String, Object> parameters)
**Example:**
Dart
```Dart
final paramMap = {
"firstKeyCustomParam": "TEST_1",
"secondKeyCustomParam": "TEST_2",
};
CustomEvent event = CustomEvent("LABEL", "ACTION", paramMap);
```
---
---
### PushViewedEvent
Represents a 'client viewed push' event.
This event is used for push message interaction tracking.
**Declared In:**
lib/events/push/push_viewed_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class PushViewedEvent extends CustomEvent
**Initializers:**
PushViewedEvent(
String label,
Map<String, Object>? parameters,
)
---
---
### PushClickedEvent
Represents a 'client clicked push' event.
This event is used for push message interaction tracking.
**Declared In:**
lib/events/push/push_clicked_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class PushClickedEvent extends CustomEvent
**Initializers:**
PushClickedEvent(
String label,
Map<String, Object>? parameters,
)
---
---
### PushCancelledEvent
Represents a 'client dismissed push' event.
This event is used for push message interaction tracking.
**Declared In:**
lib/events/push/push_cancelled_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class PushCancelledEvent extends CustomEvent
**Initializers:**
PushCancelledEvent(
String label,
Map<String, Object>? parameters,
)
---
---
### CartEvent
Main cart action abstract class for inheriting classes.
This is an abstract class and it is not meant to be instantiated directly. You should use concrete `CartEvent` subclasses instead.
**Declared In:**
lib/events/cart/cart_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class CartEvent extends CustomEvent
**Initializers:**
CartEvent(String label, String action, String sku, UnitPrice finalPrice, int quantity, Map<String, Object>? parameters)
**Methods:**
This method sets a value for the `name` parameter.
void setName(String name)
---
This method sets a value for the `category` parameter.
void setCategory(String category)
---
This method sets values for the `categories` parameter.
void setCategories(List<String> categories)
---
This method sets a value for the `offline` parameter.
void setOffline(bool offline)
---
This method sets the value of the `regularPrice` parameter.
void setRegularPrice(UnitPrice regularPrice)
---
This method sets the value of the `discountedPrice` parameter.
void setDiscountedPrice(UnitPrice discountedPrice)
---
This method sets the value of the `url` parameter.
void setUrl(String url)
---
This method sets the value of the `producer` parameter (producer can signify a brand of the item).
void setProducer(String producer)
---
---
### UnitPrice
**Declared In:**
lib/model/tracker/unit_price.dart
**Declaration:**
class UnitPrice
**Initializers:**
UnitPrice(
int amount,
String currency)
---
---
### ProductAddedToCartEvent
Represents a 'client added product to cart' event.
**Declared In:**
lib/events/cart/product_added_to_cart_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class ProductAddedToCartEvent extends CartEvent
**Initializers:**
ProductAddedToCartEvent(String label, String sku, UnitPrice finalPrice, int quantity, Map<String, Object>? parameters)
---
---
### ProductRemovedFromCartEvent
Represents a 'client removed product from cart' event.
**Declared In:**
lib/events/cart/product_removed_from_cart_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class ProductRemovedFromCartEvent extends CartEvent
**Initializers:**
ProductRemovedFromCartEvent(String label, String sku, UnitPrice finalPrice, int quantity, Map<String, Object>? parameters)
---
---
### ProductViewedEvent
Represents a 'client viewed product' event.
**Declared In:**
lib/events/product/product_viewed_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class ProductViewedEvent extends CustomEvent
**Initializers:**
ProductViewedEvent(
String label,
String productId,
String name,
Map<String, Object>? parameters,
)
**Methods:**
This method sets a value for the `category` parameter.
void setCategory(String category)
---
This method sets the value of the `url` parameter.
void setUrl(String url)
---
---
### ProductAddedToFavoritesEvent
Represents a 'client added product to favorites' event.
**Declared In:**
lib/events/product/product_added_to_favorites_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class ProductAddedToFavouritesEvent extends CustomEvent
**Initializers:**
ProductAddedToFavoritesEvent(
String label,
Map<String, Object>? parameters,
)
---
---
### LoggedInEvent
Represents a 'client logged in' event.
**Declared In:**
lib/events/auth/logged_in_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class LoggedInEvent extends CustomEvent
**Initializers:**
LoggedInEvent(
String label,
Map<String, Object>? parameters,
)
---
---
### LoggedOutEvent
Represents a 'client logged out' event.
**Declared In:**
lib/events/auth/logged_out_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class LoggedOutEvent extends CustomEvent
**Initializers:**
LoggedOutEvent(String label, Map<String, Object>? parameters)
---
---
### RegisteredEvent
Represents a 'client registered' event.
**Declared In:**
lib/events/auth/registered_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class RegisteredEvent extends CustomEvent
**Initializers:**
RegisteredEvent(String label, Map<String, Object>? parameters)
---
---
### RecommendationEvent
Main recommendation abstract class for inheriting classes.
This is an abstract class and it is not meant to be instantiated directly. You should use concrete `RecommendationEvent` subclasses instead.
**Declared In:**
lib/events/recommendation/recommendation_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class RecommendationEvent extends CustomEvent
**Initializers:**
RecommendationEvent(String label, String action, Map<String, Object>? parameters)
---
---
### RecommendationSeenEvent
Represents a 'client saw a recommendation' event.
**Declared In:**
lib/events/recommendation/recommendation_seen_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class RecommendationSeenEvent extends RecommendationEvent
**Initializers:**
RecommendationSeenEvent(String label, String action, String productId, String productName, String campaignId, String campaignHash, Map<String, Object>? parameters)
---
---
### RecommendationViewEvent
Represents a 'client viewed a recommendation' event.
**Declared In:**
lib/events/recommendation/recommendation_view_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class RecommendationViewEvent extends RecommendationEvent
**Initializers:**
RecommendationViewEvent(String label, String action, List<String>? items, String campaignId, String campaignHash, String correlationId, Map<String, Object>? parameters)
---
---
### RecommendationClickEvent
Represents a 'client clicked a recommendation' event.
**Declared In:**
lib/events/recommendation/recommendation_click_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
[RecommendationEvent](/developers/mobile-sdk/class-reference/flutter/events#recommendationevent)
**Declaration:**
class RecommendationClickEvent extends RecommendationEvent
**Initializers:**
RecommendationClickEvent(String label, String action, String productId, String productName, String campaignId, String campaignHash,
Map<String, Object>? parameters)
---
---
### VisitedScreenEvent
Represents a 'client visited screen' event.
This can be used for mobile screen usage tracking.
**Declared In:**
lib/events/other/visited_screen_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class VisitedScreenEvent extends CustomEvent
**Initializers:**
VisitedScreenEvent(
String label,
Map<String, Object>? parameters,
)
---
---
### HitTimerEvent
Represents a 'client hit timer' event.
This could be used for profiling or activity time monitoring - you can send a `HitTimerEvent` when your client starts doing something and send it once again when they finish, but this time with the different time signature. Then you can use our analytics engine to measure, for example, average activity time.
**Declared In:**
lib/events/other/hit_timer_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class HitTimerEvent extends CustomEvent
**Initializers:**
HitTimerEvent(
String label,
Map<String, Object>? parameters,
)
---
---
### SearchedEvent
Represents a 'client searched' event.
**Declared In:**
lib/events/other/searched_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class SearchedEvent extends CustomEvent
**Initializers:**
SearchedEvent(
String label,
Map<String, Object>? parameters,
)
---
---
### SharedEvent
Represents a 'client shared' event.
**Declared In:**
lib/events/other/shared_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class SharedEvent extends CustomEvent
**Initializers:**
SharedEvent(
String label,
Map<String, Object>? parameters,
)
---
---
### AppearedInLocationEvent
Represents a 'client appeared in location' event.
**Declared In:**
lib/events/other/appeared_in_location_event.dart
**Inherits From:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Declaration:**
class AppearedInLocationEvent extends CustomEvent
**Initializers:**
AppearedInLocationEvent(
String label,
double lat,
double lon,
Map<String, Object>? parameters,
)
# Promotions and Vouchers
## Promotions
---
### PromotionResponse
**Declared In:**
lib/classes/models/Promotions/PromotionResponse.js
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotion)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class PromotionResponse extends BaseModel
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **totalCount** | number | no | Total count of promotions |
| **totalPages** | number | no | Total count of pages |
| **page** | number | no | Current page |
| **limit** | number | no | Limit of promotions per page |
| **code** | number | no | HTTP code of the response |
| **items** | [Array](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotion) | no | List of promotion items |
---
---
### Promotion
**Declared In:**
lib/classes/models/Promotions/Promotion.js
**Related To:**
[PromotionResponse](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionresponse)
[PromotionStatus](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionstatus)
[PromotionType](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiontype)
[PromotionDetails](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondetails)
[PromotionItemScope](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionitemscope)
[PromotionDiscountType](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscounttype)
[PromotionDiscountMode](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscountmode)
[PromotionDiscountModeDetails](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscountmodedetails)
[PromotionImage](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionimage)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class Promotion extends BaseModel
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **uuid** | string | no | Promotion's UUID |
| **code** | string | no | Promotion's code |
| **status** | [PromotionStatus](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionstatus) | yes | Promotion's status |
| **type** | [PromotionType](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiontype) | yes | Promotion's type |
| **details** | [PromotionDetails](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondetails) | yes | Promotion's details |
| **redeemLimitPerClient** | number | yes | Redemption limit per customer |
| **redeemQuantityPerActivation** | number | yes | Redemption quantity per activation |
| **currentRedeemedQuantity** | number | no | Current redemption quantity |
| **currentRedeemLimit** | number | no | Current redemption limit |
| **activationCounter** | number | no | Promotion's activation counter |
| **possibleRedeems** | number | no | Maximum number of promotion redemptions |
| **requireRedeemedPoints** | number | yes | Required redeemed points |
| **discountType** | [PromotionDiscountType](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscounttype) | yes | Discount type |
| **discountValue** | number | no | Discount value |
| **discountMode** | [PromotionDiscountMode](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscountmode) | no | Discount mode |
| **discountModeDetails** | [PromotionDiscountModeDetails](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscountmodedetails) | yes | Discount mode details |
| **priority** | number | no | Promotion's priority |
| **price** | number | no | Item price |
| **itemScope** | [PromotionItemScope](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionitemscope) | no | Promotion's item scope |
| **minBasketValue** | number | yes | Minimum basket value |
| **maxBasketValue** | number | yes | Maximum basket value |
| **name** | string | no | Promotion's name |
| **headline** | string | yes | Promotion's headline |
| **descriptionText** | string | yes | Promotion's description |
| **images** | [Array<[PromotionImage](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionimage)> | yes | List of promotion images |
| **startAt** | Date | yes | Start time of a promotion |
| **expireAt** | Date | yes | Expiration time of the promotion |
| **lastingAt** | Date | yes | Date when the promotion expires for the current profile |
| **lastingTime** | number | yes | Duration of the promotion in seconds |
| **displayFrom** | string | yes | Date as a string when the promotion starts being displayed |
| **displayTo** | string | yes | Date as a string when the promotions ends being displayed |
| **catalogIndexItems** | Array | yes | List of item indexes |
| **params** | object | yes | Promotion's custom parameters |
| **tags** | Array | yes | Promotion's custom tags |
---
---
### PromotionStatus
**Declared In:**
lib/classes/models/Promotions/PromotionStatus.js
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionStatus {
None = 'NONE',
Active = 'ACTIVE',
Assigned = 'ASSIGNED',
Redeemed = 'REDEEMED',
}
**Functions:**
Converts from **PromotionStatus** to **string**.
function PromotionStatusToString(promotionStatus: PromotionStatus): string
---
Converts from **string** to **PromotionStatus**.
function PromotionStatusFromString(string: string): PromotionStatus
---
---
### PromotionType
**Declared In:**
lib/classes/models/Promotions/PromotionType.js
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionType {
Unknown = 'UNKNOWN',
MembersOnly = 'MEMBERS_ONLY',
Custom = 'CUSTOM',
General = 'GENERAL',
}
**Functions:**
Converts from **PromotionType** to **string**.
function PromotionTypeToString(promotionType: PromotionType): string
---
Converts from **string** to **PromotionType**.
function PromotionTypeFromString(string: string): PromotionType
---
---
### PromotionItemScope
**Declared In:**
lib/classes/models/Promotions/PromotionItemScope.js
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionItemScope {
LineItem = 'LINE_ITEM',
Basket = 'BASKET'
}
**Functions:**
Converts from **PromotionItemScope** to **string**.
function PromotionItemScopeToString(promotionItemScope: PromotionItemScope): string
---
Converts from **string** to **PromotionItemScope**.
function PromotionItemScopeFromString(string: string): PromotionItemScope
---
---
### PromotionDetails
**Declared In:**
lib/classes/models/Promotions/PromotionDetails.js
**Related To:**
[PromotionDiscountTypeDetails](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscounttypedetails)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class PromotionDetails extends BaseModel {
discountType: PromotionDiscountTypeDetails;
}
**Properties:**
Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **discountType** | [PromotionDiscountTypeDetails](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscounttypedetails) | yes | Discount details |
---
---
### PromotionDiscountTypeDetails
**Declared In:**
lib/classes/models/Promotions/PromotionDiscountTypeDetails.js
**Related To:**
[PromotionDetails](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondetails)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class PromotionDiscountTypeDetails extends BaseModel {
name: string;
outerScope: boolean;
requiredItemsCount: number;
discountedItemsCount: number;
}
**Properties:**
Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **name** | string | no | Discount’s name |
| **outerScope** | boolean | no | When `true`, the items required to trigger the promotion are different than the items included in that promotion. |
| **requiredItemsCount** | number | no | Number of items required to qualify for the discount |
| **discountedItemsCount** | number | no | Number of discounted items |
---
---
### PromotionDiscountMode
**Declared In:**
lib/classes/models/Promotions/PromotionDiscountMode.js
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionDiscountMode {
Static = 'STATIC',
Step = 'STEP'
}
**Functions:**
Converts from **PromotionDiscountMode** to **string**.
function PromotionDiscountModeToString(promotionDiscountMode: PromotionDiscountMode): string
---
Converts from **string** to **PromotionDiscountMode**.
function PromotionDiscountModeFromString(string: string): PromotionDiscountMode
---
---
### PromotionDiscountModeDetails
**Declared In:**
lib/classes/models/Promotions/PromotionDiscountModeDetails.js
**Related To:**
[PromotionDiscountStep](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscountstep)
[PromotionDiscountUsageTrigger](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscountusagetrigger)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class PromotionDiscountModeDetails extends BaseModel {
discountSteps: Array<PromotionDiscountStep>;
discountUsageTrigger: PromotionDiscountUsageTrigger;
}
**Properties:**
Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **discountSteps** | Array<[PromotionDiscountStep](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscountstep)> | no | List of discount steps |
| **discountUsageTrigger** | [PromotionDiscountUsageTrigger](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscountusagetrigger) | no | Usage trigger for the discount |
---
---
### PromotionDiscountStep
**Declared In:**
lib/classes/models/Promotions/PromotionDiscountStep.js
**Related To:**
[PromotionDiscountModeDetails](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiondiscountmodedetails)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class PromotionDiscountStep extends BaseModel {
discountValue: number;
usageThreshold: number;
}
**Properties:**
Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **discountValue** | number | no | Value of the discount |
| **usageThreshold** | number | no | Usage threshold |
---
---
### PromotionDiscountUsageTrigger
**Declared In:**
lib/classes/models/Promotions/PromotionDiscountUsageTrigger.js
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionDiscountUsageTrigger {
Transaction = 'TRANSACTION',
Redeem = 'REDEEM'
}
**Functions:**
Converts from **PromotionDiscountUsageTrigger** to **string**.
function PromotionDiscountUsageTriggerToString(promotionDiscountUsageTrigger: PromotionDiscountUsageTrigger): string
---
Converts from **string** to **PromotionDiscountUsageTrigger**.
function PromotionDiscountUsageTriggerFromString(string: string): PromotionDiscountUsageTrigger
---
---
### PromotionImage
**Declared In:**
lib/classes/models/Promotions/PromotionImage.js
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotion)
[PromotionImageType](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionimagetype)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class PromotionImage extends BaseModel {
url: string;
type: PromotionImageType;
}
**Properties:**
Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **url** | string | no | URL of the image |
| **type** | [PromotionImageType](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionimagetype) | no | Image type |
---
---
### PromotionImageType
**Declared In:**
lib/classes/models/Promotions/PromotionImageType.js
**Related To:**
[PromotionImage](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionimage)
**Declaration:**
enum PromotionImageType {
Image = 'image',
Thumbnail = 'thumbnail'
}
**Functions:**
Converts from **PromotionImageType** to **string**.
function PromotionImageTypeToString(promotionImageType: PromotionImageType): string
---
Converts from **string** to **PromotionImageType**.
function PromotionImageTypeFromString(string: string): PromotionImageType
---
---
### PromotionDiscountType
**Declared In:**
lib/classes/models/Promotions/PromotionDiscountType.js
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionDiscountType {
None = 'NONE',
Percent = 'PERCENT',
Amount = 'AMOUNT',
TwoForOne = '2_FOR_1',
Points = 'POINTS',
Multibuy = 'MULTIBUY',
}
**Functions:**
Converts from **PromotionDiscountType** to **string**.
function PromotionDiscountTypeToString(promotionDiscountType: PromotionDiscountType): string
---
Converts from **string** to **PromotionDiscountType**.
function PromotionDiscountTypeFromString(string: string): PromotionDiscountType
---
---
### PromotionIdentifier
**Declared In:**
lib/classes/models/Promotions/PromotionIdentifier.js
**Declaration:**
class PromotionIdentifier {
key: string;
value: string;
}
**Properties:**
Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **key** | string | yes | | Promotion identifier type (see [PromotionIdentifierKey enum](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionidentifierkey))|
| **value** | string | yes | | Promotion identifier value |
**Initializers:**
constructor(key: PromotionIdentifierKey, value: string)
---
---
### PromotionIdentifierKey
**Declared In:**
lib/classes/models/Promotions/PromotionIdentifierKey.js
**Declaration:**
enum PromotionIdentifierKey {
Uuid = 'UUID',
Code = 'CODE',
}
---
---
### PromotionsApiQuery
Object for setting parameters to facilitate fetching promotions from the API.
**Declared In:**
lib/classes/models/api_queries/PromotionsApiQuery.js
**Related To:**
[PromotionResponse](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionresponse)
[Promotion](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotion)
**Inherits From:**
[BaseApiQuery](/developers/mobile-sdk/class-reference/react-native/miscellaneous#baseapiquery)
**Declaration:**
class PromotionsApiQuery extends BaseApiQuery
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **statuses** | [Array](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotionstatus) | no | [] | List of promotion statuses for query |
| **types** | [Array](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#promotiontype) | no | [] | List of promotion types for query |
- Check the list of promotion sorting keys available in [Loyalty - Promotion sorting options](/developers/mobile-sdk/loyalty#promotion-sorting-options) section.
- See [ApiQuerySortingOrderString](/developers/mobile-sdk/class-reference/react-native/miscellaneous#apiquerysortingorder) to check ordering options.
**Initializers:**
constructor()
---
---
## Vouchers
---
### AssignVoucherResponse
**Declared In:**
lib/classes/models/Vouchers/AssignVoucherResponse.js
**Related To:**
[AssignVoucherData](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#assignvoucherdata)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class AssignVoucherResponse extends BaseModel
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **message** | string | no | Message from the Voucher assignment response |
| **assignVoucherData** | [AssignVoucherData](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#assignvoucherdata) | yes | List of vouchers in a pool |
---
---
### VoucherCodesResponse
**Declared In:**
lib/classes/models/Vouchers/VoucherCodesResponse.js
**Related To:**
[VoucherCodesData](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#vouchercodesdata)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class VoucherCodesResponse extends BaseModel
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **items** | Array<[VoucherCodesData](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#vouchercodesdata)> | no | List of voucher items |
---
---
### AssignVoucherData
**Declared In:**
lib/classes/models/Vouchers/AssignVoucherData.js
**Related To:**
[AssignVoucherResponse](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#assignvoucherresponse)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class AssignVoucherData extends BaseModel
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **code** | string | no | Voucher's code |
| **expireIn** | Date | yes | Voucher's expiration date |
| **redeemAt** | Date | yes | Voucher's redemption date |
| **assignedAt** | Date | yes | Voucher's assignment date |
| **createdAt** | Date | no | Voucher's creation date |
| **updatedAt** | Date | no | Voucher's update date |
---
---
### VoucherCodesData
**Declared In:**
lib/classes/models/Vouchers/VoucherCodesData.js
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class VoucherCodesData extends BaseModel
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **code** | string | no | Voucher's code |
| **status** | [VoucherCodeStatus](/developers/mobile-sdk/class-reference/react-native/promotions-and-vouchers#vouchercodestatus) | no | Voucher's status |
| **clientId** | string | no | ID of the customer to whom the voucher is assigned |
| **clientUuid** | string | no | UUID of the customer to whom the voucher is assigned |
| **poolUuid** | string | no | Voucher's pool ID |
| **expireIn** | string | no | Voucher's expiration date |
| **redeemAt** | Date | no | Voucher's redemption date |
| **assignedAt** | Date | no | Voucher's assignment date |
| **createdAt** | Date | no | Voucher's creation date |
| **updatedAt** | Date | no | Voucher's update date|
---
---
### VoucherCodeStatus
**Declared In:**
lib/classes/models/Vouchers/VoucherCodeStatus.js
**Declaration:**
enum VoucherCodeStatus {
Unassigned = 'UNASSIGNED',
Assigned = 'ASSIGNED',
Redeemed = 'REDEEMED',
Canceled = 'CANCELED',
}
**Functions:**
Converts from **VoucherCodeStatus** to **string**.
function VoucherCodeStatusToString(voucherCodeStatus: VoucherCodeStatus): string
---
Converts from **string** to **VoucherCodeStatus**.
function VoucherCodeStatusFromString(string: string): VoucherCodeStatus
# Recommendations and Documents
## Recommendations
---
### RecommendationResponse
Model representing a response with recommendations.
This is a read-only class and it is not meant to be instantiated directly.
**Declared In:**
lib/model/content/recommendation_response.dart
**Related To:**
[Recommendation](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendation)
**Declaration:**
class RecommendationResponse
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **name** | String | no | Name of the recommendation campaign |
| **campaignHash** | String | no | Hash (UUID) of the recommendation campaign |
| **campaignID** | String | no | ID of the recommendation campaign |
| **items** | List<[Recommendation](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendation)> | no | List of items in the recommendation |
| **correlationID** | String | no | Recommendation's correlation ID. It can be added to a `recommendation.click` event to associate it with the recommendation request |
| **schema** | String | no | Schema of the document which contains the recommendation |
| **slug** | String | no | Slug of the document |
| **uuid** | String | no | UUID of the document |
---
---
### Recommendation
Model representating a recommendation item data.
This is a read-only class and it is not meant to be instantiated directly.
**Declared In:**
lib/model/content/recommendation.dart
**Related To:**
[RecommendationResponse](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendationresponse)
**Declaration:**
class Recommendation
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **itemID** | String | no | Product's GTIN |
| **attributes** | Map | no | Product's recommendation attributes |
---
---
### RecommendationOptions
**Declared In:**
lib/model/content/recommendation_options.dart
**Related To:**
[RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendationfiltersjoinerrule)
**Declaration:**
class RecommendationOptions
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **slug** | String | no | Unique identifier of a document which includes a recommendation insert |
| **productID** | String | yes | Item identifier (for single ID) |
| **itemsIds** | List | yes | List of item identifiers (for multiple IDs) |
| **itemsExcluded** | List | yes | Items that will be excluded from the generated recommendations |
| **additionalFilters** | String | yes | Additional filters. These are merged with the campaign's own filters according to the logic in **filtersJoiner** |
| **filtersJoiner** | [RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendationfiltersjoinerrule) | yes | Defines the logic of merging additionalFilters with the campaign's existing filters |
| **additionalElasticFilters** | String | yes | Additional elastic filters. These are merged with the campaign's own elastic filters according to the logic in **elasticFiltersJoiner** |
| **elasticFiltersJoiner** | [RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendationfiltersjoinerrule) | yes | Defines the logic of merging **additionalElasticFilters** with the campaign's existing elastic filters |
| **displayAttribute** | List | yes | An array of item attributes which value will be returned in a recommendation response |
| **includeContextItems** | bool | yes | When true, the recommendation response will include context item metadata |
**Initializers:**
RecommendationOptions recommendationOptions = RecommendationOptions(
slug: slug,
productID: productId);
---
---
### RecommendationFiltersJoinerRule
**Declared In:**
lib/model/content/recommendation_options.dart
**Declaration:**
enum RecommendationFiltersJoinerRule {
and('and'),
or('or'),
replace('replace');
**Functions:**
Converts from **RecommendationFiltersJoinerRule** to **String**.
Dart
```Dart
String recommendationFiltersJoinerRuleAsString()
```
Converts from **String** to **RecommendationFiltersJoinerRule**.
Dart
```Dart
static RecommendationFiltersJoinerRule? getRecommendationFiltersJoinerRuleFromString(String string)
```
---
---
## Documents
---
---
### DocumentApiQuery
Object for setting parameters to facilitate fetching documents from the API.
**Declared In:**
lib/model/content/document_api_query.dart
**Declaration:**
class DocumentApiQuery
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **slug** | String | no | Unique identifier of a document |
**Properties used only if the document includes a recommendation insert:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **productId** | String | yes | Item identifier of the context item |
| **itemsIds** | List | yes | List of item identifiers, used for multiple item context |
| **itemsExcluded** | List | yes | Items that will be excluded from the generated recommendations |
| **additionalFilters** | String | yes | Additional filters. These are merged with the campaign's own filters according to the logic in **filtersJoiner** |
| **filtersJoiner** | [RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendationfiltersjoinerrule) | no | Defines the logic of merging additionalFilters with the campaign's existing filters |
| **additionalElasticFilters** | String | yes | Additional elastic filters. These are merged with the campaign's own elastic filters according to the logic in **elasticFiltersJoiner** |
| **elasticFiltersJoiner** | [RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#recommendationfiltersjoinerrule) | no | Defines the logic of merging **additionalElasticFilters** with the campaign's existing elastic filters |
| **displayAttribute** | List | yes | An array of item attributes which value will be returned in a recommendation response |
| **includeContextItems** | bool | yes | When true, the recommendation response will include context item metadata |
**Initializers:**
DocumentApiQuery({
required this.slug,
this.productId,
this.itemsIds,
this.itemsExcluded,
this.additionalFilters,
this.filtersJoiner,
this.additionalElasticFilters,
this.elasticFiltersJoiner,
this.displayAttribute,
this.includeContextItems = false
});
---
---
### Document
**Declared In:**
lib/model/content/document.dart
**Declaration:**
class Document
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **uuid** | String | no | Document's identifier (this parameter was called **identifier** before version 2.0.0)|
| **slug** | String | no | Document's slug |
| **schema** | String | no | Document's schema type |
| **content** | Map | yes | Document's content |
All properties are read-only.
---
---
## Removed symbols
---
### DocumentsApiQuery{#documentsapiquery}
The object to set parameters easily for fetching documents from API.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 3.5.10 | 3.5.1 | 0.9.10 | 0.2.0 |
| Deprecated in: | 4.13.0 | 5.5.0 | 0.17.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
The object to set parameters easily for fetching documents from API.
**Declared In:**
lib/model/content/documents_api_query.dart
**Related To:**
[DocumentsApiQueryType](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#documentsapiquerytype)
**Declaration:**
class DocumentsApiQuery
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **type** | [DocumentsApiQueryType](/developers/mobile-sdk/class-reference/flutter/recommendations-and-documents#documentsapiquerytype) | no | .bySchema | Query type |
| **typeValue** | String | no | null | Value for query type |
| **version** | String | yes | null | Specifies the document version |
**Initializers:**
DocumentsApiQuery({required this.type, required this.typeValue, this.version})
---
---
### DocumentsApiQueryType{#documentsapiquerytype}
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 3.5.10 | 3.5.1 | 0.9.10 | 0.2.0 |
| Deprecated in: | 4.13.0 | 5.5.0 | 0.17.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
**Declared In:**
lib/enums/content/documents_api_query_type.dart
**Declaration:**
enum DocumentsApiQueryType {
schema('by-schema');
}
# Event tracking
## Set Tracker Delegate
---
This method sets an object for Tracker module delegate methods.
**Declared In:**
Headers/SNRTracker.h
**Related To:**
[TrackerDelegate](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#tracker-delegate)
**Class:**
[Tracker](/developers/mobile-sdk/class-reference/ios/modules#tracker)
**Declaration:**
Swift Objective-C
```Swift
static func setDelegate(_ delegate: TrackerDelegate)
```
```Objective-C
+ (void)setDelegate:(SNRTrackerDelegate *)delegate
```
**Discussion:**
Learn more about the methods and the purpose of this listener [here](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#tracker-delegate).
## Get customer's events
---
This method retrieves events for an authenticated customer.
This method requires customer authentication.
**Declared In:**
Headers/SNRClient.h
**Related To:**
[ClientEventsApiQuery](/developers/mobile-sdk/class-reference/ios/client#clienteventsapiquery)
**Class:**
[Client](/developers/mobile-sdk/class-reference/ios/modules#client)
**Declaration:**
Swift Objective-C
```Swift
static func getEvents(apiQuery: ClientEventsApiQuery, success: (([ClientEventData]) -> Void), failure: ((ApiError) -> Void)) -> Void
```
```Objective-C
+ (void)getEventsWithApiQuery:(nonnull SNRClientEventsApiQuery *)apiQuery success:(nonnull void (^)(NSArray *events))success failure:(nonnull void (^)(NSError *error))failure
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **apiQuery** | [ClientEventsApiQuery](/developers/mobile-sdk/class-reference/ios/client#clienteventsapiquery) | yes | - | Object responsible for storing all query parameters |
| **success** | (([ClientEventData]) -> Void) | yes | - | Closure/Block to be executed when the operation is completed successfully |
| **failure** | (([ApiError](/developers/mobile-sdk/class-reference/ios/miscellaneous#snrapierror)) -> Void) | yes | - | Closure/Block to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
## Set custom identifier for events
---
This method sets a custom identifier in the parameters of every event.
You can pass a custom identifier to match your customers in our database.
**Declared In:**
Headers/SNRTracker.h
**Class:**
[Tracker](/developers/mobile-sdk/class-reference/ios/modules#tracker)
**Declaration:**
Swift Objective-C
```Swift
static func setCustomIdentifier(customIdentifier: String?) -> Void
```
```Objective-C
+ (void)setCustomIdentifier:(nullable NSString *)customIdentifier;
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **customIdentifier** | String | no | - | Customer's custom identifier |
**Return Value:**
No value is returned.
## Set custom email for events
---
This method sets a custom email in the parameters of every event.
You can pass a custom email to match your customers in our database.
**Declared In:**
Headers/SNRTracker.h
**Class:**
[Tracker](/developers/mobile-sdk/class-reference/ios/modules#tracker)
**Declaration:**
Swift Objective-C
```Swift
static func setCustomEmail(customEmail: String?) -> Void
```
```Objective-C
+ (void)setCustomEmail:(nullable NSString *)customEmail;
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **customEmail** | String | no | - | Customer's custom email |
**Return Value:**
No value is returned.
## Send event
---
This method sends an event.
DO NOT send `transaction.charge` events as custom events.
Transactions must be tracked with these endpoints:
- [`/v4/transactions`](https://hub.synerise.com/api-reference/data-management#operation/CreateATransaction) (single transaction)
- [`/v4/transactions/batch`](https://hub.synerise.com/api-reference/data-management#operation/BatchAddOrUpdateTransactions) (multiple transactions)
- The tracker caches and enqueues all your events locally, so they all will be sent eventually.
- The API key must have the `API_BATCH_EVENTS_CREATE` permission from the **Events** group.
**Declared In:**
Headers/SNRTracker.h
**Related To:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Class:**
[Tracker](/developers/mobile-sdk/class-reference/ios/modules#tracker)
**Declaration:**
Swift Objective-C
```Swift
static func send(_: Event) -> Void
```
```Objective-C
+ (void)send:(SNREvent *)event
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **event** | [Event](/developers/mobile-sdk/class-reference/ios/events#event) | yes | - | [Event](/developers/mobile-sdk/class-reference/ios/events#event) object |
**Return Value:**
No value is returned.
**Example:**
You may use standard objects in SDK, for example `ProductAddedToCartEvent` that represents a 'customer added a product to cart' event:
Swift Objective-C
```Swift
let event: ProductAddedToCartEvent = ProductAddedToCartEvent(label: "Product added!", sku: "12345", finalPrice: UnitPrice(amount: 100.0), quantity: 1)
event.setCategory("Smartphones")
event.setName("iPhone")
event.setProducer("Apple")
Tracker.send(event)
```
```Objective-C
SNRProductAddedToCartEvent *event = [[SNRProductAddedToCartEvent alloc] initWithLabel:@"Product added!" sku:@"12345" finalPrice:[[SNRUnitPrice alloc] initWithAmount:100.0f] quantity:1];
[event setCategory:@"Smartphones"];
[event setName:@"iPhone"];
[event setProducer:@"Apple"];
[SNRTracker send:event];
```
You can also pass additional parameters along with `ProductAddedToCartEvent` and other events, like in the example below:
Swift Objective-C
```Swift
let params: TrackerParams = TrackerParams.make { (builder) in
builder.setString("12345", forKey: "snr_sku")
builder.setInt(1, forKey: "snr_quantity")
builder.setDouble(100.0, forKey: "snr_finalPrice")
}
let event: ProductAddedToCartEvent = ProductAddedToCartEvent(label: "Product added!", sku: "12345", finalPrice: UnitPrice(amount: 100.0), quantity: 1, params: params)
event.setCategory("Smartphones")
event.setName("iPhone")
event.setProducer("Apple")
Tracker.send(event)
```
```Objective-C
SNRTrackerParams *params = [SNRTrackerParams makeWithBuilder:^(SNRTrackerParamsBuilder *builder) {
[builder setString:@"12345" forKey:@"snr_sku"];
[builder setInt:1 forKey:@"snr_quantity"];
[builder setDouble:100.0f forKey:@"snr_finalPrice"];
}];
SNRProductAddedToCartEvent *event = [[SNRProductAddedToCartEvent alloc] initWithLabel:@"Product added!" sku:@"12345" finalPrice:[[SNRUnitPrice alloc] initWithAmount:100.0f] quantity:1 andParams:params];
[event setCategory:@"Smartphones"];
[event setName:@"iPhone"];
[event setProducer:@"Apple"];
[SNRTracker send:event];
```
If you want to track a fully customizable event, you should use `CustomEvent`:
Swift Objective-C
```Swift
let params: TrackerParams = TrackerParams.make { (builder) in
builder.setString("12345", forKey:"key_string");
builder.setInt(1, forKey:"key_integer");
builder.setDouble(1.0, forKey:"key_double");
builder.setFloat(1.0, forKey:"key_float");
builder.setBool(true, forKey:"key_bool");
builder.setObject(["key": "value"], forKey:"key_object");
}
let event: CustomEvent = CustomEvent(label: "custom event", action: "custom event action", params: params)
Tracker.send(event)
```
```Objective-C
SNRTrackerParams *params = [SNRTrackerParams makeWithBuilder:^(SNRTrackerParamsBuilder *builder) {
[builder setString:@"string" forKey:@"key_string"];
[builder setInt:1 forKey:@"key_integer"];
[builder setDouble:1.0f forKey:@"key_double"];
[builder setFloat:1.0f forKey:@"key_float"];
[builder setBool:YES forKey:@"key_bool"];
[builder setObject:@{ @"key" : @"value" } forKey:@"key_object"];
}];
SNRCustomEvent *event = [[SNRCustomEvent alloc] initWithLabel:"custom event" action:@"custom event action" andParams:params];
[SNRTracker send:event];
```
## Flush events from Tracker
---
This method forces sending the events from the queue to the server.
The API key must have the `API_BATCH_EVENTS_CREATE` permission from the **Events** group.
**Declared In:**
Headers/SNRTracker.h
**Related To:**
[Event](/developers/mobile-sdk/class-reference/ios/events#event)
[TrackerParams](/developers/mobile-sdk/class-reference/ios/events#trackerparams)
[TrackerParamsBuilder](/developers/mobile-sdk/class-reference/ios/events#trackerparamsbuilder)
**Class:**
[Tracker](/developers/mobile-sdk/class-reference/ios/modules#tracker)
**Declaration:**
Swift Objective-C
```Swift
static func flushEvents(completionHandler: (() -> Void)?) -> Void
```
```Objective-C
+ (void)flushEventsWithCompletionHandler:(nullable void (^)(void))completion
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **completionHandler** | (() -> Void) | no | - | Block/Closure to be executed when the tracker has finished flushing events to Synerise backend, no matter the result |
**Return Value:**
No value is returned.
# Event tracking
---
## Set custom identifier for events
---
This method sets a custom identifier in the parameters of every event.
You can pass a custom identifier to match your customers in our database.
**Declared In:**
lib/main/modules/TrackerModule.js
**Class:**
[TrackerModule](/developers/mobile-sdk/class-reference/react-native/modules#tracker)
**Declaration:**
public setCustomIdentifier(identifier: string)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **identifier** | string | yes | - | Customer's custom identifier |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Tracker.setCustomIdentifier("CUSTOM_IDENTIFIER");
```
## Set custom email for events
---
This method sets a custom email in the parameters of every event.
You can pass a custom email to match your customers in our database.
**Declared In:**
lib/main/modules/TrackerModule.js
**Class:**
[TrackerModule](/developers/mobile-sdk/class-reference/react-native/modules#tracker)
**Declaration:**
public setCustomEmail(email: string)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | string | yes | - | Customer's custom email |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Tracker.setCustomEmail("CUSTOM_EMAIL");
```
## Send event
---
This method sends an event.
DO NOT send `transaction.charge` events as custom events.
Transactions must be tracked with these endpoints:
- [`/v4/transactions`](https://hub.synerise.com/api-reference/data-management#operation/CreateATransaction) (single transaction)
- [`/v4/transactions/batch`](https://hub.synerise.com/api-reference/data-management#operation/BatchAddOrUpdateTransactions) (multiple transactions)
- The tracker caches and enqueues all your events locally, so they all will be sent eventually.
- The API key must have the `API_BATCH_EVENTS_CREATE` permission from the **Events** group.
**Declared In:**
lib/main/modules/TrackerModule.js
**Related To:**
[Event](/developers/mobile-sdk/class-reference/react-native/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/react-native/events#customevent)
**Class:**
[TrackerModule](/developers/mobile-sdk/class-reference/react-native/modules#tracker)
**Declaration:**
public send(event: Event)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **event** | **Event** | yes | - | Event object |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
let parameters = {
"name": "John",
"surname": "Rise",
"company": "Synerise",
"age": 25,
"lastOrder": 380.50
};
let event = new CustomEvent("label", "my.action", parameters);
Synerise.Tracker.send(event);
```
## Flush events from Tracker
---
This method forces sending the events from the queue to the server.
The API key must have the `API_BATCH_EVENTS_CREATE` permission from the **Events** group.
**Declared In:**
lib/main/modules/TrackerModule.js
**Class:**
[TrackerModule](/developers/mobile-sdk/class-reference/react-native/modules#tracker)
**Declaration:**
public flushEvents(onSuccess: () => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Tracker.flushEvents(function() {
// success
});
```
# Event tracking
---
## Set custom identifier for events
---
This method sets a custom identifier in the parameters of every event.
You can pass a custom identifier to match your customers in our database.
**Declared In:**
lib/modules/tracker/tracker_impl.dart
**Class:**
[TrackerImpl](/developers/mobile-sdk/class-reference/flutter/modules#tracker)
**Declaration:**
Future<void> setCustomIdentifier(String customIdentifier)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **identifier** | String | yes | - | Customer’s custom identifier |
**Return Value:**
No value is returned.
**Example:**
Dart
```Dart
await Synerise.tracker.setCustomIdentifier("CUSTOM_IDENTIFIER");
```
## Set custom email for events
---
This method sets a custom email in the parameters of every event.
You can pass a custom email to match your customers in our database.
**Declared In:**
lib/modules/tracker/tracker_impl.dart
**Class:**
[TrackerImpl](/developers/mobile-sdk/class-reference/flutter/modules#tracker)
**Declaration:**
Future<void> setCustomEmail(String customEmail)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **email** | String | yes | - | Customer’s custom email |
**Return Value:**
No value is returned.
**Example:**
Dart
```Dart
await Synerise.tracker.setCustomEmail("CUSTOM_EMAIL");
```
## Send event
---
This method sends an event.
DO NOT send `transaction.charge` events as custom events.
Transactions must be tracked with these endpoints:
- [`/v4/transactions`](https://hub.synerise.com/api-reference/data-management#operation/CreateATransaction) (single transaction)
- [`/v4/transactions/batch`](https://hub.synerise.com/api-reference/data-management#operation/BatchAddOrUpdateTransactions) (multiple transactions)
- The tracker caches and enqueues all your events locally, so they all will be sent eventually.
- The API key must have the `API_BATCH_EVENTS_CREATE` permission from the **Events** group.
**Declared In:**
lib/modules/tracker/tracker_impl.dart
**Related To:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Class:**
[TrackerImpl](/developers/mobile-sdk/class-reference/flutter/modules#tracker)
**Declaration:**
Future<void> send(Event event)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **event** | [Event](/developers/mobile-sdk/class-reference/flutter/events#event) | yes | - | Event object |
**Return Value:**
No value is returned.
**Example:**
Dart
```Dart
final paramMap = {"firstKeyCustomParam": "TEST"};
CustomEvent event = CustomEvent("label", "flutter", paramMap);
await Synerise.tracker.send(event);
```
## Flush events from Tracker
---
This method forces sending the events from the queue to the server.
The API key must have the `API_BATCH_EVENTS_CREATE` permission from the **Events** group.
**Declared In:**
lib/modules/tracker/tracker_impl.dart
**Related To:**
[Event](/developers/mobile-sdk/class-reference/flutter/events#event)
[CustomEvent](/developers/mobile-sdk/class-reference/flutter/events#customevent)
**Class:**
[TrackerImpl](/developers/mobile-sdk/class-reference/flutter/modules#tracker)
**Declaration:**
Future<void> flush()
**Return Value:**
No value is returned.
**Example:**
Dart
```Dart
await Synerise.tracker.flush();
```
# Promotions and Vouchers
## Promotions
---
### PromotionResponse
**Declared In:**
Headers/SNRPromotionResponse.h
**Related To:**
[PromotionResponseMetadata](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionresponsemetadata)
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class PromotionResponse: BaseModel
```
```Objective-C
@interface SNRPromotionResponse : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **metadata** | [PromotionResponseMetadata](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionresponsemetadata) | yes | Metadata of the promotion response |
| **items** | [[Promotion]](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers/#promotion) | no | List of promotion items |
All properties are read-only.
---
---
### PromotionResponseMetadata
**Declared In:**
Headers/SNRPromotionResponseMetadata.h
**Related To:**
[PromotionResponse](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionresponse)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class PromotionResponseMetadata: BaseModel
```
```Objective-C
@interface SNRPromotionResponseMetadata : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **totalCount** | Int | no | Total count of promotions |
| **totalPages** | Int | no | Total count of pages |
| **page** | Int | no | Current page |
| **limit** | Int | no | Limit of promotions per page |
| **code** | Int | no | HTTP code of the response |
All properties are read-only.
---
---
### Promotion
**Declared In:**
Headers/SNRPromotion.h
**Related To:**
[PromotionResponse](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionresponse)
[PromotionStatus](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionstatus)
[PromotionType](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiontype)
[PromotionDetails](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondetails)
[PromotionItemScope](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionitemscope)
[PromotionDiscountType](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscounttype)
[PromotionDiscountMode](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscountmode)
[PromotionDiscountModeDetails](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscountmodedetails)
[PromotionImage](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionimage)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class Promotion: BaseModel
```
```Objective-C
@interface SNRPromotion : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **uuid** | String | no | Promotion's UUID |
| **code** | String | no | Promotion's code |
| **status** | [PromotionStatus](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionstatus) | no | Promotion's status |
| **type** | [PromotionType](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiontype) | no | Promotion's type |
| **details** | [PromotionDetails](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondetails) | yes | Promotion's details |
| **redeemLimitPerClient** | NSNumber | yes | Redemption limit per customer |
| **redeemQuantityPerActivation** | NSNumber | yes | Redemption quantity per activation |
| **currentRedeemedQuantity** | NSNumber | no | Current redemption quantity |
| **currentRedeemLimit** | NSNumber | no | Current redemption limit |
| **activationCounter** | NSNumber | no | Promotion's activation counter |
| **possibleRedeems** | NSNumber | no | Maximum number of promotion redemptions |
| **requireRedeemedPoints** | NSNumber | yes | Required redeemed points |
| **discountType** | [PromotionDiscountType](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscounttype) | no | Discount type |
| **discountValue** | NSNumber | no | Discount value |
| **discountMode** | [PromotionDiscountMode](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscountmode) | no | Discount mode |
| **discountModeDetails** | [PromotionDiscountModeDetails](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscountmodedetails) | yes | Discount mode details |
| **priority** | NSNumber | no | Promotion's priority |
| **price** | NSNumber | no | Item price |
| **itemScope** | [PromotionItemScope](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionitemscope) | no | Promotion's item scope |
| **minBasketValue** | NSNumber | yes | Minimum basket value |
| **maxBasketValue** | NSNumber | yes | Maximum basket value |
| **name** | String | no | Promotion's name |
| **headline** | String | yes | Promotion's headline |
| **descriptionText** | String | yes | Promotion's description |
| **images** | [[PromotionImage](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionimage)] | yes | List of promotion images |
| **startAt** | Date | yes | Start time of a promotion |
| **expireAt** | Date | yes | Expiration time of the promotion |
| **lastingAt** | Date | yes | Date when the promotion expires for the current profile |
| **lastingTime** | NSNumber | yes | Duration of the promotion in seconds |
| **displayFrom** | String | yes | Date as a string when the promotion starts being displayed |
| **displayTo** | String | yes | Date as a string when the promotions ends being displayed |
| **catalogIndexItems** | [String] | yes | List of item indexes |
| **params** | [AnyHashable: Any] | yes | Promotion's custom parameters |
| **tags** | [AnyObject] | yes | Promotion's custom tags |
All properties are read-only.
---
---
### PromotionStatus
**Declared In:**
Headers/SNRPromotionStatus.h
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
**Declaration:**
Swift Objective-C
```Swift
enum PromotionStatus: Int {
none,
active,
assigned,
redeemed
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRPromotionStatus) {
SNRPromotionStatusNone = 0,
SNRPromotionStatusActive,
SNRPromotionStatusAssigned,
SNRPromotionStatusRedeemed
}
```
**Functions:**
Converts from **PromotionStatus** to **String**.
Swift Objective-C
```Swift
func SNR_PromotionStatusToString(_: PromotionStatus) -> String
```
```Objective-C
NSString * SNR_PromotionStatusToString(SNRPromotionStatus type)
```
---
Converts from **String** to **PromotionStatus**.
Swift Objective-C
```Swift
func SNR_StringToPromotionStatus(_: String) -> PromotionStatus
```
```Objective-C
SNRPromotionStatus SNR_StringToPromotionStatus(NSString * _Nullable string)
```
**Note:**
The following string constants can be used in [PromotionsApiQuery](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionsapiquery) object:
- SNR_PROMOTION_STATUS_NONE
- SNR_PROMOTION_STATUS_ACTIVE
- SNR_PROMOTION_STATUS_ASSIGNED
- SNR_PROMOTION_STATUS_REDEEMED
---
---
### PromotionType
**Declared In:**
Headers/SNRPromotionType.h
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
**Declaration:**
Swift Objective-C
```Swift
enum PromotionType: Int {
unknown,
membersOnly,
custom,
general,
handbill
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRPromotionType) {
SNRPromotionTypeUnknown = 0,
SNRPromotionTypeMembersOnly,
SNRPromotionTypeCustom,
SNRPromotionTypeGeneral,
SNRPromotionTypeHandbill
}
```
**Functions:**
Converts from **PromotionType** to **String**.
Swift Objective-C
```Swift
func SNR_PromotionTypeToString(_: PromotionType) -> String
```
```Objective-C
NSString * SNR_PromotionTypeToString(SNRPromotionType type)
```
---
Converts from **String** to **PromotionType**.
Swift Objective-C
```Swift
func SNR_StringToPromotionType(_: String) -> PromotionType
```
```Objective-C
SNRPromotionType SNR_StringToPromotionType(NSString * _Nullable string)
```
**Note:**
The following string constants can be used in [PromotionsApiQuery](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionsapiquery) object:
- SNR_PROMOTION_TYPE_UNKNOWN
- SNR_PROMOTION_TYPE_MEMBERS_ONLY
- SNR_PROMOTION_TYPE_CUSTOM
- SNR_PROMOTION_TYPE_GENERAL
---
---
### PromotionItemScope
**Declared In:**
Headers/SNRPromotionItemScope.h
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
**Declaration:**
Swift Objective-C
```Swift
enum PromotionItemScope: Int {
lineItem,
basket
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRPromotionItemScope) {
SNRPromotionItemScopeLineItem = 0,
SNRPromotionItemScopeBasket
}
```
**Functions:**
Converts from **PromotionItemScope** to **String**.
Swift Objective-C
```Swift
func SNR_PromotionItemScopeToString(_: PromotionItemScope) -> String
```
```Objective-C
NSString * SNR_PromotionItemScopeToString(SNRPromotionItemScope scope)
```
---
Converts from **String** to **PromotionItemScope**.
Swift Objective-C
```Swift
func SNR_StringToPromotionItemScope(_: String) -> PromotionItemScope
```
```Objective-C
SNRPromotionItemScope SNR_StringToPromotionItemScope(NSString * _Nullable string)
```
---
---
### PromotionDetails
**Declared In:**
Headers/SNRPromotionDetails.h
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
[PromotionDiscountTypeDetails](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscounttypedetails)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class PromotionDetails: BaseModel
```
```Objective-C
@interface SNRPromotionDetails : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **discountType** | [PromotionDiscountTypeDetails](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscounttypedetails) | no | Discount details |
All properties are read-only.
---
---
### PromotionDiscountTypeDetails
**Declared In:**
Headers/SNRPromotionDiscountTypeDetails.h
**Related To:**
[PromotionDetails](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondetails)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class PromotionDiscountTypeDetails: BaseModel
```
```Objective-C
@interface SNRPromotionDiscountTypeDetails : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **name** | String | no | Discount's name |
| **outerScope** | Bool | no | When `true`, the items required to trigger the promotion are different than the items included in that promotion. |
| **requiredItemsCount** | Int | no | Number of items required to qualify for the discount |
| **discountedItemsCount** | Int | no | Number of discounted items |
All properties are read-only.
---
---
### PromotionDiscountMode
**Declared In:**
Headers/SNRPromotionDiscountType.h
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
**Declaration:**
Swift Objective-C
```Swift
enum PromotionDiscountMode: Int {
static,
step
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRPromotionDiscountMode) {
SNRPromotionDiscountModeStatic = 0,
SNRPromotionDiscountModeStep
}
```
**Functions:**
Converts from **PromotionDiscountMode** to **String**.
Swift Objective-C
```Swift
func SNR_PromotionDiscountModeToString(_: PromotionDiscountMode) -> String
```
```Objective-C
NSString * SNR_PromotionDiscountModeToString(SNRPromotionDiscountMode mode)
```
---
Converts from **String** to **PromotionDiscountMode**.
Swift Objective-C
```Swift
func SNR_StringToPromotionDiscountMode(_: String) -> PromotionDiscountMode
```
```Objective-C
SNRPromotionDiscountMode SNR_StringToPromotionDiscountMode(NSString * _Nullable string)
```
---
---
### PromotionDiscountModeDetails
**Declared In:**
Headers/SNRPromotionDiscountModeDetails.h
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
[PromotionDiscountStep](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscountstep)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class PromotionDiscountModeDetails: BaseModel
```
```Objective-C
@interface SNRPromotionDiscountModeDetails : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **discountSteps** | [[SNRPromotionDiscountStep]](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers/#promotion) | no | List of discount steps |
| **discountUsageTrigger** | [PromotionDiscountUsageTrigger](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscountusagetrigger) | no | Usage trigger for the discount |
All properties are read-only.
---
---
### PromotionDiscountStep
**Declared In:**
Headers/SNRPromotionDiscountStep.h
**Related To:**
[PromotionDiscountModeDetails](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscountmodedetails)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class PromotionDiscountStep: BaseModel
```
```Objective-C
@interface SNRPromotionDiscountStep : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **discountValue** | NSNumber | no | Value of the discount |
| **usageThreshold** | NSNumber | no | Usage threshold |
All properties are read-only.
---
---
### PromotionDiscountUsageTrigger
**Declared In:**
Headers/SNRPromotionDiscountUsageTrigger.h
**Related To:**
[PromotionDiscountModeDetails](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotiondiscountmodedetails)
**Declaration:**
Swift Objective-C
```Swift
enum PromotionDiscountUsageTrigger: Int {
transaction,
redeem
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRPromotionDiscountUsageTrigger) {
SNRPromotionDiscountUsageTriggerTransaction = 0,
SNRPromotionDiscountUsageTriggerRedeem
}
```
**Functions:**
Converts from **PromotionDiscountUsageTrigger** to **String**.
Swift Objective-C
```Swift
func SNR_PromotionDiscountUsageTriggerToString(_: PromotionDiscountUsageTrigger) -> String
```
```Objective-C
NSString * SNR_PromotionDiscountUsageTriggerToString(SNRPromotionDiscountUsageTrigger trigger)
```
---
Converts from **String** to **PromotionDiscountUsageTrigger**.
Swift Objective-C
```Swift
func SNR_StringToPromotionDiscountUsageTrigger(_: String) -> PromotionDiscountUsageTrigger
```
```Objective-C
SNRPromotionDiscountUsageTrigger SNR_StringToPromotionDiscountUsageTrigger(NSString * _Nullable string)
```
---
---
### PromotionImage
**Declared In:**
Headers/SNRPromotion.h
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
[PromotionImageType](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionimagetype)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class PromotionImage: BaseModel
```
```Objective-C
@interface SNRPromotionImage : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **url** | String | no | Image's URL |
| **type** | [PromotionImageType](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionimagetype) | no | Image type |
All properties are read-only.
---
---
### PromotionImageType
**Declared In:**
Headers/SNRPromotionImageType.h
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
**Declaration:**
Swift Objective-C
```Swift
enum PromotionImageType: Int {
image,
thumbnail
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRPromotionImageType) {
SNRPromotionImageTypeImage = 0,
SNRPromotionImageTypeThumbnail
}
```
**Functions:**
Converts from **PromotionImageType** to **String**.
Swift Objective-C
```Swift
func SNR_PromotionImageTypeToString(_: PromotionImageType) -> String
```
```Objective-C
NSString * SNR_PromotionImageTypeToString(SNRPromotionImageType type)
```
---
Converts from **String** to **PromotionImageType**.
Swift Objective-C
```Swift
func SNR_StringToPromotionImageType(_: String) -> PromotionImageType
```
```Objective-C
SNRPromotionImageType SNR_StringToPromotionImageType(NSString * _Nullable string)
```
---
---
### PromotionDiscountType
**Declared In:**
Headers/SNRPromotionDiscountType.h
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
**Declaration:**
Swift Objective-C
```Swift
enum PromotionDiscountType: Int {
none,
percent,
amount,
2For1,
points,
multibuy,
exactPrice
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRPromotionDiscountType) {
SNRPromotionDiscountTypeNone = 0,
SNRPromotionDiscountTypePercent,
SNRPromotionDiscountTypeAmount,
SNRPromotionDiscountType2For1,
SNRPromotionDiscountTypePoints,
SNRPromotionDiscountTypeMultibuy,
SNRPromotionDiscountTypeExactPrice
}
```
**Functions:**
Converts from **PromotionDiscountType** to **String**.
Swift Objective-C
```Swift
func SNR_PromotionDiscountTypeToString(_: PromotionDiscountType) -> String
```
```Objective-C
NSString * SNR_PromotionDiscountTypeToString(SNRPromotionDiscountType type)
```
---
Converts from **String** to **PromotionDiscountType**.
Swift Objective-C
```Swift
func SNR_StringToPromotionDiscountType(_: String) -> PromotionDiscountType
```
```Objective-C
SNRPromotionDiscountType SNR_StringToPromotionDiscountType(NSString * _Nullable string)
```
---
---
### PromotionIdentifier
**Declared In:**
Headers/SNRPromotionIdentifier.h
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class PromotionIdentifier: BaseModel
```
```Objective-C
@interface SNRPromotionIdentifier : SNRBaseModel
```
**Initializers:**
Swift Objective-C
```Swift
init(uuid: String)
```
```Objective-C
- (instancetype)initWithUUID:(NSString *)UUID
```
---
Swift Objective-C
```Swift
init(code: String)
```
```Objective-C
- (instancetype)initWithCode:(NSString *)code
```
---
---
### PromotionsApiQuery
Object for setting parameters to facilitate fetching promotions from the API.
**Declared In:**
Headers/SNRPromotionsApiQuery.h
**Related To:**
[PromotionResponse](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotionresponse)
[Promotion](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#promotion)
[ApiQuerySortingOrderString](/developers/mobile-sdk/class-reference/ios/miscellaneous#apiquerysortingorder)
**Inherits From:**
[NSObject](https://developer.apple.com/documentation/objectivec/nsobject)
**Declaration:**
Swift Objective-C
```Swift
class PromotionsApiQuery: NSObject
```
```Objective-C
@interface SNRPromotionsApiQuery : NSObject
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **statuses** | [[SNRPromotionStatusString]](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers/#promotionstatus) | no | [] | List of promotion statuses for query |
| **types** | [[SNRPromotionTypeString]](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers/#promotiontype) | no | [] | List of promotion types for query |
| **sorting** | [[SNRPromotionSortingKey: SNRApiQuerySortingOrderString]] | yes | [] | Specifies sorting rules for items in the response |
| **limit** | Int | no | 100 | Limit of items per page in the response |
| **page** | Int | no | 1 | Page number |
| **includeMeta** | Bool | no | false | Specifies if meta data should be included in the response |
- Check the list of promotion sorting keys available in [Loyalty - Promotion sorting options](/developers/mobile-sdk/loyalty#promotion-sorting-options) section.
- See [ApiQuerySortingOrderString](/developers/mobile-sdk/class-reference/ios/miscellaneous#apiquerysortingorder) to check ordering options.
**Initializers:**
Swift Objective-C
```Swift
init()
```
```Objective-C
- (instancetype)init
```
---
---
## Vouchers
---
### AssignVoucherResponse
**Declared In:**
Headers/SNRAssignVoucherResponse.h
**Related To:**
[AssignVoucherData](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#assignvoucherdata)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class AssignVoucherResponse: BaseModel
```
```Objective-C
@interface SNRAssignVoucherResponse : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **message** | String | no | Message from the Voucher assignment response |
| **assignVoucherData** | [AssignVoucherData](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#assignvoucherdata) | yes | List of vouchers in a pool |
All properties are read-only.
---
---
### VoucherCodesResponse
**Declared In:**
Headers/SNRVoucherCodesResponse.h
**Related To:**
[SNRVoucherCodesData](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#vouchercodesdata)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class VoucherCodesResponse: BaseModel
```
```Objective-C
@interface SNRVoucherCodesResponse : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **items** | [[VoucherCodesData]](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers/#vouchercodesdata) | no | List of voucher items |
All properties are read-only.
---
---
### AssignVoucherData
**Declared In:**
Headers/SNRAssignVoucherData.h
**Related To:**
[AssignVoucherResponse](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#assignvoucherresponse)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class AssignVoucherData: BaseModel
```
```Objective-C
@interface SNRAssignVoucherData : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **code** | String | no | Voucher's code |
| **expireIn** | Date | yes | Voucher's expiration date |
| **redeemAt** | Date | yes | Voucher's redemption date |
| **assignedAt** | Date | yes | Voucher's assignment date |
| **createdAt** | Date | no | Voucher's creation date |
| **updatedAt** | Date | no | Voucher's update date |
All properties are read-only.
---
---
### VoucherCodesData
**Declared In:**
Headers/SNRVoucherCodesData.h
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class VoucherCodesData: BaseModel
```
```Objective-C
@interface SNRVoucherCodesData : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **code** | String | no | Voucher's code |
| **status** | [VoucherStatus](/developers/mobile-sdk/class-reference/ios/promotions-and-vouchers#voucherstatus) | no | Voucher's status |
| **clientId** | String | no | ID of the customer to whom the voucher is assigned |
| **clientUuid** | String | no | UUID of the customer to whom the voucher is assigned |
| **poolUuid** | String | no | Voucher's pool ID |
| **expireIn** | Date | no | Voucher's expiration date |
| **redeemAt** | Date | no | Voucher's redemption date |
| **assignedAt** | Date | no | Voucher's assignment date |
| **createdAt** | Date | no | Voucher's creation date |
| **updatedAt** | Date | no | Voucher's update date|
All properties are read-only.
---
---
### VoucherStatus
**Declared In:**
Headers/SNRVoucherStatus.h
**Declaration:**
Swift Objective-C
```Swift
enum VoucherStatus: Int {
unassigned,
assigned,
redeemed,
canceled
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRVoucherStatus) {
SNRVoucherStatusUnassigned = 0,
SNRVoucherStatusAssigned,
SNRVoucherStatusRedeemed,
SNRVoucherStatusCanceled
}
```
**Functions:**
Converts from **VoucherStatus** to **String**.
Swift Objective-C
```Swift
func SNR_VoucherStatusToString(_: VoucherStatus) -> String
```
```Objective-C
NSString * SNR_VoucherStatusToString(SNRVoucherStatus type)
```
---
Converts from **String** to **VoucherStatus**.
Swift Objective-C
```Swift
func SNR_StringToVoucherStatus(_: String) -> VoucherStatus
```
```Objective-C
SNRVoucherStatus SNR_StringToVoucherStatus(NSString * _Nullable string)
```
# Promotions and Vouchers
## Promotions
---
### PromotionResponse
Class model for a promotion response.
**Declared In:**
`com.synerise.sdk.promotions.model.promotion.PromotionResponse`
**Declaration:**
Java Kotlin
```Java
public class PromotionResponse
```
```Kotlin
class PromotionResponse
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **promotionMetadata** | [PromotionMetadata](/developers/mobile-sdk/class-reference/android/promotions-and-vouchers#promotionmetadata) | no | - | Metadata |
| **promotions** | List<[Promotion](/developers/mobile-sdk/class-reference/android/promotions-and-vouchers#promotion)> | no | - | List of promotions |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method retrieves the value of the `promotionMetadata` parameter.
public PromotionMetadata getPromotionMetadata()
---
This method retrieves a list of promotions.
public List<Promotion> getPromotions()
---
---
---
### SinglePromotionResponse
Class model for a single promotion response.
**Declared In:**
`com.synerise.sdk.promotions.model.promotion.SinglePromotionResponse`
**Declaration:**
Java Kotlin
```Java
public class SinglePromotionResponse
```
```Kotlin
class SinglePromotionResponse
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **promotion** | [Promotion](/developers/mobile-sdk/class-reference/android/promotions-and-vouchers#promotion) | no | - | Promotion |
All the properties above are accessible by using getters and setters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters and setters for the above properties.
This method retrieves the value of the `promotion` parameter.
public Promotion getPromotion()
---
This method defines the value of the `promotion` parameter.
public void setPromotion(Promotion data)
---
---
---
### PromotionMetadata
Class model for a promotion metadata.
**Declared In:**
`com.synerise.sdk.promotions.model.promotion.PromotionMetadata`
**Declaration:**
Java Kotlin
```Java
public class PromotionMetadata implements Serializable
```
```Kotlin
class PromotionMetadata : Serializable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **totalCount** | int | no | - | Total count of promotions |
| **totalPages** | int | no | - | Total count of pages |
| **page** | int | no | - | Page |
| **limit** | int | no | - | Limit of promotions per page |
| **code** | int | no | - | Code |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method retrieves the value of the `totalCount` parameter.
public int getTotalCount()
---
This method retrieves the value of the `totalPages` parameter.
public int getTotalPages()
---
This method retrieves the value of the `page` parameter.
public int getPage()
---
This method retrieves the value of the `limit` parameter.
public int getLimit()
---
This method retrieves the value of the `code` parameter.
public int getCode()
---
---
---
### Promotion
Class model for a promotion.
**Declared In:**
`com.synerise.sdk.promotions.model.promotion.Promotion`
**Declaration:**
Java Kotlin
```Java
public class Promotion extends BaseModel implements Serializable
```
```Kotlin
class Promotion : BaseModel, Serializable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **uuid** | String | no | - | Promotion UUID |
| **code** | String | no | - | Promotion code |
| **status** | String | no | - | Promotion status |
| **type** | String | no | - | Promotion type |
| **redeemLimitPerClient** | int | no | - | Redemption limit per client |
| **redeemQuantityPerActivation** | int | no | - | Redemption quantity per activation |
| **currentRedeemedQuantity** | int | no | - | Current redeemed quantity |
| **currentRedeemLimit** | int | no | - | Current redemption limit |
| **activationCounter** | int | no | - | Activation counter |
| **discountType** | String | no | - | Discount type |
| **discountValue** | int | no | - | Discount value |
| **requireRedeemedPoints** | int | no | - | Required redeemed points |
| **name** | String | no | - | Promotion name |
| **headline** | String | no | - | Promotion headline |
| **description** | String | no | - | Promotion description |
| **images** | List | no | - | List of promotion images |
| **startAt** | Date | no | - | Start time of a promotion |
| **expireAt** | Date | no | - | Expiration time of a promotion |
| **lastingAt** | Date | no | - | How long a promotion lasts |
| **params** | HashMap | no | - | Promotion custom parameters |
| **catalogIndexItems** | List | no | - | List of item indexes |
| **price** | long | no | - | Item price |
| **priority** | int | no | - | Promotion priority |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters for the above properties.
---
---
---
### PromotionStatus
This enum contains values for a promotion status.
**Declared In:**
`com.synerise.sdk.promotions.model.promotion.PromotionStatus`
**Declaration:**
Java Kotlin
```Java
public enum PromotionStatus
```
```Kotlin
public enum PromotionStatus
```
**Values:**
| Property | Value | Description |
| --- | --- | --- |
| **ASSIGNED** | "ASSIGNED" | Promotion status |
| **ACTIVE** | "ACTIVE" | Promotion status |
| **REDEEMED** | "REDEEMED" | Promotion status |
| **UNKNOWN** | "UNKNOWN" | Promotion status |
**Methods:**
This method retrieves a promotion status.
public static PromotionStatus getByPromotionStatus(String status)
---
---
---
### PromotionType
This enum contains values for a promotion type.
**Declared In:**
`com.synerise.sdk.promotions.model.promotion.PromotionType`
**Declaration:**
Java Kotlin
```Java
public enum PromotionType
```
```Kotlin
public enum PromotionType
```
**Values:**
| Property | Value | Description |
| --- | --- | --- |
| **GENERAL** | "GENERAL" | Promotion type |
| **CUSTOM** | "CUSTOM" | Promotion type |
| **MEMBERS_ONLY** | "MEMBERS_ONLY" | Promotion type |
| **UNKNOWN** | "UNKNOWN" | Promotion type |
**Methods:**
This method retrieves a promotion type.
public static PromotionType getByPromotionType(String type)
---
---
---
### PromotionIdentifier
Class model for a promotion identifier.
**Declared In:**
`com.synerise.sdk.promotions.model.promotion.PromotionIdentifier`
**Declaration:**
Java Kotlin
```Java
public class PromotionIdentifier implements Serializable
```
```Kotlin
class PromotionIdentifier : Serializable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **key** | String | no | - | Promotion key identifier |
| **value** | String | no | - | Promotion identifier value |
**Initializers:**
There is a constructor.
**Methods:**
There are no methods.
---
---
### PromotionsApiQuery
Class responsible for creating a promotion query.
**Declared In:**
`com.synerise.sdk.promotions.model.promotion.PromotionsApiQuery`
**Declaration:**
Java Kotlin
```Java
public class PromotionsApiQuery
```
```Kotlin
class PromotionsApiQuery
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **statuses** | List<[PromotionStatus](/developers/mobile-sdk/class-reference/android/promotions-and-vouchers#promotionstatus)> | yes | - | List of promotion states |
| **types** | List<[PromotionType](/developers/mobile-sdk/class-reference/android/promotions-and-vouchers#promotiontype)> | yes | - | List of promotion types |
| **sortParameters** | LinkedHashMap | yes | - | Sort parameters. If you add more than one sorting attribute, the importance of each attribute depends on its position. The first one is the most important. |
| **limit** | int | no | 100 | Limit of promotions per page |
| **page** | int | no | 1 | Page number |
| **includeMeta** | Boolean | no | false | If true, the response includes metadata |
All the properties above are accessible by using setters.
**Initializers:**
There are no initializers.
**Methods:**
There are only setters for above properties.
---
---
## Vouchers
---
### AssignVoucherResponse
Class model of AssignVoucherResponse.
**Declared In:**
`com.synerise.sdk.promotions.model.AssignVoucherResponse`
**Declaration:**
Java Kotlin
```Java
public class AssignVoucherResponse
```
```Kotlin
class AssignVoucherResponse
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **message** | String | no | - | Message |
| **data** | [AssignVoucherData](/developers/mobile-sdk/class-reference/android/promotions-and-vouchers#assignvoucherdata) | no | - | Voucher data |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters for the above properties.
This method retrieves the value of the `message` parameter.
public String getMessage()
---
This method retrieves the value of the `data` parameter.
public AssignVoucherData getData()
---
---
---
### VoucherCodesResponse
Class model of VoucherCodesResponse.
**Declared In:**
`com.synerise.sdk.promotions.model.VoucherCodesResponse`
**Declaration:**
Java Kotlin
```Java
public class VoucherCodesResponse
```
```Kotlin
class VoucherCodesResponse
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **data** | List<[VoucherCodesData](/developers/mobile-sdk/class-reference/android/promotions-and-vouchers#vouchercodesdata)> | no | - | Voucher data |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters for the above properties.
This method retrieves the list of values of the `data` parameter.
public List<VoucherCodesData> getData()
---
---
---
### AssignVoucherData
Class model of AssignVoucherData.
**Declared In:**
`com.synerise.sdk.promotions.model.AssignVoucherData`
**Declaration:**
Java Kotlin
```Java
public class AssignVoucherData
```
```Kotlin
class AssignVoucherData
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **code** | String | no | - | Code |
| **expireIn** | Date | no | - | Date of expiration |
| **redeemAt** | Date | no | - | Redemption at date |
| **assignedAt** | Date | no | - | Date of assigning voucher |
| **createdAt** | Date | no | - | Date of creation |
| **updatedAt** | Date | no | - | Date of voucher update |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters for the above properties.
This method retrieves the value of the `code` parameter.
public String getCode()
---
This method retrieves the value of the `ExpireIn` parameter.
public Date getExpireIn()
---
This method retrieves the value of the `RedeemAt` parameter.
public Date getRedeemAt()
---
This method retrieves the value of the `AssignedAt` parameter.
public Date getAssignedAt()
---
This method retrieves the value of the `CreatedAt` parameter.
public Date getCreatedAt()
---
This method retrieves the value of the `UpdateAt` parameter.
public Date getUpdatedAt()
---
---
---
### VoucherCodesData
Class model of VoucherCodesData.
**Declared In:**
`com.synerise.sdk.promotions.model.VoucherCodesData`
**Declaration:**
Java Kotlin
```Java
public class VoucherCodesData
```
```Kotlin
class VoucherCodesData
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **code** | String | no | - | Voucher code |
| **status** | String | no | - | Voucher status |
| **clientUuid** | String | no | - | Profile's UUID |
| **poolUuid** | String | no | - | Pool UUID |
| **expireIn** | Date | no | - | Voucher expiration date |
| **assignedAt** | Date | no | - | Voucher assignment date |
| **createdAt** | Date | no | - | Voucher creation date |
| **updatedAt** | Date | no | - | Voucher update date |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters for the above properties.
---
---
---
### VoucherCodesStatus
This enum contains values for a voucher code status.
**Declared In:**
`com.synerise.sdk.client.model.client.VoucherCodeStatus`
**Declaration:**
Java Kotlin
```Java
public enum VoucherCodeStatus
```
```Kotlin
public enum VoucherCodeStatus
```
**Values:**
| Property | Value | Description |
| --- | --- | --- |
| **ASSIGNED** | "ASSIGNED" | Assigned |
| **UNASSIGNED** | "UNASSIGNED" | Unassigned |
| **REDEEMED** | "REDEEMED" | Redeemed |
| **CANCELED** | "CANCELED" | Canceled |
**Methods:**
This method retrieves the voucher status.
public String getStatus()
---
This method retrieves the voucher status.
public static VoucherCodeStatus getStatus(String status)
---
# Profile identification, authentication, and management
# Customer session
## Refresh customer token
---
This method refreshes the customer’s current token.
Returns an error if the token has expired and cannot be refreshed.
**Method name:**
Client.refreshToken()
**Declaration:**
Java Kotlin
```Java
public static IApiCall refreshToken()
```
```Kotlin
fun refreshToken():IApiCall
```
**Parameters:**
No parameters required.
**Return Value:**
[IApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#iapicall) object to execute the request.
**Example:**
Java Kotlin
```Java
boolean success = Client.refreshToken();
```
```Kotlin
var success = Client.refreshToken()
```
## Retrieve customer token
---
This method retrieves the customer’s current, active token.
Returns an error if the token has expired and cannot be retrieved.
**Method name:**
Client.retrieveToken()
This method replaces `Client.getToken()`.
**Declaration:**
Java Kotlin
```Java
public static IDataApiCall retrieveToken()
```
```Kotlin
fun retrieveToken():IDataApiCall
```
**Parameters:**
No parameters required.
**Return Value:**
[IDataApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#idataapicall)<[Token](/developers/mobile-sdk/class-reference/android/client#token)> object to execute the request.
**Example:**
Java Kotlin
```Java
IDataApiCall retrieveTokenCall = Client.retrieveToken();
retrieveTokenCall.execute(success -> onSuccess(), this::onFailure);
```
```Kotlin
val retrieveTokenCall = Client.retrieveToken()
retrieveTokenCall.execute({ success-> onSuccess() }, ({ this.onFailure() }))
```
## Get current customer UUID
---
This method retrieves the customer’s current UUID.
**Method name:**
Client.getUuid()
**Declaration:**
Java Kotlin
```Java
public static String getUuid()
```
```Kotlin
fun getUuid():String
```
**Parameters:**
No parameters required.
**Return Value:**
Customer's UUID as a string.
**Example:**
Java Kotlin
```Java
Client.getUuid()
```
```Kotlin
Client.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.
**Method name:**
Client.getUuidForAuthentication()
**Declaration:**
Java Kotlin
```Java
public static String getUuidForAuthentication(@NonNull String authId)
```
```Kotlin
fun getUuidForAuthentication(
authId: String
): String
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **authId** | String | yes | --- | Seed for UUID generation |
**Return Value:**
The UUID for use in authentication as a string.
**Example:**
Java Kotlin
```Java
Client.getUuidForAuthentication(authId)
```
```Kotlin
Client.getUuidForAuthentication(authId)
```
## 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 |
**Method name:**
Client.regenerateUuid()
**Declaration:**
Java Kotlin
```Java
public static boolean regenerateUuid()
```
```Kotlin
fun regenerateUuid():Boolean
```
**Parameters:**
No parameters required.
**Return Value:**
Returns true if the current Customer is anonymous and the operation succeeds.
**Example:**
Java Kotlin
```Java
boolean success = Client.regenerateUuid();
```
```Kotlin
var success = Client.regenerateUuid()
```
## 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 |
**Method name:**
Client.regenerateUuid(clientIdentifier)
**Declaration:**
Java Kotlin
```Java
public static boolean regenerateUuid(clientIdentifier)
```
```Kotlin
fun regenerateUuid(clientIdentifier):Boolean
```
**Parameters:**
| Parameter | Type | Mandatory | 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:**
Returns true if the current Client is anonymous and the operation succeeds.
**Example:**
Java Kotlin
```Java
boolean success = Client.regenerateUuid(clientIdentifier);
```
```Kotlin
var success = Client.regenerateUuid(clientIdentifier)
```
## 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.
**Method name:**
Client.destroySession()
**Declaration:**
Java Kotlin
```Java
public static void destroySession()
```
```Kotlin
fun destroySession()
```
**Parameters:**
No parameters required.
**Return Value:**
Method is void type.
**Example:**
Java Kotlin
```Java
Client.destroySession();
```
```Kotlin
Client.destroySession()
```
# Promotions and Vouchers
## Promotions
---
### PromotionResponse
**Declared In:**
lib/model/promotions/promotion_response.dart
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
**Declaration:**
class PromotionResponse
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **totalCount** | int | no | Total count of promotions |
| **totalPages** | int | no | Total count of pages |
| **page** | int | no | Current page |
| **limit** | int | no | Limit of promotions per page |
| **code** | int | no | HTTP code of the response |
| **items** | List<[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)> | no | List of promotion items |
---
---
### Promotion
**Declared In:**
lib/model/promotions/promotion.dart
**Related To:**
[PromotionResponse](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotionresponse)
[PromotionStatus](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotionstatus)
[PromotionType](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiontype)
[PromotionDiscountType](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondiscounttype)
**Declaration:**
class Promotion
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **uuid** | String | no | Promotion's UUID |
| **code** | String | no | Promotion's code |
| **status** | [PromotionStatus](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotionstatus) | yes | Promotion's status |
| **type** | [PromotionType](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiontype) | yes | Promotion's type |
| **details** | [PromotionDetails](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondetails) | yes | Promotion's details |
| **redeemLimitPerClient** | int | yes | Redemption limit per customer |
| **redeemQuantityPerActivation** | int | yes | Redemption quantity per activation |
| **currentRedeemedQuantity** | int | no | Current redemption quantity |
| **currentRedeemLimit** | int | no | Current redemption limit |
| **activationCounter** | int | no | Promotion's activation counter |
| **possibleRedeems** | int | no | Maximum number of promotion redemptions |
| **requireRedeemedPoints** | int | yes | Required redeemed points |
| **discountType** | [PromotionDiscountType](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondiscounttype) | yes | Discount type |
| **discountValue** | int | no | Discount value |
| **discountMode** | [PromotionDiscountMode](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondiscountmode) | no | Discount mode |
| **discountModeDetails** | [PromotionDiscountModeDetails](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondiscountmodedetails) | yes | Discount mode details |
| **priority** | int | no | Promotion's priority |
| **price** | int | no | Item price |
| **itemScope** | [PromotionItemScope](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotionitemscope) | no | Promotion's item scope |
| **minBasketValue** | int | yes | Minimum basket value |
| **maxBasketValue** | int | yes | Maximum basket value |
| **name** | String | no | Promotion's name |
| **headline** | String | yes | Promotion's headline |
| **descriptionText** | String | yes | Promotion's description |
| **images** | List<[PromotionImage](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiontype)> | yes | List of promotion images |
| **startAt** | DateTime | yes | Start time of a promotion |
| **expireAt** | DateTime | yes | Expiration time of the promotion |
| **lastingAt** | DateTime | yes | Date when the promotion expires for the current profile |
| **lastingTime** | int | yes | Duration of the promotion in seconds |
| **displayFrom** | String | yes | DateTime as a String when the promotion starts being displayed |
| **displayTo** | String | yes | DateTime as a String when the promotions ends being displayed |
| **catalogIndexItems** | List<String> | yes | List of item indexes |
| **params** | Map | yes | Promotion's custom parameters |
| **tags** | List<Object> | yes | Promotion's custom tags |
---
---
### PromotionStatus
**Declared In:**
lib/enums/promotions/promotion_status.dart
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionStatus {
none('NONE'),
active('ACTIVE'),
assigned('ASSIGNED'),
redeemed('REDEEMED');
}
**Functions:**
Converts from **PromotionStatus** to **String**.
String promotionStatusAsString()
---
Converts from **String** to **PromotionStatus**.
PromotionStatus getPromotionStatusFromString(String string)
---
---
### PromotionType
**Declared In:**
lib/enums/promotions/promotion_type.dart
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionType {
unknown('UNKNOWN'),
membersOnly('MEMBERS_ONLY'),
custom('CUSTOM'),
general('GENERAL'),
handbill('HANDBILL');
}
**Functions:**
Converts from **PromotionType** to **String**.
String promotionTypeAsString() {
---
Converts from **String** to **PromotionType**.
PromotionType getPromotionTypeFromString(String string) {
---
---
### PromotionDiscountType
**Declared In:**
lib/enums/promotions/promotion_discount_type.dart
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionDiscountType {
none('NONE'),
percent('PERCENT'),
amount('AMOUNT'),
twoForOne('2_FOR_1'),
points('POINTS'),
multibuy('MULTIBUY'),
exactPrice('EXACT_PRICE');
}
**Functions:**
Converts from **String** to **PromotionDiscountType**.
PromotionDiscountType getPromotionDiscountTypeFromString(String string)
---
---
### PromotionItemScope
**Declared In:**
lib/enums/promotions/promotion_item_scope.dart
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionItemScope {
lineItem('LINE_ITEM'),
basket('BASKET');
**Functions:**
Converts from **PromotionItemScope** to **String**.
Dart
```Dart
String promotionItemScopeAsString()
```
---
Converts from **String** to **PromotionItemScope**.
Dart
```Dart
static PromotionItemScope getPromotionItemScopeFromString(String string)
```
---
---
### PromotionDetails
**Declared In:**
lib/model/promotions/promotion_details.dart
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
[PromotionDiscountTypeDetails](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondiscounttypedetails)
**Declaration:**
class PromotionDetails
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **discountType** | [PromotionDiscountTypeDetails](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondiscounttypedetails) | no | Discount details |
All properties are read-only.
---
---
### PromotionDiscountTypeDetails
**Declared In:**
lib/model/promotions/promotion_discount_type_details.dart
**Related To:**
[PromotionDetails](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondetails)
**Declaration:**
class PromotionDiscountTypeDetails
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **name** | String | no | Discount's name |
| **outerScope** | bool | no | When `true`, the items required to trigger the promotion are different than the items included in that promotion. |
| **requiredItemsCount** | int | no | Number of items required to qualify for the discount |
| **discountedItemsCount** | int | no | Number of discounted items |
All properties are read-only.
---
---
### PromotionDiscountMode
**Declared In:**
lib/enums/promotions/promotion_discount_mode.dart
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionDiscountMode {
staticMode('STATIC'),
stepMode('STEP');
**Functions:**
Converts from **String** to **PromotionDiscountMode**.
Dart
```Dart
static PromotionDiscountMode getPromotionDiscountModeFromString(String string)
```
---
---
### PromotionDiscountModeDetails
**Declared In:**
lib/model/promotions/promotion_discount_mode_details.dart
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
[PromotionDiscountStep](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondiscountstep)
**Declaration:**
class PromotionDiscountModeDetails
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **discountSteps** | [PromotionDiscountStep](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion) | no | List of discount steps |
| **discountUsageTrigger** | [PromotionDiscountUsageTrigger](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondiscountusagetrigger) | no | Usage trigger for the discount |
All properties are read-only.
---
---
### PromotionDiscountStep
**Declared In:**
lib/model/promotions/promotion_discount_step.dart
**Related To:**
[PromotionDiscountModeDetails](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondiscountmodedetails)
**Declaration:**
class PromotionDiscountStep
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **discountValue** | int | no | Value of the discount |
| **usageThreshold** | int | no | Usage threshold |
All properties are read-only.
---
---
### PromotionDiscountUsageTrigger
**Declared In:**
lib/enums/promotions/promotion_discount_usage_trigger.dart
**Related To:**
[PromotionDiscountModeDetails](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiondiscountmodedetails)
**Declaration:**
enum PromotionDiscountUsageTrigger {
transaction('TRANSACTION'),
redeem('REDEEM');
**Functions:**
Converts from **PromotionDiscountUsageTrigger** to **String**.
Dart
```Dart
String promotionDiscountUsageTriggerAsString() {
```
---
Converts from **String** to **PromotionDiscountUsageTrigger**.
Dart
```Dart
static PromotionDiscountUsageTrigger getPromotionDiscountUsageTriggerFromString(String string) {
```
---
---
### PromotionImage
**Declared In:**
lib/model/promotions/promotion_image.dart
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
[PromotionImageType](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotionimagetype)
**Declaration:**
class PromotionImage
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **url** | String | no | Image's URL |
| **type** | [PromotionImageType](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotionimagetype) | no | Image type |
All properties are read-only.
---
---
### PromotionImageType
**Declared In:**
lib/enums/promotions/promotion_image_type.dart
**Related To:**
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
**Declaration:**
enum PromotionImageType {
image('image'),
thumbnail('thumbnail'),
large('large'),
unknown('UNKNOWN');
**Functions:**
Converts from **PromotionImageType** to **String**.
Dart
```Dart
String promotionImageTypeAsString() {
```
---
Converts from **String** to **PromotionImageType**.
Swift
```Swift
static PromotionImageType getPromotionImageTypeFromString(String string)
```
---
---
### PromotionIdentifier
**Declared In:**
lib/model/promotions/promotion_identifier.dart
**Declaration:**
class PromotionIdentifier {
PromotionIdentifierKey key;
String value;
}
**Properties:**
Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **key** | String | yes | | Promotion identifier type (see [PromotionIdentifierKey enum](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotionidentifierkey))|
| **value** | String | yes | | Promotion identifier value |
**Initializers:**
PromotionIdentifier({required this.key, required this.value});
---
---
### PromotionIdentifierKey
**Declared In:**
lib/enums/promotions/promotion_identifier_key.dart
**Declaration:**
enum PromotionIdentifierKey {
uuid('UUID'),
code('CODE');
}
---
---
### PromotionsApiQuery
Object for setting parameters to facilitate fetching promotions from the API.
**Declared In:**
lib/model/promotions/promotions_api_query.dart
**Related To:**
[PromotionResponse](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotionresponse)
[Promotion](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotion)
**Declaration:**
class PromotionsApiQuery
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **statuses** | List<[PromotionStatus](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotionstatus)> | no | [] | List of promotion statuses for query |
| **types** | List<[PromotionType](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#promotiontype)> | no | [] | List of promotion types for query |
- Check the list of promotion sorting keys available in [Loyalty - Promotion sorting options](/developers/mobile-sdk/loyalty#promotion-sorting-options) section.
- See [ApiQuerySortingOrderString](/developers/mobile-sdk/class-reference/flutter/miscellaneous#apiquerysortingorder) to check ordering options.
**Initializers:**
PromotionsApiQuery(
{required this.statuses,
required this.types,
required super.sorting,
required super.limit,
required super.page,
required super.includeMeta});
---
---
## Vouchers
---
### AssignVoucherResponse
**Declared In:**
lib/model/vouchers/assign_voucher_response.dart
**Related To:**
[AssignVoucherData](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#assignvoucherdata)
**Declaration:**
class AssignVoucherResponse
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **message** | String | no | Message from the Voucher assignment response |
| **assignVoucherData** | [AssignVoucherData](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#assignvoucherdata) | yes | List of vouchers in a pool |
---
---
### VoucherCodesResponse
**Declared In:**
lib/model/vouchers/voucher_codes_response.dart
**Related To:**
[VoucherCodesData](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#vouchercodesdata)
**Declaration:**
class VoucherCodesResponse
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **items** | List<[VoucherCodesData](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#vouchercodesdata)> | no | List of voucher items |
---
---
### AssignVoucherData
**Declared In:**
lib/model/vouchers/assign_voucher_data.dart
**Related To:**
[AssignVoucherResponse](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#assignvoucherresponse)
**Declaration:**
class AssignVoucherData
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **code** | String | no | Voucher's code |
| **expireIn** | DateTime | yes | Voucher's expiration date |
| **redeemAt** | DateTime | yes | Voucher's redemption date |
| **assignedAt** | DateTime | yes | Voucher's assignment date |
| **createdAt** | DateTime | no | Voucher's creation date |
| **updatedAt** | DateTime | no | Voucher's update date |
---
---
### VoucherCodesData
**Declared In:**
lib/model/vouchers/voucher_codes_data.dart
**Declaration:**
class VoucherCodesData
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **code** | String | no | Voucher's code |
| **status** | [VoucherCodeStatus](/developers/mobile-sdk/class-reference/flutter/promotions-and-vouchers#vouchercodestatus) | no | Voucher's status |
| **clientId** | String | no | ID of the customer to whom the voucher is assigned |
| **clientUuid** | String | no | UUID of the customer to whom the voucher is assigned |
| **poolUuid** | String | no | Voucher's pool ID |
| **expireIn** | String | no | Voucher's expiration date |
| **redeemAt** | DateTime | no | Voucher's redemption date |
| **assignedAt** | DateTime | no | Voucher's assignment date |
| **createdAt** | DateTime | no | Voucher's creation date |
| **updatedAt** | DateTime | no | Voucher's update date|
---
---
### VoucherCodeStatus
**Declared In:**
lib/enums/vouchers/voucher_code_status.dart
**Declaration:**
enum VoucherCodeStatus {
unassigned('UNASSIGNED'),
assigned('ASSIGNED'),
redeemed('REDEEMED'),
canceled('CANCELED');
}
**Functions:**
Converts from **VoucherCodeStatus** to **String**.
String voucherCodeStatusAsString() {
---
Converts from **String** to **VoucherCodeStatus**.
VoucherCodeStatus getVoucherCodeStatusFromString(String string) {
# Campaigns
---
## Set Injector listener
---
This method sets callbacks for an injector module.
**Declared In:**
lib/main/modules/InjectorModule.js
**Related To:**
[ClientStateChangeListener](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#injector-listener)
**Class:**
[InjectorModule](/developers/mobile-sdk/class-reference/react-native/modules#injector)
**Declaration:**
public setListener(listener: IInjectorListener)
**Discussion:**
Learn more about the methods and the purpose of this listener [here](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#injector-listener).
## Set In-App Message listener
---
This method sets callbacks for in-app message campaigns.
**Declared In:**
lib/main/modules/InjectorModule.js
**Related To:**
[ClientStateChangeListener](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#injector-in-app-message-listener)
**Class:**
[InjectorModule](/developers/mobile-sdk/class-reference/react-native/modules#injector)
**Declaration:**
public setInAppMessageListener(listener: IInjectorInAppMessageListener)
**Discussion:**
Learn more about the methods and the purpose of this listener [here](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#injector-in-app-message-listener).
## Close In-App message
---
Closes an in-app message and sends an `inApp.discard` event.
Usage examples:
- Closing a top bar or bottom bar when the user taps outside the in-app area.
- Automatically dismissing messages when navigating away from a screen.
- Controlling in-app visibility based on app logic for a smoother user experience.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| ----------------------------------------------- | ----------- | --------------- | -------------------- | --------------- |
| Introduced in: | 5.7.0 | 6.7.0 | 1.5.0 | 2.5.0 |
**Declared In:**
lib/main/modules/InjectorModule.js
**Class:**
[InjectorModule](/developers/mobile-sdk/class-reference/react-native/modules#injector)
**Declaration:**
public closeInAppMessage(campaignHash: string)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| ---------------- | ------ | --------- | ------- | ---------------------------------------- |
| **campaignHash** | string | yes | - | Unique identifier of the in-app campaign |
## Set Notifications listener
---
This method sets callbacks for notifications module.
**Declared In:**
lib/main/modules/NotificationsModule.js
**Class:**
[NotificationsModule](/developers/mobile-sdk/class-reference/react-native/modules#notifications)
**Declaration:**
public setListener(listener: INotificationsListener)
## Register for push notifications
---
This method passes the Firebase Token to Synerise for notifications.
- You should call this method every time the user changes the system or application consent for notifications.
- The API key must have the `API_PERSONAL_DEVICE_CLIENT_UPDATE` permission from the **Client** group.
- If the registration fails, the SDK requests a token update again by a listener/delegate method ([Android](/developers/mobile-sdk/listeners-and-delegates/android-listeners#on-register-for-push-listener), [iOS](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#synerise-delegate-register-for-push-notifications-is-needed), [React Native](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#notifications-listener), [Flutter](/developers/mobile-sdk/listeners-and-delegates/flutter-listeners#notifications-listener)).
**Declared In:**
lib/main/modules/NotificationsModule.js
**Class:**
[NotificationsModule](/developers/mobile-sdk/class-reference/react-native/modules#notifications)
**Declaration:**
public registerForNotifications(registrationToken: string, mobileAgreement: boolean | null, onSuccess: () => void, onError: (error: Error) => void)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **registrationToken** | string | yes | - | Firebase Token |
| **mobileAgreement** | boolean | false | null | Agreement (consent) for mobile push campaigns |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
// If you integrate Firebase Messaging in the native part of app
Synerise.Notifications.setListener({
onRegistrationToken: function(registrationToken) {
Synerise.Notifications.registerForNotifications(registrationToken, true, function(){
//success
}, function() {
//failure
});
},
onNotification: function(payload) {
//...
}
//...
//other listener's methods
});
// Or if you want to use Firebase Messaging in react native
Synerise.Notifications.registerForNotifications("YOUR_FIREBASE_TOKEN", true, function(){
//success
}, function() {
//failure
});
```
## Check if push notification is from Synerise
---
This method verifies if a notification was sent by Synerise.
**Declared In:**
lib/main/modules/NotificationsModule.js
**Class:**
[NotificationsModule](/developers/mobile-sdk/class-reference/react-native/modules#notifications)
**Declaration:**
public isSyneriseNotification(payload: object): boolean
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **payload** | object | yes | - | Notification's key-value data object |
**Return Value:**
**true** if a notification was sent by Synerise, otherwise **false**.
**Example:**
JavaScript
```JavaScript
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isSyneriseNotification(payload)) {
Synerise.Notifications.handleNotification(payload);
}
}
//...
//other listener's methods
});
```
## Check if push notification is a Simple Push Campaign
---
This method verifies if a notification’s sender is Synerise and if the notification is a Simple Push campaign
**Declared In:**
lib/main/modules/NotificationsModule.js
**Class:**
[NotificationsModule](/developers/mobile-sdk/class-reference/react-native/modules#notifications)
**Declaration:**
public isSyneriseSimplePush(payload: object): boolean
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **payload** | object | yes | - | Notification's key-value data object |
**Return Value:**
**true** if a notification is a Simple Push, otherwise **false**.
**Example:**
JavaScript
```JavaScript
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isSyneriseSimplePush(payload)) {
Synerise.Notifications.handleNotification(payload);
}
}
//...
//other listener's methods
});
```
## Check if push notification is a Silent Command
---
This method verifies if a notification’s sender is Synerise and if the notification is a Silent Command.
**Declared In:**
lib/main/modules/NotificationsModule.js
**Class:**
[NotificationsModule](/developers/mobile-sdk/class-reference/react-native/modules#notifications)
**Declaration:**
public isSilentCommand(payload: object): boolean
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **payload** | object | yes | - | Notification's key-value data object |
**Return Value:**
**true** if a notification is a Silent Command, otherwise **false**.
**Example:**
JavaScript
```JavaScript
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isSilentCommand(payload)) {
Synerise.Notifications.handleNotification(payload);
}
}
//...
//other listener's methods
});
```
## Check if push notification is a Silent SDK Command
---
This method verifies if a notification's sender is Synerise and if the notification is a Silent SDK Command.
**Declared In:**
lib/main/modules/NotificationsModule.js
**Class:**
[NotificationsModule](/developers/mobile-sdk/class-reference/react-native/modules#notifications)
**Declaration:**
public isSilentSDKCommand(payload: object): boolean
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **payload** | object | yes | - | Notification's key-value data object |
**Return Value:**
**true** if a notification is a Silent SDK Command, otherwise **false**.
**Example:**
JavaScript
```JavaScript
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isSilentSDKCommand(payload)) {
Synerise.Notifications.handleNotification(payload);
}
}
//...
//other listener's methods
});
```
## Check if push notification is encrypted
---
This method verifies if a notification is encrypted.
**Declared In:**
lib/main/modules/NotificationsModule.js
**Class:**
[NotificationsModule](/developers/mobile-sdk/class-reference/react-native/modules#notifications)
**Declaration:**
public isNotificationEncrypted(payload: object): boolean
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **payload** | object | yes | - | Notification's key-value data object |
**Return Value:**
**true** if a notification is encrypted, otherwise **false**.
**Example:**
JavaScript
```JavaScript
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isNotificationEncrypted(payload)) {
Synerise.Notifications.decryptNotification(payload);
}
}
//...
//other listener's methods
});
```
## Decrypt push notification
---
This method decrypts the notification payload.
If the notification is not encrypted, the method returns the raw payload.
If a notification is not decrypted successfully, the method returns nil.
**Declared In:**
lib/main/modules/NotificationsModule.js
**Class:**
[NotificationsModule](/developers/mobile-sdk/class-reference/react-native/modules#notifications)
**Declaration:**
public decryptNotification(payload: object): object | null
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **payload** | object | yes | - | Notification's key-value data object |
**Return Value:**
Notification’s key-value data object with decrypted content
**Example:**
JavaScript
```JavaScript
Synerise.Notifications.setListener({
onNotification: function(payload) {
let data = Synerise.Notifications.decryptNotification(payload)
// custom notification implementation
}
//...
//other listener's methods
});
```
## Handle Synerise push notification
---
This method handles a notification payload and starts activity.
**Declared In:**
lib/main/modules/NotificationsModule.js
**Class:**
[NotificationsModule](/developers/mobile-sdk/class-reference/react-native/modules#notifications)
**Declaration:**
public handleNotification(payload: object, actionIdentifier: string | null)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **payload** | object | yes | - | Notification's key-value data object |
**Return Value:**
No value is returned.
**Example:**
JavaScript
```JavaScript
Synerise.Notifications.setListener({
onNotification: function(payload) {
Synerise.Notifications.handleNotification(payload);
}
//...
//other listener's methods
});
```
## Removed methods
### Check if push notification is a Banner Campaign {#check-if-push-notification-is-a-banner-campaign}
---
This method verifies if a notification’s sender is Synerise and if the notification is a Banner campaign.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | n/a |
**Declared In:**
lib/main/modules/NotificationsModule.js
**Class:**
[NotificationsModule](/developers/mobile-sdk/class-reference/react-native/modules#notifications)
**Declaration:**
public isSyneriseBanner(payload: object): boolean
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **payload** | object | yes | - | Notification's key-value data object |
**Return Value:**
**true** if a notification is a Banner, otherwise **false**.
**Example:**
JavaScript
```JavaScript
Synerise.Notifications.setListener({
onNotification: function(payload) {
if (Synerise.Notifications.isSyneriseBanner(payload)) {
Synerise.Notifications.handleNotification(payload);
}
}
//...
//other listener's methods
});
```
### Fetch Banners {#fetch-banners}
---
This method fetches banners set for mobile campaigns and caches the valid ones.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 4.6.0 | 4.7.0 | 0.12.0 | n/a |
This method was removed in SDK version 0.12.0.
**Declared In:**
lib/main/modules/InjectorModule.js
**Class:**
[InjectorModule](/developers/mobile-sdk/class-reference/react-native/modules#injector)
**Declaration:**
public fetchBanners(onSuccess, onError)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **onSuccess** | Function | no | - | Function to be executed when the operation is completed successfully |
| **onError** | Function | no | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
### Get Banners {#get-banners}
---
This method provides valid banners directly from SDK cache.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 4.6.0 | 4.7.0 | 0.12.0 | n/a |
This method was removed in SDK version 0.12.0.
**Declared In:**
lib/main/modules/InjectorModule.js
**Class:**
[InjectorModule](/developers/mobile-sdk/class-reference/react-native/modules#injector)
**Declaration:**
public getBanners()
**Return Value:**
No value is returned.
### Show Banner {#show-banner}
---
This method shows a banner immediately.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 4.6.0 | 4.7.0 | 0.12.0 | - |
This method was removed in SDK version 0.12.0.
**Declared In:**
lib/main/modules/InjectorModule.js
**Class:**
[InjectorModule](/developers/mobile-sdk/class-reference/react-native/modules#injector)
**Declaration:**
public showBanner(banner: object, markPresented: boolean)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **banner** | object | yes | - | Object representation of a banner |
| **markPresented** | boolean | yes | - | Sets the banner as presented and this banner instance representation will not appear again |
**Return Value:**
No value is returned.
### Get Walkthrough {#get-walkthrough}
---
This method fetches a walkthrough.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
The API key must have the `CAMPAIGN_BACKEND_CAMPAIGN_READ` permission from the **Campaign** group.
**Declared In:**
lib/main/modules/InjectorModule.js
**Class:**
[InjectorModule](/developers/mobile-sdk/class-reference/react-native/modules#injector)
**Declaration:**
public getWalkthrough()
**Return Value:**
No value is returned.
### Show Walkthrough {#show-walkthrough}
---
This method shows a walkthrough when it is loaded.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
**Declared In:**
lib/main/modules/InjectorModule.js
**Class:**
[InjectorModule](/developers/mobile-sdk/class-reference/react-native/modules#injector)
**Declaration:**
public showWalkthrough()
**Return Value:**
No value is returned.
### Check if Walkthrough is loaded {#check-if-walkthrough-is-loaded}
---
This method checks if a walkthrough is loaded.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
**Declared In:**
lib/main/modules/InjectorModule.js
**Class:**
[InjectorModule](/developers/mobile-sdk/class-reference/react-native/modules#injector)
**Declaration:**
public isWalkthroughLoaded(): boolean
**Return Value:**
**true** if the walkthrough is loaded, otherwise returns **false**.
### Check if is loaded Walkthrough unique {#check-if-is-loaded-walkthrough-unique}
---
This method checks if the walkthrough is unique compared to the previous one.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
**Declared In:**
lib/main/modules/InjectorModule.js
**Class:**
[InjectorModule](/developers/mobile-sdk/class-reference/react-native/modules#injector)
**Declaration:**
public isLoadedWalkthroughUnique(): boolean
**Return Value:**
**true** if the loaded walkthrough is unique, otherwise returns **false**.
# Recommendations and Documents
## Recommendations
---
### RecommendationRequestBody
Class responsible for creating a recommendation request.
**Declared In:**
`com.synerise.sdk.content.model.recommendation.RecommendationRequestBody`
**Declaration:**
Java Kotlin
```Java
public final class RecommendationRequestBody implements Serializable
```
```Kotlin
class RecommendationRequestBody:Serializable
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **productId** | String | no | - | Item identifier of the context item |
| **itemsIds** | ArrayList | no | - | List of item identifiers, used for multiple item context |
| **itemsExcluded** | ArrayList | no | Items that will be excluded from the generated recommendations | | **additionalFilters** | String | no | Additional filters. These are merged with the campaign's own filters according to the logic in **filtersJoiner** |
| **filtersJoiner** | String | no | Defines the logic of merging additionalFilters with the campaign's existing filters | | **additionalElasticFilters** | String | no | Additional elastic filters. These are merged with the campaign's own elastic filters according to the logic in **elasticFiltersJoiner** |
| **elasticFiltersJoiner** | String | no | Defines the logic of merging **additionalElasticFilters** with the campaign's existing elastic filters | | **displayAttribute** | ArrayList | no | An array of item attributes which value will be returned in a recommendation response |
| **includeContextItems** | Boolean | no | When true, the recommendation response will include context item metadata |
**Initializers:**
There are no initializers.
**Methods:**
Setter for productId
public RecommendationRequestBody setProductId(String productId)
---
Setter for itemsIds
public RecommendationRequestBody setItemsIds(ArrayList<String> itemsIds)
---
---
---
### RecommendationResponse
Class responsible for receiving recommendations.
**Declared In:**
`com.synerise.sdk.content.model.recommendation.RecommendationResponse`
**Declaration:**
Java Kotlin
```Java
public class RecommendationResponse
```
```Kotlin
class RecommendationResponse
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **recommended** | List<[Recommendation](/developers/mobile-sdk/class-reference/android/recommendations-and-documents#recommendation)> | no | - | List of recommendations |
| **extras** | RecommendationResponseExtras | yes | - | Additional details of the recommendation |
| **name** | String | no | - | Name of the recommendation campaign |
| **campaignHash** | String | no | - | Hash (UUID) of the recommendation campaign |
| **campaignId** | String | no | - | ID of the recommendation campaign |
| **correlationId** | String | no | - | Recommendation's correlation ID. It can be added to a `recommendation.click` event to associate it with the recommendation request |
| **schema** | String | no | - | Schema of the document which contains the recommendation |
| **slug** | String | no | - | Slug of the document |
| **uuid** | String | no | - | UUID of the document |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
This method retrieves a recommendation schema.
public String getSchema()
---
This method retrieves the value of the `slug` parameter.
public String getSlug()
---
This method retrieves the value of the `UUID` parameter.
public String getUuid()
---
This method retrieves a list of recommendations.
public List<Recommendation> getRecommendationsV2()
---
This method retrieves the value of the `campaignHash` parameter.
public String getCampaignHash()
---
This method retrieves the value of the `campaignId` parameter.
public String getCampaignId()
---
---
---
### Recommendation
Class model for a recommendation.
**Declared In:**
`com.synerise.sdk.content.model.recommendation.Recommendation`
**Declaration:**
Java Kotlin
```Java
public class Recommendation extends BaseModel
```
```Kotlin
class Recommendation : BaseModel
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **itemId** | String | no | - | Product's GTIN |
| **feed** | HashMap | no | - | Product’s recommendation attributes |
All the properties above are accessible by using getters and setters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters and setters for the above properties.
---
---
---
### RecommendationAttribute
Class model for custom attributes.
**Declared In:**
`com.synerise.sdk.content.model.recommendation.RecommendationAtribute`
**Declaration:**
Java Kotlin
```Java
public class RecommendationAtribute
```
```Kotlin
class RecommendationAtribute
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **name** | String | no | - | Attribute name |
| **type** | String | no | - | Attribute type |
| **value** | String | no | - | Attribute value |
All the properties above are accessible by using getters and setters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters and setters for the above properties.
---
## Documents
---
### DocumentApiQuery
Class responsible for creating a query to the Documents API.
**Declared In:**
`com.synerise.sdk.content.model.DocumentApiQuery`
**Declaration:**
Java Kotlin
```Java
public class DocumentApiQuery
```
```Kotlin
class DocumentApiQuery
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **slug** | String | no | Unique identifier of a document |
**Properties used only if the document includes a recommendation insert:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **productId** | String | no | Item identifier of the context item |
| **itemsIds** | ArrayList | no | List of item identifiers, used for multiple item context |
| **itemsExcluded** | ArrayList | no | Items that will be excluded from the generated recommendations |
| **additionalFilters** | String | no | Additional filters. These are merged with the campaign's own filters according to the logic in **filtersJoiner** |
| **filtersJoiner** | String | no | Defines the logic of merging additionalFilters with the campaign's existing filters |
| **additionalElasticFilters** | String | no | Additional elastic filters. These are merged with the campaign's own elastic filters according to the logic in **elasticFiltersJoiner** |
| **elasticFiltersJoiner** | String | no | Defines the logic of merging **additionalElasticFilters** with the campaign's existing elastic filters |
| **displayAttribute** | ArrayList | no | An array of item attributes which value will be returned in a recommendation response |
| **includeContextItems** | Boolean | no | When true, the recommendation response will include context item metadata |
| **params** | HashMap | yes | Additional parameters to pass for [Inserts in the document](/developers/inserts/screen-views-documents#handling-variables-when-displaying-screen-viewsdocuments). For example, if the insert is `{{ foo }}`, you need to pass the value of `foo` |
**Initializers:**
There is a constructor.
public DocumentApiQuery(String feedSlug)
**Methods:**
Setter for feedSlug
public void setFeedSlug(String feedSlug)
---
Setter for additionalFilters
public DocumentApiQuery setAdditionalFilters(String additionalFilters)
---
Setter for itemsExcluded
public DocumentApiQuery setItemsExcluded(ArrayList<String> itemsExcluded)
---
Setter for filtersJoiner
public DocumentApiQuery setFiltersJoiner(FiltersJoinerRule filtersJoiner)
---
Setter for additionalElasticFilters
public DocumentApiQuery setAdditionalElasticFilters(String additionalElasticFilters)
---
Setter for elasticFiltersJoiner
public DocumentApiQuery setElasticFiltersJoiner(FiltersJoinerRule elasticFiltersJoiner)
---
Setter for displayAttributes
public DocumentApiQuery setDisplayAttributes(ArrayList<String> displayAttribute)
---
Setter for includeContextItems
public DocumentApiQuery setIncludeContextItems(Boolean includeContextItems)
---
Setter for itemsIds
public DocumentApiQuery setItemsIds(ArrayList<String> itemsIds)
---
Setter for productId
public DocumentApiQuery setProductId(String productId)
---
---
---
### Document
**Declared In:**
`com.synerise.sdk.content.model.document`
**Declaration:**
java kotlin
```java
public class Document
```
```kotlin
class Document
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **uuid** | String | no | Document's identifier (UUID) |
| **slug** | String | no | Document's slug |
| **schema** | String | no | Document's schema type |
| **content** | [AnyHashable: Any] | no | Document's content |
All the properties above are accessible by using getters.
**Initializers:**
There are no initializers.
**Methods:**
There are only getters for the above properties.
---
---
## Removed symbols
---
### DocumentsApiQuery{#documentsapiquery}
The object to set parameters easily for fetching documents from API.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 3.5.10 | 3.5.1 | 0.9.10 | 0.2.0 |
| Deprecated in: | 4.13.0 | 5.5.0 | 0.17.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
Class responsible for creating a query to the Documents API.
**Declared In:**
`com.synerise.sdk.content.model.DocumentsApiQuery`
**Declaration:**
Java Kotlin
```Java
public class DocumentsApiQuery
```
```Kotlin
class DocumentsApiQuery
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **type** | [DocumentsApiQueryType](/developers/mobile-sdk/class-reference/android/recommendations-and-documents#documentsapiquerytype) | yes | - | Document's query type |
| **typeValue** | String | yes | - | Document's query type value |
| **version** | String | yes | - | Document version |
**Initializers:**
There are no initializers.
**Methods:**
This method sets query parameters.
public void setDocumentQueryParameters(DocumentsApiQueryType type, String typeValue)
---
This method sets a document version.
public void setVersion(String version)
---
---
---
### DocumentsApiQueryType{#documentsapiquerytype}
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 3.5.10 | 3.5.1 | 0.9.10 | 0.2.0 |
| Deprecated in: | 4.13.0 | 5.5.0 | 0.17.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
This enum contains values for the Documents API query type.
**Declared In:**
`com.synerise.sdk.content.model.DocumentsApiQueryType`
**Declaration:**
Java Kotlin
```Java
public enum DocumentsApiQueryType
```
```Kotlin
public enum DocumentsApiQueryType
```
**Values:**
| Property | Value | Description |
| --- | --- | --- |
| **SCHEMA** | "by-schema" | Query type |
**Methods:**
Get by path type.
public static DocumentsApiQueryType getByPathType(String type)
---
# Campaigns
---
## Set Injector listener
---
This method sets callbacks for an injector module.
**Declared In:**
lib/modules/injector/injector_impl.dart
**Related To:**
[InjectorListener](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#injector-listener)
**Class:**
[InjectorImpl](/developers/mobile-sdk/class-reference/flutter/modules#injector)
**Declaration:**
void listener(InjectorListenerFunction listenerFunction)
**Discussion:**
Learn more about the methods and their purpose of this listener [here](/developers/mobile-sdk/listeners-and-delegates/flutter-listeners#injector-listener).
## Set In-App Message listener
---
This method sets callbacks for in-app message campaigns.
**Declared In:**
lib/modules/injector/injector_impl.dart
**Related To:**
[InjectorInAppMessageListener](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#injector-in-app-message-listener)
**Class:**
[InjectorImpl](/developers/mobile-sdk/class-reference/flutter/modules#injector)
**Declaration:**
void inAppMessageListener(InjectorInAppMessageListenerFunction listenerFunction)
**Discussion:**
Learn more about the methods and their purpose of this listener [here](/developers/mobile-sdk/listeners-and-delegates/flutter-listeners#injector-in-app-message-listener).
## Close in-app message
---
Closes an in-app message and sends an `inApp.discard` event.
Usage examples:
- Closing a top bar or bottom bar when the user taps outside the in-app area.
- Automatically dismissing messages when navigating away from a screen.
- Controlling in-app visibility based on app logic for a smoother user experience.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| ----------------------------------------------- | ----------- | --------------- | -------------------- | --------------- |
| Introduced in: | 5.7.0 | 6.7.0 | 1.5.0 | 2.5.0 |
**Declared In:**
lib/modules/injector/injector_impl.dart
**Declaration:**
void closeInAppMessage(String campaignHash)
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| ---------------- | ------ | --------- | ------- | ---------------------------------------- |
| **campaignHash** | string | yes | - | Unique identifier of the in-app campaign |
## Register for push notifications
---
This method passes the Firebase Token to Synerise for notifications.
- You should call this method every time the user changes the system or application consent for notifications.
- The API key must have the `API_PERSONAL_DEVICE_CLIENT_UPDATE` permission from the **Client** group.
- If the registration fails, the SDK requests a token update again by a listener/delegate method ([Android](/developers/mobile-sdk/listeners-and-delegates/android-listeners#on-register-for-push-listener), [iOS](/developers/mobile-sdk/listeners-and-delegates/ios-delegates#synerise-delegate-register-for-push-notifications-is-needed), [React Native](/developers/mobile-sdk/listeners-and-delegates/react-native-listeners#notifications-listener), [Flutter](/developers/mobile-sdk/listeners-and-delegates/flutter-listeners#notifications-listener)).
**Declared In:**
lib/modules/notifications/notifications_impl.dart
**Class:**
[NotificationsImpl](/developers/mobile-sdk/class-reference/flutter/modules#notifications)
SDK >= 1.0.0 Legacy SDK
**Declaration:**
Future<void> registerForNotifications(String registrationToken,
{bool? mobileAgreement,
required void Function() onSuccess,
required void Function(SyneriseError error) onError})
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **registrationToken** | String | yes | - | Firebase Token |
| **mobileAgreement** | bool | no | null | Agreement (consent) for receiving mobile push campaigns |
| **onSuccess** | Function() | yes | - | Function to be executed when the operation is completed successfully |
| **onError** | Function([SyneriseError](/developers/mobile-sdk/class-reference/flutter/miscellaneous#syneriseerror) error) | yes | - | Function to be executed when the operation is completed with an error |
**Return Value:**
No value is returned.
This method also allows using the `registerForPushWithoutAgreement` native method.
The `registerForPushWithoutAgreement` method will be used when the `mobileAgreement` parameter is not filled.
**Example:**
FirebaseMessaging.instance.onTokenRefresh.listen((event) {
FirebaseMessaging.instance.getToken().then((token) {
if (token != null) {
firebaseToken = token;
Synerise.notifications.registerForNotifications(
firebaseToken!,
mobileAgreement: true,
onSuccess: () {},
onError: (error) {},
);
}
});
});
**Declaration:**
Future<void> registerForNotifications(String registrationToken, [bool? mobileAgreement])
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **registrationToken** | String | yes | - | Firebase Token |
| **mobileAgreement** | bool | no | null | Agreement (consent) for receiving mobile push campaigns |
**Return Value:**
No value is returned.
This method also allows to use `registerForPushWithoutAgreement` native method.
The `registerForPushWithoutAgreement` method will be used when the `mobileAgreement` parameter is not filled.
**Example:**
FirebaseMessaging.instance.onTokenRefresh.listen((event) {
FirebaseMessaging.instance.getToken().then((token) {
if (token != null) {
firebaseToken = token;
Synerise.notifications.registerForNotifications(
firebaseToken!,
mobileAgreement: true,
);
}
});
});
## Handle Synerise push notification
---
This method handles a notification payload and starts activity.
**Declared In:**
lib/modules/notifications/notifications_impl.dart
**Class:**
[NotificationsImpl](/developers/mobile-sdk/class-reference/flutter/modules#notifications)
**Declaration:**
Future<bool> handleNotification(Map notification) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **notification** | Map | yes | - | Notification’s key-value data object |
**Return Value:**
**true** if the notification is handled properly.
**Example:**
Dart
```Dart
FirebaseMessaging.onMessage.listen((RemoteMessage message,) {
Synerise.notifications.handleNotification(message.toMap());
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
Synerise.notifications.handleNotificationClick(message.toMap());
});
```
## Handle Synerise push notification click
---
This method handles a notification payload with a user interaction and starts activity.
**Declared In:**
lib/modules/notifications/notifications_impl.dart
**Class:**
[NotificationsImpl](/developers/mobile-sdk/class-reference/flutter/modules#notifications)
**Declaration:**
Future<bool> handleNotificationClick(Map notification) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **notification** | Map | yes | - | Notification’s key-value data object |
**Return Value:**
**true** if the notification is handled properly.
**Example:**
Dart
```Dart
FirebaseMessaging.onMessage.listen((RemoteMessage message,) {
Synerise.notifications.handleNotification(message.toMap());
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
Synerise.notifications.handleNotificationClick(message.toMap());
});
```
## Check if push notification is from Synerise
---
This method verifies if a notification was sent by Synerise.
**Declared In:**
lib/modules/notifications/notifications_impl.dart
**Class:**
[NotificationsImpl](/developers/mobile-sdk/class-reference/flutter/modules#notifications)
**Declaration:**
Future<bool> isSyneriseNotification(Map notification) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **notification** | Map | yes | - | Key-Value map of data |
**Return Value:**
**true** if the notification is provided by Synerise, otherwise returns **false**.
**Example:**
Dart
```Dart
bool isSyneriseNotification = await Synerise.notifications.isSyneriseNotification(remoteMessageMap);
```
## Check if push notification is a Simple Push Campaign
---
This method verifies if a notification’s sender is Synerise and if the notification is a Simple Push campaign
**Declared In:**
lib/modules/notifications/notifications_impl.dart
**Class:**
[NotificationsImpl](/developers/mobile-sdk/class-reference/flutter/modules#notifications)
**Declaration:**
Future<bool> isSyneriseSimplePush(Map notification) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **notification** | Map | yes | - | Key-Value map of data |
**Return Value:**
**true** if the notification is Synerise Simple Push provided by Synerise, otherwise returns **false**.
**Example:**
Dart
```Dart
bool isSyneriseSimplePush = await Synerise.notifications.isSyneriseSimplePush(remoteMessageMap);
```
## Check if push notification is a Silent Command
---
This method verifies if a notification’s sender is Synerise and if the notification is a Silent Command.
**Declared In:**
lib/modules/notifications/notifications_impl.dart
**Class:**
[NotificationsImpl](/developers/mobile-sdk/class-reference/flutter/modules#notifications)
**Declaration:**
Future<bool> isSilentCommand(Map notification) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **notification** | Map | yes | - | Key-Value map of data |
**Return Value:**
**true** if the notification is Synerise Silent Command provided by Synerise, otherwise returns **false**.
**Example:**
Dart
```Dart
bool isSilentCommand = await Synerise.notifications.isSilentCommand(remoteMessageMap);
```
## Check if push notification is a Silent SDK Command
---
This method verifies if a notification's sender is Synerise and if the notification is a Silent SDK Command.
**Declared In:**
lib/modules/notifications/notifications_impl.dart
**Class:**
[NotificationsImpl](/developers/mobile-sdk/class-reference/flutter/modules#notifications)
**Declaration:**
Future<bool> isSilentSDKCommand(Map notification) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **notification** | Map | yes | - | Key-Value map of data |
**Return Value:**
**true** if the notification is Synerise Silent SDK Command provided by Synerise, otherwise returns **false**.
**Example:**
Dart
```Dart
bool isSilentSDKCommand = await Synerise.notifications.isSilentSDKCommand(remoteMessageMap);
```
## Removed methods
### Check if push notification is a Banner Campaign {#check-if-push-notification-is-a-banner-campaign}
---
This method verifies if a notification’s sender is Synerise and if the notification is a Banner campaign.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | n/a |
**Declared In:**
lib/modules/notifications/notifications_impl.dart
**Class:**
[NotificationsImpl](/developers/mobile-sdk/class-reference/flutter/modules#notifications)
**Declaration:**
Future<bool> isSyneriseBanner(Map notification) async
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **notification** | Map | yes | - | Key-Value map of data |
**Return Value:**
**true** if the notification is Synerise Banner provided by Synerise, otherwise returns **false**.
**Example:**
Dart
```Dart
bool isSyneriseBanner = await Synerise.notifications.isSyneriseBanner(remoteMessageMap);
```
### Get Walkthrough {#get-walkthrough}
---
This method fetches a walkthrough.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
The API key must have the `CAMPAIGN_BACKEND_CAMPAIGN_READ` permission from the **Campaign** group.
**Declared In:**
lib/modules/injector/injector_impl.dart
**Class:**
[InjectorImpl](/developers/mobile-sdk/class-reference/flutter/modules#injector)
**Declaration:**
void getWalkthrough()
**Return Value:**
No value is returned.
**Example:**
Dart
```Dart
Synerise.injector.getWalkthrough();
```
### Show Walkthrough {#show-walkthrough}
---
This method shows a walkthrough when it is loaded.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
**Declared In:**
lib/modules/injector/injector_impl.dart
**Class:**
[InjectorImpl](/developers/mobile-sdk/class-reference/flutter/modules#injector)
**Declaration:**
void showWalkthrough()
**Return Value:**
No value is returned.
**Example:**
Dart
```Dart
Synerise.injector.showWalkthrough();
```
### Check if Walkthrough is loaded {#check-if-walkthrough-is-loaded}
---
This method checks if a walkthrough is loaded.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
**Declared In:**
lib/modules/injector/injector_impl.dart
**Class:**
[InjectorImpl](/developers/mobile-sdk/class-reference/flutter/modules#injector)
**Declaration:**
Future<bool> isWalkthroughLoaded()
**Return Value:**
**true** if the walkthrough is loaded, otherwise returns **false**.
**Example:**
Dart
```Dart
var isLoaded = await Synerise.injector.isWalkthroughLoaded();
```
### Check if is loaded Walkthrough unique {#check-if-is-loaded-walkthrough-unique}
---
This method checks if the walkthrough is unique compared to the previous one.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
**Declared In:**
lib/modules/injector/injector_impl.dart
**Class:**
[InjectorImpl](/developers/mobile-sdk/class-reference/flutter/modules#injector)
**Declaration:**
Future<bool> isLoadedWalkthroughUnique()
**Return Value:**
**true** if the loaded walkthrough is unique, otherwise returns **false**.
**Example:**
Dart
```Dart
var isLoaded = await Synerise.injector.isLoadedWalkthroughUnique();
```
# Recommendations and Documents
## Recommendations
---
### RecommendationResponse
**Declared In:**
Headers/SNRRecommendationResponse.h
**Related To:**
[Recommendation](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#recommendation)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class RecommendationResponse
```
```Objective-C
@interface SNRRecommendationResponse
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **name** | String | no | Name of the recommendation campaign |
| **campaignHash** | String | no | Hash (UUID) of the recommendation campaign |
| **campaignID** | String | no | ID of the recommendation campaign |
| **correlationID** | String | no | Recommendation's correlation ID. It can be added to a `recommendation.click` event to associate it with the recommendation request |
| **extras** | RecommendationResponseExtras | yes | Additional details of the recommendation |
| **schema** | String | no | Schema of the document which contains the recommendation|
| **slug** | String | no | Slug of the document |
| **uuid** | String | no | UUID of the document |
| **items** | [[Recommendation]](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents/#recommendation) | no | List of items in the recommendation |
---
---
### Recommendation
**Declared In:**
Headers/SNRRecommendation.h
**Related To:**
[RecommendationResponse](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#recommendationresponse)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class Recommendation
```
```Objective-C
@interface SNRRecommendation
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **itemID** | String | no | Product's GTIN |
| **attributes** | [AnyHashable: Any] | no | Product’s recommendation attributes |
---
---
### RecommendationOptions
**Declared In:**
Headers/SNRRecommendationOptions.h
**Related To:**
[RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#recommendationfiltersjoinerrule)
**Declaration:**
Swift Objective-C
```Swift
class RecommendationOptions
```
```Objective-C
@interface SNRRecommendationOptions
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **slug** | String | no | Unique identifier of a document which includes a recommendation insert |
| **productID** | String | no | Item identifier of the context item |
| **productIDs** | [String] | no | List of item identifiers, used for multiple item context |
| **itemsExcluded** | [String] | no | Items that will be excluded from the generated recommendations |
| **additionalFilters** | String | no | Additional filters. These are merged with the campaign's own filters according to the logic in **filtersJoiner** |
| **filtersJoiner** | [RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#recommendationfiltersjoinerrule) | no | Defines the logic of merging additionalFilters with the campaign's existing filters |
| **additionalElasticFilters** | String | no | Additional elastic filters. These are merged with the campaign's own elastic filters according to the logic in **elasticFiltersJoiner** |
| **elasticFiltersJoiner** | [RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#recommendationfiltersjoinerrule) | no | Defines the logic of merging **additionalElasticFilters** with the campaign's existing elastic filters |
| **displayAttribute** | [String] | no | An array of item attributes which value will be returned in a recommendation response |
| **includeContextItems** | Bool | no | When true, the recommendation response will include context item metadata |
---
---
### RecommendationFiltersJoinerRule
**Declared In:**
Headers/SNRRecommendationOptions.h
**Declaration:**
Swift Objective-C
```Swift
enum RecommendationFiltersJoinerRule: Int {
and,
or,
replace
}
```
```Objective-C
typedef NS_ENUM(NSUInteger, SNRRecommendationFiltersJoinerRule) {
SNRRecommendationFiltersJoinerRuleAnd,
SNRRecommendationFiltersJoinerRuleOr,
SNRRecommendationFiltersJoinerRuleReplace
}
```
**Functions:**
Converts from **RecommendationFiltersJoinerRule** to **String**.
Swift Objective-C
```Swift
func SNR_RecommendationFiltersJoinerRuleToString(_: RecommendationFiltersJoinerRule) -> String
```
```Objective-C
NSString * SNR_RecommendationFiltersJoinerRuleToString(SNRRecommendationFiltersJoinerRule rule)
```
---
---
## Documents
---
### DocumentApiQuery
The object to set parameters easily for fetching documents from API.
**Declared In:**
Headers/SNRDocumentApiQuery.h
**Inherits From:**
[NSObject](https://developer.apple.com/documentation/objectivec/nsobject)
**Declaration:**
Swift Objective-C
```Swift
class DocumentApiQuery: NSObject
```
```Objective-C
@interface SNRDocumentApiQuery : NSObject
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **slug** | String | no | nil | Unique identifier of a document |
**Properties used only if the document includes a recommendation insert:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **productId** | String | yes | Item identifier of the context item |
| **itemsIds** | [String] | yes | List of item identifiers, used for multiple item context |
| **itemsExcluded** | [String] | yes | Items that will be excluded from the generated recommendations |
| **additionalFilters** | String | yes | Additional filters. These are merged with the campaign's own filters according to the logic in **filtersJoiner** |
| **filtersJoiner** | [RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#recommendationfiltersjoinerrule) | yes | Defines the logic of merging additionalFilters with the campaign's existing filters |
| **additionalElasticFilters** | String | yes | Additional elastic filters. These are merged with the campaign's own elastic filters according to the logic in **elasticFiltersJoiner** |
| **elasticFiltersJoiner** | [RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#recommendationfiltersjoinerrule) | yes | Defines the logic of merging **additionalElasticFilters** with the campaign's existing elastic filters |
| **displayAttribute** | [String] | yes | An array of item attributes which value will be returned in a recommendation response |
| **includeContextItems** | Bool | yes | When true, the recommendation response will include context item metadata |
| **params** | [String: Any] | yes | Additional parameters to pass for [Inserts in the document](/developers/inserts/screen-views-documents#handling-variables-when-displaying-screen-viewsdocuments). For example, if the insert is `{{ foo }}`, you need to pass the value of `foo` |
**Initializers:**
Swift Objective-C
```Swift
init(slug: String)
```
```Objective-C
- (instancetype)initWithSlug:(NSString *)slug
```
---
---
### Document
**Declared In:**
Headers/SNRDocument.h
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/ios/miscellaneous#basemodel)
**Declaration:**
Swift Objective-C
```Swift
class Document: BaseModel
```
```Objective-C
@interface SNRDocument : SNRBaseModel
```
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **uuid** | String | no | Document's identifier (this parameter was called **identifier** before version 5.0.0) |
| **slug** | String | no | Document's slug |
| **schema** | String | no | Document's schema type |
| **content** | [AnyHashable: Any] | no | Document's content |
All properties are read-only.
---
---
## Removed symbols
---
### DocumentsApiQuery{#documentsapiquery}
The object to set parameters easily for fetching documents from API.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 3.5.10 | 3.5.1 | 0.9.10 | 0.2.0 |
| Deprecated in: | 4.13.0 | 5.5.0 | 0.17.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
**Declared In:**
Headers/SNRDocumentsApiQuery.h
**Related To:**
[DocumentsApiQueryType](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#documentsapiquerytype)
**Inherits From:**
[NSObject](https://developer.apple.com/documentation/objectivec/nsobject)
**Declaration:**
Swift Objective-C
```Swift
class DocumentsApiQuery: NSObject
```
```Objective-C
@interface SNRDocumentsApiQuery : NSObject
```
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **type** | [DocumentsApiQueryType](/developers/mobile-sdk/class-reference/ios/recommendations-and-documents#documentsapiquerytype) | no | .bySchema | Query type |
| **typeValue** | String | no | nil | Value for query type |
| **version** | String | yes | nil | Specifies the document version |
**Initializers:**
Swift Objective-C
```Swift
init(type: DocumentsApiQueryType, value: String)
```
```Objective-C
- (instancetype)initWithType:(SNRDocumentsApiQueryType)type typeValue:(nonnull NSString *)typeValue
```
---
---
### DocumentsApiQueryType{#documentsapiquerytype}
**Declared In:**
Headers/SNRDocumentsApiQueryType.h
**Declaration:**
Swift Objective-C
```Swift
enum DocumentsApiQueryType: Int {
bySchema
}
```
```Objective-C
typedef NS_ENUM(NSInteger, SNRDocumentsApiQueryType) {
SNRDocumentsApiQueryTypeBySchema
}
```
# Mobile SDK
This section explains how to implement and use Synerise SDK in your mobile applications (Android, iOS, React Native).
The best way to start is to read the [Overview](/developers/mobile-sdk/overview) article. It contains all information about the possibilities Mobile SDK offers.
After reading the Overview, we recommend familiarizing with the instructions and performing the actions described in them in the presented order:
- [Installation and configuration](/developers/mobile-sdk/installation-and-configuration)
- [Configuring push notifications](/developers/mobile-sdk/configuring-push-notifications)
- [Settings](/developers/mobile-sdk/settings)
- [Profile identification, authorization and management](/developers/mobile-sdk/user-identification-and-authorization)
- [Event tracking](/developers/mobile-sdk/event-tracking)
- [Campaigns](/developers/mobile-sdk/campaigns)
- [Loyalty](/developers/mobile-sdk/loyalty)
After that, you can read and configure the other modules in any order.
# Recommendations and Documents
## Recommendations
---
### RecommendationResponse
**Declared In:**
lib/classes/content/RecommendationResponse.js
**Related To:**
[Recommendation](/developers/mobile-sdk/class-reference/react-native/recommendations-and-documents#recommendation)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class RecommendationResponse extends BaseModel
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **name** | string | no | Name of the recommendation campaign |
| **campaignHash** | string | no | Hash (UUID) of the recommendation campaign |
| **campaignID** | string | no | ID of the recommendation campaign |
| **items** | [Array](/developers/mobile-sdk/class-reference/react-native/recommendations-and-documents#recommendation) | no | List of items in the recommendation |
---
---
### Recommendation
Model representating a recommendation item data.
This is a read-only class and it is not meant to be instantiated directly.
**Declared In:**
lib/classes/Content/Recommendation.js
**Related To:**
[RecommendationResponse](/developers/mobile-sdk/class-reference/react-native/recommendations-and-documents#recommendationresponse)
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class Recommendation extends BaseModel
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **itemID** | string | no | Product's GTIN |
| **attributes** | Record | no | Product's recommendation attributes |
---
---
### RecommendationOptions
**Declared In:**
lib/classes/content/RecommendationOptions.js
**Declaration:**
class RecommendationOptions
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **slug** | string | no | Unique identifier of a document which includes a recommendation insert |
| **productID** | string | no | Item identifier of the context item |
---
---
### RecommendationFiltersJoinerRule
**Declared In:**
lib/classes/models/Content/RecommendationOptions.js
**Declaration:**
enum RecommendationFiltersJoinerRule {
And = 'AND',
Or = 'OR',
Replace = 'REPLACE'
}
---
---
## Documents
---
### DocumentApiQuery
The object to set parameters easily for fetching screen views from API.
**Declared In:**
lib/classes/api_queries/DocumentApiQuery.js
**Declaration:**
class DocumentApiQuery
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **slug** | string | no | Unique identifier of a document |
**Properties used only if the document includes a recommendation insert:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **productId** | string | yes | Item identifier of the context item |
| **itemsIds** | Array | yes | List of item identifiers, used for multiple item context |
| **itemsExcluded** | Array | yes | Items that will be excluded from the generated recommendations |
| **additionalFilters** | string | yes | Additional filters. These are merged with the campaign's own filters according to the logic in **filtersJoiner** |
| **filtersJoiner** | [RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/react-native/recommendations-and-documents#recommendationfiltersjoinerrule) | no | Defines the logic of merging additionalFilters with the campaign's existing filters |
| **additionalElasticFilters** | string | yes | Additional elastic filters. These are merged with the campaign's own elastic filters according to the logic in **elasticFiltersJoiner** |
| **elasticFiltersJoiner** | [RecommendationFiltersJoinerRule](/developers/mobile-sdk/class-reference/react-native/recommendations-and-documents#recommendationfiltersjoinerrule) | no | Defines the logic of merging **additionalElasticFilters** with the campaign's existing elastic filters |
| **displayAttribute** | Array | yes | An array of item attributes which value will be returned in a recommendation response |
| **includeContextItems** | boolean | yes | When true, the recommendation response will include context item metadata |
**Initializers:**
constructor()
---
---
### Document
Model representing a highest-priority customer screen view campaign.
This is a read-only class and it is not meant to be instantiated directly.
**Declared In:**
lib/classes/content/Document.js
**Inherits From:**
[BaseModel](/developers/mobile-sdk/class-reference/react-native/miscellaneous#basemodel)
**Declaration:**
class Document extends BaseModel
**Properties:**
| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| **uuid** | string | no | Document's identifier (UUID) |
| **slug** | string | no | Document's slug |
| **schema** | string | no | Document's schema type |
| **content** | object | no | Document's content |
---
---
## Removed symbols
---
### DocumentsApiQuery{#documentsapiquery}
The object to set parameters easily for fetching documents from API.
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 3.5.10 | 3.5.1 | 0.9.10 | 0.2.0 |
| Deprecated in: | 4.13.0 | 5.5.0 | 0.17.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
The object to set parameters easily for fetching documents from API.
**Declared In:**
lib/classes/api_queries/DocumentsApiQuery.js
**Related To:**
[DocumentsApiQueryType](/developers/mobile-sdk/class-reference/react-native/recommendations-and-documents#documentsapiquerytype)
**Declaration:**
class DocumentsApiQuery
**Properties:**
| Property | Type | Optional | Default | Description |
| --- | --- | --- | --- | --- |
| **type** | [DocumentsApiQueryType](/developers/mobile-sdk/class-reference/react-native/recommendations-and-documents#documentsapiquerytype) | no | .bySchema | Query type |
| **typeValue** | string | no | nil | Value for query type |
| **version** | string | yes | nil | Specifies the document version |
**Initializers:**
constructor(type: DocumentsApiQueryType, typeValue: string, version: string)
---
---
### DocumentsApiQueryType {#documentsapiquerytype}
| | **iOS SDK** | **Android SDK** | **React Native SDK** | **Flutter SDK** |
| --- | --- | --- | --- | --- |
| Introduced in: | 3.5.10 | 3.5.1 | 0.9.10 | 0.2.0 |
| Deprecated in: | 4.13.0 | 5.5.0 | 0.17.0 | n/a |
| Removed in: | 5.0.0 | 6.0.0 | 1.0.0 | 2.0.0 |
**Declared In:**
lib/classes/api_queries/DocumentsApiQueryType.js
**Declaration:**
enum DocumentsApiQueryType {
SCHEMA = 'by-schema',
}
# Event tracking
## Get customer's events
---
This method retrieves events for an authenticated customer.
This method requires customer authentication.
**Method name:**
Client.getEvents(clientEventsQuery)
**Declaration:**
Java Kotlin
```Java
public static IDataApiCall> getEvents(ClientEventsQuery clientEventsQuery)
```
```Kotlin
fun getEvents(clientEventsQuery:ClientEventsQuery):IDataApiCall>
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **clientEventsQuery** | ClientEventsQuery | yes | - | Object to create clientEvent query |
**Return Value:**
[IDataApiCall](/developers/mobile-sdk/method-reference/android/public-interfaces#idataapicall)> object to execute the request.
**Example:**
Java Kotlin
```Java
private IDataApiCall> getEventClientsCall;
if (getEventClientsCall != null) getEventClientsCall.cancel();
getEventClientsCall = Client.getEvents(clientEventsQuery);
getEventClientsCall.execute(({ this.onSuccess() }), ({ this.onFailure() });
```
```Kotlin
private val getEventClientsCall:IDataApiCall>
if (getEventClientsCall != null) getEventClientsCall.cancel()
getEventClientsCall = Client.getEvents(clientEventsQuery)
getEventClientsCall.execute(({ this.onSuccess() }), ({ this.onFailure() })
```
## Set custom identifier for events
---
This method sets a custom identifier in the parameters of every event.
You can pass a custom identifier to match your customers in our database.
**Method name:**
Tracker.setCustomIdentifier(customIdentifier)
**Declaration:**
java kotlin
```java
public static void setCustomIdentifier(String customIdentifier)
```
```kotlin
fun setCustomIdentifier(customIdentifier:String)
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **customIdentifier** | String | yes | - | Client's custom identifier |
**Return Value:**
Void type method.
**Example:**
java kotlin
```java
Tracker.setCustomIdentifier(customIdentifier)
```
```kotlin
Tracker.setCustomIdentifier(customIdentifier)
```
## Set custom email for events
---
This method sets a custom email in the parameters of every event.
You can pass a custom email to match your customers in our database.
**Method name:**
Tracker.setCustomEmail(customEmail)
**Declaration:**
java kotlin
```java
public static void setCustomEmail(String customEmail)
```
```kotlin
fun setCustomEmail(customEmail:String)
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **customEmail** | String | yes | - | Customer's email |
**Return Value:**
Void type method.
**Example:**
java kotlin
```java
private void setCustomEmail(String customEmail) {
Tracker.setCustomEmail(customEmail);
}
```
```kotlin
private fun setCustomEmail(customEmail:String) {
Tracker.setCustomEmail(customEmail)
}
```
## Send event
---
This method sends an event.
DO NOT send `transaction.charge` events as custom events.
Transactions must be tracked with these endpoints:
- [`/v4/transactions`](https://hub.synerise.com/api-reference/data-management#operation/CreateATransaction) (single transaction)
- [`/v4/transactions/batch`](https://hub.synerise.com/api-reference/data-management#operation/BatchAddOrUpdateTransactions) (multiple transactions)
- The tracker caches and enqueues all your events locally, so they all will be sent eventually.
- The API key must have the `API_BATCH_EVENTS_CREATE` permission from the **Events** group.
It also supports Android O's [Background Execution Limits](https://developer.android.com/about/versions/oreo/background.html).
**Method name:**
Tracker.send(event)
**Declaration:**
java kotlin
```java
public static void send(Event event)
```
```kotlin
fun send(event:Event)
```
**Parameters:**
| Parameter | Type | Mandatory | Default | Description |
| --- | --- | --- | --- | --- |
| **event** | Event | yes | - | Event object (e.g. `CustomEvent()` instance). |
**Return Value:**
Void type method.
**Example:**
java kotlin
```java
Tracker.send(new CustomEvent("my.action", "label"));
```
```kotlin
Tracker.send(CustomEvent("my.action", "label"))
```
## Flush events from Tracker
---
This method forces sending the events from the queue to the server.
The API key must have the `API_BATCH_EVENTS_CREATE` permission from the **Events** group.
**Method name:**
Tracker.flush()
**Declaration:**
java kotlin
```java
public static void flush()
```
```kotlin
fun flush()
```
**Parameters:**
No parameters required.
**Return Value:**
Void type method.
**Example:**
java kotlin
```java
Tracker.flush();
```
```kotlin
Tracker.flush();
```