This repository goal is to demonstrate the integration process of the iAdvize Flutter SDK. Each commit corresponds to an integration step and is described below.
$ flutter doctor
[✓] Flutter (Channel stable, 3.7.9, on macOS 13.2.1 22D68 darwin-arm64, locale en-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] IntelliJ IDEA Community Edition (version 2022.2.1)
[✓] VS Code (version 1.77.0)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
To install the Flutter boilerplate code, run the following command:
flutter create integration_demo_app
This will create a integration_demo_app
folder containing the Flutter project.
The Dart version used in this case is:
dart: ">=2.19.6 <3.0.0"
For the rest of this guide, the root folder for all commands will be the integration_demo_app
repository so navigate to this folder:
cd integration_demo_app
To launch the app on a device run:
flutter run lib/main.dart
To integrate the iAdvize SDK Flutter Plugin inside the demo project, run the following command:
flutter pub add iadvize_flutter_sdk
This will add the dependency inside the pubspec.yaml
file
$ pubspec.yaml
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
iadvize_flutter_sdk: ^2.10.1
The iAdvize iOS SDK supports iOS 12 and further, you must define the minimum iOS platform at the top of your ios/Podfile
file:
$ ios/Podfile
# Add this line
platform :ios, '12.0'
Add this step inside the post_install
hook at the end of the Podfile
to enable Swift Library Evolution:
$ ios/Podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
# Add those lines
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
Library evolution support allows developers of binary frameworks to make additive changes to the API of their framework while remaining binary compatible with previous versions.
Once this is done, is it possible to download the iOS dependency pod:
cd ios
pod install
cd ..
Since the version 2.5.0, the iAdvize iOS SDK supports video conversations. Thus it will request camera and microphone access before entering a video call. To prevent the app from crashing at this stage, you have to setup two keys in your app Info.plist
:
$ ios/Runner/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
...
<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>
</dict>
</plist>
The iAdvize Android SDK is hosted on GitHub, this repository should be declared in the Android app in order for it to find the SDK artifacts:
$ android/build.gradle
allprojects {
repositories {
google()
mavenCentral()
// Add those lines
maven { url "https://raw.github.com/iadvize/iadvize-android-sdk/master" }
maven { url "https://jitpack.io" }
}
}
The latest iAdvize Android SDK used Kotlin 1.8.10
. To avoid conflict between the Kotlin versions used in the Flutter dependencies, this version needs to be set in the Android configuration.
In the project-level android/build.gradle
file, update the Kotlin version in the buildscript
block:
$ android/build.gradle
buildscript {
// Update the Kotlin version
ext.kotlin_version = '1.8.10' // was 1.7.10
}
The iAdvize Android SDK supports Android API 21 and further, you must define the minimum supported API inside the android/build.gradle
file:
$ android/build.gradle
android {
defaultConfig {
applicationId "com.example.integration_demo_app"
minSdkVersion 21 // was minSdkVersion flutter.minSdkVersion
targetSdkVersion 33 // was targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
}
Add the IAdvize SDK import statement:
$ lib/main.dart
import 'package:iadvize_flutter_sdk/iadvize_flutter_sdk.dart';
Then you can activate using the relevant API:
$ lib/main.dart
IAdvizeSdk.activate(
projectId: projectId,
authenticationOption: authOption,
gdprOption: gdprOption,
)
Once the SDK is activated you can engage the visitor using the relevant API:
$ lib/main.dart
IAdvizeSDK.setLanguage("targetingLanguage");
IAdvizeSdk.activateTargetingRule(
TargetingRule(
uuid: 'targetingRuleId',
channel: ConversationChannel.chat,
),
);
This will display the Default Floating Button that leads to the Chatbox.
To go further in your integration you will need to read the SDK documentation available in our Developer Platform.
This covers a wide range of the use cases you may have (chatbox configuration, custom button, notifications, transactions, custom data registration...)