There are a few steps required before you start integrating the iAdvize Messenger SDK.
💬 Setting up your iAdvize environment
Before integrating the SDK, you need to check that your iAdvize environment is ready to use (i.e. you have an account ready to receive and answer to conversations from the SDK). You will also need some information related to the project for the SDK setup. Please ask your iAdvize administrator to follow the instructions available on the SDK Knowledge Base and to provide you with the Project Identifier as well as a Targeting Rule Identifier.
Your iAdvize administrator should already have configured the project on the iAdvize Administration Desk and created an operator account for you. If it is not yet the case please contact your iAdvize Technical Project Manager.
💻 Connecting to your iAdvize Operator Desk
Using your operator account please log into the iAdvize Desk.
If you have the Administrator status in addition to your operator account, you will be directed to the Admin Desk when logging in. Just click on the Chat button in the upper right corner to open the Operator Desk.
The iAdvize operator desk is the place where the conversations that are assigned to your account will pop up. Please ensure that your status is “Available" by enabling the corresponding chat or video toggle buttons in the upper right corner:
If the toggle button is yellow, it means you have reached your maximum simultaneous chat slots, please end your current conversations to free a chat slot and allow the conversations to be assigned to you. If the toggle is red you are not available to chat.
🔐 Ensuring the SDK integrity
Before downloading the iAdvize Messenger SDK artifacts you can verify their integrity by generating their checksums and comparing them with the reference checksums available.
The Android SDK consists of an archive (aar file) and a Maven project description (pom file), you can generate their checksums using the following commands (replace x.y.z by the SDK version you are checking):
This ensures that the online packages are valid. In order to check those checksums on the fly, this process can be automated via Gradle by adding a metadata verification xml file at $PROJECT_ROOT/gradle/verification-metadata.xml:
With this file present in your project structure, Gradle will automatically check the artifacts checksums before integrating them into your app. Please note that you will have to do this for all dependencies used in your project. To help you with that, verification-metadata.xml for the SDK sub-dependencies is delivered alongside the SDK. Those subdependencies checksums have been generated through the Gradle generation feature and not verified.
The iOS SDK only consists of an archive (zip file). You can generate its checksums using the following command (replace x.y.z by the SDK version you are checking):
SPM will also automatically verify that the checksum of the artifact it downloads correspond to the one described in the Package.swift available in the public repository (it's a SHA2-256 checksum).
CocoaPods integration
The iOS SDK consists of an archive (zip file) and a Cocoapods project description file (podspec file). You can generate their checksums using the following commands (replace x.y.z by the SDK version you are checking):
After downloading the SDK through CocoaPods, additional verifications can be made, first by comparing the podspec checksum at the end of the generated Podfile.lock with the SHA1 podspec reference checksum.
SPEC CHECKSUMS:
iAdvize: podspec-sha1-checksum
The downloaded framework integrity can also be checked by generating the local pod files checksums and comparing them with the online reference ones:
Our React Native SDK plugin is hosted on an external platform called Node Package Manager (NPM) that already has internal checksum validation strategies in order to ensure that the downloaded plugin code (the wrapper code) is untampered.
Our Flutter SDK plugin is hosted on an external platform called pub.dev, that already has internal checksum validation strategies in order to ensure that the downloaded plugin code (the wrapper code) is untampered.
⚙️ Setting up the SDK
1️⃣ Setting up the SDK into your project configuration
First of all, to be able to use the SDK you need to add the SDK dependency into your project. Some configuration steps will also be needed in order to use it.
Add the iAdvize repository to your project repositories inside your top-level Gradle build file:
The exclude configuration is required because the iAdvize Messenger SDK uses Smack, an XMPP library that is built upon xpp3, which is bundled by default in the Android framework. This exclude ensures that your app does not also bundle xpp3 to avoid classes duplication errors.
In that same file, you also need to ensure that you are using the right Android target to build (iAdvize Messenger SDK is built with Android target 33):
iAdvize Messenger SDK requires a minSdkVersion >= 21.
After syncing your project you should be able to import the iAdvize dependency in your application code with import com.iadvize.conversation.sdk.IAdvizeSDK
You will then need to provide a reference to your application object and initialize the SDK with it.
In your AndroidManifest.xml declare your application class:
<applicationandroid:name="my.app.package.App"><!-- your activities etc... --></application>
The SDK supports video conversations using a third-party native (C++) binaries. If you are delivering your app using an APK you will note a size increase as the default behavior of the build system is to include the binaries for each ABI in a single APK. We strongly recommended that you take advantage of either App Bundles or APK Splits to reduce the size of your APKs while still maintaining maximum device compatibility.
From Xcode go to File > Add Packages, then paste the iAdvize Messenger SDK URL https://github.com/iadvize/iadvize-ios-sdk in the top-right search bar. Select the versioning strategy fitting your app then click on Add Package.
You should then be able to import the iAdvize dependency in your application code using import IAdvizeConversationSDK
Add this line to your Podfile, inside the target section (replace x.y.z by the latest SDK version available, and choose the versioning strategy fitting your app):
platform :ios,'13.0'target 'YOUR_TARGET'do project 'YOUR_PROJECT' pod 'iAdvize','x.y.z'end
iAdvize Messenger SDK requires a minimum iOS platform of 13.0.
After running pod install you should be able to import the iAdvize dependency in your application code with import IAdvizeConversationSDK
The SDK supports video conversations. Thus it will request camera and microphone access before entering a video call. To avoid the app to crash, you have to setup two keys in your app Info.plist
<key>NSCameraUsageDescription</key>
<string>This application will use the camera to share photos and during video calls.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This application will use the microphone during video calls.</string>
Download the library from NPM using the following command:
npminstall@iadvize-oss/iadvize-react-native-sdk
Alternatively, you can use Yarn:
yarnadd@iadvize-oss/iadvize-react-native-sdk
The SDK API is then available via the following import:
In your android/build.gradle file, and add the iAdvize SDK repository. You also need to ensure that you are using the right Android framework to build (iAdvize Messenger SDK is built with Android target 33):
iAdvize Messenger SDK requires a minSdkVersion >= 21.
On Android, the iAdvize Messenger SDK needs to be initialized before use to allow several functionalities to work. For instance, the default floating button use an ActivityLifecycleController that must be started before the main ReactNative activity is created, otherwise the controller won't be able to trigger the button display. Thus you need to add those lines in the android/app/src/main/java/yourpackage/MainApplication.java to initialize the SDK properly:
Add this line to your Podfile, inside the target section (replace x.y.z by the latest SDK version available, and choose the versioning strategy fitting your app):
platform :ios,'13.0'target 'YOUR_TARGET'do project 'YOUR_PROJECT' pod 'iAdvize','x.y.z'end
iAdvize Messenger SDK requires a minimum iOS platform of 13.0.
Once this is done, make sure to go to ios folder and install CocoaPods dependencies:
cdios&&podinstall--repo-update
The SDK supports video conversations. Thus it will request camera and microphone access before entering a video call. To avoid the app to crash, you have to setup two keys in your app Info.plist
<key>NSCameraUsageDescription</key>
<string>This application will use the camera to share photos and during video calls.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This application will use the microphone during video calls.</string>
Download the library from pub.dev using the following command:
flutterpubaddiadvize_flutter_sdk
The SDK API is then available via the following import:
You also need to ensure that you are using the right Android framework to build (iAdvize Messenger SDK is built with Android target 33), as a good practice, also check that you are using the latest Kotlin version in android/build.gradle (you can find the version used in the plugin through its README file)
iAdvize Messenger SDK requires a minSdkVersion >= 21.
Add this line to your Podfile, inside the target section (replace x.y.z by the latest SDK version available, and choose the versioning strategy fitting your app):
platform :ios,'13.0'target 'YOUR_TARGET'do project 'YOUR_PROJECT' pod 'iAdvize','x.y.z'end
iAdvize Messenger SDK requires a minimum iOS platform of 13.0.
Once this is done, make sure to go to ios folder and install CocoaPods dependencies:
cdios&&podinstall--repo-update
The SDK supports video conversations. Thus it will request camera and microphone access before entering a video call. To avoid the app to crash, you have to setup two keys in your app Info.plist
<key>NSCameraUsageDescription</key>
<string>This application will use the camera to share photos and during video calls.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This application will use the microphone during video calls.</string>
2️⃣ Activating the SDK
Now that the SDK is available into your project build, let's integrate it into your app, first by activating it. Activation is the step that logs a user into the iAdvize flow.
You can choose between multiple authentication options:
To activate the SDK you must use the activate function with your projectId (see the Prerequisites section above to get that identifier). You have access to callbacks in order to know if the SDK has been successfully activated. In case of an SDK activation failure the callback will give you the reason of the failure and you may want to retry later.
IAdvizeSDK.activate( projectId = projectId, authenticationOption = authOption, gdprOption = gdprOption, callback =object : IAdvizeSDK.Callback {overridefunonSuccess() { Log.d("iAdvize SDK", "The SDK has been activated.") }overridefunonFailure(t: Throwable) { Log.e("iAdvize SDK", "The SDK activation failed with:", t) } })
try {// Anonymous Auth => Do not set the onJWERequested listener & set an empty userIdawaitIAdvizeSDK.activate(projectId,'',...);// Simple Auth => Do not set the onJWERequested listener & set a non-empty userIdawaitIAdvizeSDK.activate(projectId,"my-user-unique-id",...);// Secured Auth => Set the onJWERequested listenerIAdvizeSDKListeners.onJWERequested(function (eventData:any) {console.log('onJWERequested'+' '+ eventData);var jwe =... ;// Fetch JWE from your 3rd-party auth systemreturn jwe; });awaitIAdvizeSDK.activate(projectId,'',...);// SDK is activated} catch (e) {// SDK failed to activate}
IAdvizeSdk.activate( projectId:'projectId', authenticationOption: authOption gdprOption: gdprOption, ).then((bool activated) => activated?log('iAdvize Example : SDK activated'):log('iAdvize Example : SDK not activated'));
Once the iAdvize Messenger SDK is successfully activated, you should see a success message in the console:
✅ iAdvize conversation activated, the version is x.y.z
3️⃣ Logging the user out
You will have to explicitly call the logout function of the iAdvize Messenger SDK when the user sign out of your app.
IAdvizeSDK.logout()
IAdvizeSDK.shared.logout()
IAdvizeSDK.logout()
IAdvizeSdk.logout();
4️⃣ Displaying logs
To have more information on what’s happening on the SDK side you can change the log level.
// VERBOSE, INFO, WARNING, ERROR, SUCCESS, NONE// Default is WARNINGIAdvizeSDK.setLogLevel(LogLevel.VERBOSE);
// verbose, info, warning, error, success, none// Default is warningIAdvizeSdk.setLogLevel(LogLevel.verbose);
💬 Starting a conversation
To be able to start a conversation you will first have to trigger a targeting rule in order for the default chat button to be displayed. The Chatbox will then be accessible by clicking on that chat button.
1️⃣ Configuring the targeting language
The targeting rule configured in the iAdvize Administration Panel is setup for a given language. This means that if, for example, you setup a targeting rule to be triggered only for EN language and the current user’s device is setup with a different targeting language (for instance FR), the targeting rule will not trigger.
By default, the targeting rule language used is the user’s device current language. You can force the targeting language to a specific value using:
let targetingRule =TargetingRule(id: UUID, conversationChannel: .chat)// or .videoIAdvizeSDK.shared.targetingController.activateTargetingRule(targetingRule: targetingRule)
IAdvizeSDK.activateTargetingRule(targetingRuleUUIDString,ConversationChannel.CHAT); // OR ConversationChannel.VIDEO
IAdvizeSdk.activateTargetingRule(TargetingRule(uuid: 'targeting-rule-uuid', channel: ConversationChannel.chat)); // or ConversationChannel.video
If all the following conditions are met, the default chat button should appear:
the targeting rule exists and is enabled in the administration panel
the targeting rule language set in the SDK matches the language configured for this rule
an operator assigned to this rule is available to answer (connected and with a free chat slot)
After you activate a rule and it succeeds (by displaying the button), those conditions are checked every 30 seconds to verify that the button should still be displayed or not.
Upon the first encountered failure from this periodic check, the button is hidden and the SDK stops verifying the conditions. It means that if the rule cannot be triggered (after the first call, or after any successive check), you will have to call the activateTargetingRule (or registerUserNavigation) method again in order to restart the engagement process.
3️⃣ Initiating the conversation
Once the default chat button is displayed, the visitor tap on it to access the Chatbox. After composing and sending a message a new conversation should pop up in the operator desk.
4️⃣ Following user navigation
While your user navigates through your app, you will have to update the active targeting rule in order to engage him/her with the best conversation partner at any time. In order to so, the SDK provides you with multiple navigation options to customize the behavior according to your needs:
// To clear the active targeting rule and thus stopping the engagement process (this is the default behavior)
val navOption = NavigationOption.ClearActiveRule
// To keep/start the engagement process with the same active targeting rule in the new user screen
val navOption = NavigationOption.KeepActiveRule
// To keep/start the engagement process but with another targeting rule for this screen
val navOption = NavigationOption.ActivateNewRule(newRule)
// Register the user navigation through your app
IAdvizeSDK.targetingController.registerUserNavigation(navOption)
// To clear the active targeting rule and thus stopping the engagement process (this is the default behavior)
let navOption: NavigationOption = .clearActiveRule
// To keep/start the engagement process with the same active targeting rule in the new user screen
let navOption: NavigationOption = .keepActiveRule
// To keep/start the engagement process but with another targeting rule for this screen
let navOption: NavigationOption = .activateNewRule(targetinRuleId: newRuleId)
// Register the user navigation through your app
IAdvizeSDK.shared.targetingController.registerUserNavigation(navigationOption: navOption)
// To clear the active targeting rule and thus stopping the engagement process (this is the default behavior)
IAdvizeSDK.registerUserNavigation(NavigationOption.CLEAR, "", "");
// To keep/start the engagement process with the same active targeting rule in the new user screen
IAdvizeSDK.registerUserNavigation(NavigationOption.KEEP, "", "");
// To keep/start the engagement process but with another targeting rule for this screen
IAdvizeSDK.registerUserNavigation(NavigationOption.NEW, targetingRuleUUIDString, channel);
// To clear the active targeting rule and thus stopping the engagement process (this is the default behavior)
IAdvizeSdk.registerUserNavigation(navigationOption: NavigationOption.optionClear);
// To keep/start the engagement process with the same active targeting rule in the new user screen
IAdvizeSdk.registerUserNavigation(navigationOption: NavigationOption.optionKeep);
// To keep/start the engagement process but with another targeting rule for this screen
IAdvizeSdk.registerUserNavigation(
navigationOption: NavigationOption.optionNew,
newTargetingRule: TargetingRule(uuid: 'targeting-rule-uuid', channel: ConversationChannel.chat) // or ConversationChannel.video
)
Please note that calling registerUserNavigation with the CLEAR NavigationOption will stop the engagement process, and calling it with other options will start it if it is stopped.
👋 Configuring GDPR and welcome message
1️⃣ Adding a welcome message
As seen above, the Chatbox is empty by default. You can configure a welcome message that will be displayed to the visitor when no conversation is ongoing.
val configuration = ChatboxConfiguration()
configuration.automaticMessage = "Any question? Say Hello to Smart and we will answer you as soon as possible! 😊"
IAdvizeSDK.chatboxController.setupChatbox(configuration)
var configuration = ChatboxConfiguration()
configuration.automaticMessage = NSLocalizedString(
"Any question? Say Hello to Smart and we will answer you as soon as possible! 😊",
comment: ""
)
IAdvizeSDK.shared.chatboxController.setupChatbox(configuration: configuration)
const configuration: ChatboxConfiguration = {
automaticMessage: "Any question? Say Hello to Smart and we will answer you as soon as possible! 😊",
};
IAdvizeSDK.setChatboxConfiguration(configuration);
final ChatboxConfiguration configuration = ChatboxConfiguration(
automaticMessage: "Any question? Say Hello to Smart and we will answer you as soon as possible! 😊",
);
IAdvizeSdk.setChatboxConfiguration(configuration);
When no conversation is ongoing, the welcome message is displayed to the visitor:
2️⃣ Enabling GDPR approval
If you need to get the visitor consent on GDPR before he starts chatting, you can pass a GDPROption while activating the SDK. By default this option is set to Disabled.
If enabled, a message will request the visitor approval before allowing him to send a message to start the conversation:
This GDPR option dictates how the SDK behaves when the user taps on the More information button. You can either:
provide an URL pointing to your GPDR policy, it will be opened on user click
provide a listener/delegate that will be called on user click and you can then implement your own custom behavior
If your visitors have already consented to GDPR inside your application, you can activate the iAdvize SDK without the GDPR process. However, be careful to explicitly mention the iAdvize Chat part in your GDPR consent details.
// Disabled
val gdprOption = GDPROption.Disabled
// URL
val gdprOption = GDPROption.Enabled(GDPREnabledOption.LegalUrl(URI.create("http://my.gdpr.rules.com")))
// Listener
val gdprOption = GDPROption.Enabled(GDPREnabledOption.Listener(object : GDPRListener {
override fun didTapMoreInformation() {
// Implement your own logic
}
}))
val configuration = ChatboxConfiguration()
configuration.automaticMessage = "Any question? Say Hello to Smart and we will answer you as soon as possible! 😊"
configuration.gdprMessage = "Your own GDPR message."
IAdvizeSDK.chatboxController.setupChatbox(configuration)
// Disabled
let gdprOption = .disabled
// URL
if let legalInfoURL = URL(string: "http://my.gdpr.rules.com") {
let gdprOption = .enabled(option: .legalInformation(url: legalInfoURL))
}
// Listener
class GDPRMoreInfoListener: GDPRDelegate {
func didTapMoreInformation() {
// Implement your own logid
}
}
let gdprListener = GDPRMoreInfoListener()
let gdprOption = .enabled(option: .delegate(delegate: gdprListener))
var configuration = ChatboxConfiguration()
configuration.automaticMessage = NSLocalizedString(
"Any question? Say Hello to Smart and we will answer you as soon as possible! 😊",
comment: ""
)
configuration.gdprMessage = "Your own GDPR message."
IAdvizeSDK.shared.chatboxController.setupChatbox(configuration: configuration)
// No listener set + null URL => GDPR is disabled
await IAdvizeSDK.activate(projectId, userId, null);
// No listener set + non-null URL => GDPR is enabled, the webpage opens when user click on more info button
await IAdvizeSDK.activate(projectId, userId, "http://my.gdpr.rules.com");
// Listener set => GDPR is enabled, the listener is called when user click on more info button
IAdvizeSDKListeners.onGDPRMoreInfoClicked(function (eventData: any) {
// Implement your own behavior
});
await IAdvizeSDK.activate(projectId, userId, null);
If you set both the listener and an URL, the listener will take priority.
var configuration = ChatboxConfiguration()
configuration.automaticMessage = NSLocalizedString(
"Any question? Say Hello to Smart and we will answer you as soon as possible! 😊",
comment: ""
)
configuration.gdprMessage = "Your own GDPR message."
IAdvizeSDK.setChatboxConfiguration(configuration: configuration)
// Disabled
GDPROption gdprOption = GDPROption.disabled();
// URL
GDPROption gdprOption = GDPROption.url(url: "http://my.gdpr.rules.com")
// Listener
GDPROption gdprOption = GDPROption.listener(onMoreInfoClicked: () {
log('iAdvize Example : GDPR More Info button clicked');
// Implement your own logic here
});
final ChatboxConfiguration configuration = ChatboxConfiguration(
gdprMessage: "Your own GDPR message",
);
IAdvizeSdk.setChatboxConfiguration(configuration);
🎨 Branding the Chatbox
The ChatboxConfiguration object that we used in the previous section to customize the welcome and GDPR messages can also be used to change the Chatbox UI to better fit into the look and feel of your application.
You should setup the configuration before presenting the chatbox. If you call this method while the chatbox is visible, some parameters will only apply for new messages or after closing/reopening the chatbox.
1️⃣ Updating the font
The font used in the Chatbox can easily be updated using your own font:
val configuration = ChatboxConfiguration()
configuration.fontPath = "fonts/comic_sans_ms_regular.ttf"
IAdvizeSDK.chatboxController.setupChatbox(configuration)
The font should be placed inside the assets folder. Here the file is located at src/main/assets/fonts/comic_sans_ms_regular.ttf
Even if the UIFont constructor needs a size attribute, the exact font size and traits are automatically chosen and the font is scaled to the current Dynamic Type setting.
The font should either be a system font, or be a font embedded into the app, with a font file inside the bundle and its corresponding declaration into the Info.plist file.
const configuration: ChatboxConfiguration = {
// For iOS devices
fontName: 'AmericanTypewriter-Condensed',
fontSize: 11, // iOS only
// For Android devices
fontPath: 'fonts/comic_sans_ms_regular.ttf',
};
On iOS the font should either be a system font, or be a font embedded into the app, with a font file inside the bundle and its corresponding declaration into the Info.plist file.
On Android the font should be placed inside the assets folder. Here the file is located at src/main/assets/fonts/comic_sans_ms_regular.ttf
final ChatboxConfiguration configuration = ChatboxConfiguration(
// For iOS devices
iosFontName: 'AmericanTypewriter-Condensed',
iosFontSize: 11,
// For Android devices
androidFontPath: 'fonts/comic_sans_ms_regular.ttf',
);
IAdvizeSdk.setChatboxConfiguration(configuration);
On iOS the font should either be a system font, or be a font embedded into the app, with a font file inside the bundle and its corresponding declaration into the Info.plist file.
On Android the font should be placed inside the assets folder. Here the file is located at src/main/assets/fonts/comic_sans_ms_regular.ttf
2️⃣ Styling the navigation bar
Some parts of the he toolbar/navigationbar appearing at the top of the Chatbox can also be customized:
The operator avatar displayed alongside his messages can be updated for branding purposes. You can specify a drawable either via an URL or a local resource.
val configuration = ChatboxConfiguration()
// Update the incoming message avatar with a Drawable resource.
configuration.incomingMessageAvatar = IncomingMessageAvatar.Image(
ContextCompat.getDrawable(context, R.drawable.ic_brand_avatar)
)
// Update the incoming message avatar with an URL.
configuration.incomingMessageAvatar = IncomingMessageAvatar.Url(URL("http://avatar.url"))
IAdvizeSDK.chatboxController.setupChatbox(configuration)
var configuration = ChatboxConfiguration()
// Update the incoming message avatar with a UIImage.
configuration.incomingMessageAvatar = .image(image: UIImage(named: "BrandAvatar"))
// Update the incoming message avatar with an URL.
configuration.incomingMessageAvatar = .url(url: "http://avatar.url")
IAdvizeSDK.shared.chatboxController.setupChatbox(configuration: configuration)
If you fill both fields, incomingMessageAvatarImageName will take priority over incomingMessageAvatarURL.
final ChatboxConfiguration configuration = ChatboxConfiguration(
incomingMessageAvatarImage: const AssetImage('assets/test.jpeg'),
// OR
incomingMessageAvatarURL: 'https://picsum.photos/200/200',
);
IAdvizeSdk.setChatboxConfiguration(configuration);
If you fill both fields, incomingMessageAvatarImageName will take priority over incomingMessageAvatarURL.
GIFs are not supported.
🎨 Branding the Default Floating Button
By default, the SDK uses its own Default Floating Button for the user to engage in the conversation. This Default Floating Button display process is automated by the SDK and works out of the box. You have however limited possibilities to brand it to your needs.
The Default Floating Button can be parametrized, both in its look (colors / icon) and position (anchor / margins) using the appropriate configuration:
val configuration = DefaultFloatingButtonConfiguration(
anchor = Gravity.START or Gravity.BOTTOM,
margins = DefaultFloatingButtonMargins(),
backgroundTint = ContextCompat.getColor(this, R.color.colorPrimary),
iconResIds = mapOf(
ConversationChannel.CHAT to R.drawable.chat_icon,
ConversationChannel.VIDEO to R.drawable.video_icon
)
iconTint = Color.WHITE
)
val option = DefaultFloatingButtonOption.Enabled(configuration)
IAdvizeSDK.defaultFloatingButtonController.setupDefaultFloatingButton(option)
If you are not satisfied with the Default Floating Button look and feel or if you want to implement a specific behavior related to its display you may need to use a custom conversation button.
With a custom button it is your responsibility to:
design the floating or fixed button to invite your user to chat
hide/show the button following the active targeting rule availability and the ongoing conversation status
open the Chatbox when the user presses your button
The chat button is linked to the targeting and conversation workflow and should update its visibility each time the status of those workflows is changed. First of all you need to implement the appropriate callbacks:
IAdvizeSDK.targetingController.listeners.add(object : TargetingListener {
override fun onActiveTargetingRuleAvailabilityUpdated(isActiveTargetingRuleAvailable: Boolean) {
// SDK active rule availability changed to isActiveTargetingRuleAvailable
updateChatButtonVisibility()
}
})
IAdvizeSDK.conversationController.listeners.add(object : ConversationListener {
override fun onOngoingConversationUpdated(ongoingConversation: OngoingConversation?) {
// SDK ongoing conversation has updated
updateChatButtonVisibility()
}
override fun onNewMessageReceived(content: String) {
// A new message was received via the SDK
}
override fun handleClickedUrl(uri: Uri): Boolean {
// A message link was tapped, return true if you want your app to handle it
return false
}
})
extension IntegrationApp: TargetingControllerDelegate {
func activeTargetingRuleAvailabilityDidUpdate(isActiveTargetingRuleAvailable: Bool) {
// SDK active rule availability changed to isActiveTargetingRuleAvailable
updateChatButtonVisibility()
}
}
extension IntegrationApp: ConversationControllerDelegate {
func ongoingConversationUpdated(ongoingConversation: IAdvizeConversationSDK.OngoingConversation?) {
// SDK ongoing conversation status changed
updateChatButtonVisibility()
}
func didReceiveNewMessage(content: String) {
// A new message was received via the SDK
}
func conversationController(_ controller: ConversationController, shouldOpen url: URL) -> Bool {
// A message link was tapped, return true if you want your app to handle it
}
}
class IntegrationApp {
IAdvizeSDK.shared.targetingController.delegate = self
IAdvizeSDK.shared.conversationController.delegate = self
}