Flutter Installation
Kommunicate Flutter plugin
Flutter wrapper using the native modules of Kommunicate Android and iOS SDKs.
Overview
Kommunicate Flutter SDK allows you to add customizable live chat to your applications. We support many hybrid platforms that are currently in the market; hence we have added the support for Flutter that provides a fast and expressive way for developers to build native apps on both IOS and Android.
Prerequisites
For iOS
- Apps using Kommunicate can target iOS 13 or later
- Xcode 12 or later required
For Android
- Android 4.1 (API level 16) or higher
- Java 7 or higher
- Android Gradle Plugin 3.4.0 or higher
Installation
- Add the below dependency in your pubspec.yaml file:
dependencies:
# other dependencies
kommunicate_flutter: ^1.9.1
- Run the below command to install the package:
flutter pub get
- Import
kommunicate_flutter
in your .dart file to use the methods from Kommunicate:
import 'package:kommunicate_flutter/kommunicate_flutter.dart';
Note: Add 'tools:replace="android:label"' in your application tag on AndroidManifest.xml wherever the android:label is used to avoid manifest merger failed issue during compilation of the project.
- For iOS, navigate to your App/iOS directory from terminal and run the below command:
pod install
Note: Kommunicate flutter(iOS) plugin requires minimum deployment version to be iOS 13.0 and uses dynamic frameworks. Make sure you have the below settings at the top of your iOS/Podfile:
platform :ios, '13.0'
use_frameworks!
Permissions
Permissions for Android
Add permissions if you need to use certain features like Camera, Storage, Location then you need to add it to your own app's AndroidManifest.xml file..
If you use Camera and Gallery Storage feature, add these permission:
<uses-permission
android:name="android.permission.CAMERA"
tools:node="merge" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
tools:ignore="ScopedStorage"
tools:node="merge" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
tools:node="merge" />
<!--Permissions to be used when your app targets API 33 or higher-->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
If you use Audio record / Speech to text feature, add these permissions:
<uses-permission
android:name="android.permission.RECORD_AUDIO"
tools:node="merge" />
If you use Location feature, add these permissions:
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
tools:node="merge" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
tools:node="merge" />
Permissions for iOS
Add permissions for Camera, Photo Library, Microphone and Location usage.
Note: We won't be asking the users for these permissions unless they use the respective feature. Due to Apple's requirement, we have to add these permissions if we are using any of their APIs related to Camera, Microphone etc.
In your app's Info.plist
file as ‘Source code’ and paste these permissions anywhere inside the <dict>
tag.
<key>NSCameraUsageDescription</key>
<string>Allow Camera</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow location sharing!!</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allow MicroPhone</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allow Photos</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Allow write access</string>
ProGuard for Android
Add the below rules in your proguard-rules.pro file under android/app/ directory. If the file is not present, create a new one and then add the rules.
#keep JSON classes
-keep class * extends com.applozic.mobicommons.json.JsonMarker {
!static !transient <fields>;
}
-keepclassmembernames class * extends com.applozic.mobicommons.json.JsonParcelableMarker {
!static !transient <fields>;
}
#GSON Config
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.examples.android.model.** { *; }
-keep class org.eclipse.paho.client.mqttv3.logging.JSR47Logger { *; }
-keep class android.support.** { *; }
-keep interface android.support.** { *; }
-dontwarn android.support.v4.**
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
-keep class com.google.gson.** { *; }
Get your App Id
Sign up for Kommunicate to get your APP_ID. This APP_ID is used to create/launch conversations.