live_chat_plus 1.0.5 live_chat_plus: ^1.0.5 copied to clipboard
A Flutter plugin to bring LiveChat functionality to Flutter. It wraps chat-window android and ios SDKs, in addition to support for web
live_chat_plus #
LiveChat is a plugin that brings LiveChat functionality to Flutter Mobile and Web.
Installation #
First, add live_chat_plus
as a dependency in your pubspec.yaml file.
Android #
Step 1: Ensure you have added Internet permission in AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET"/>
Step 2: To avoid issues with proguard enabled, include the following to proguard.pro file:
-keep class com.livechatinc.inappchat.** { *; }
Web #
Inside index.html file, add this line inside <head></head>
tag:
<script src="./assets/packages/live_chat_plus/assets/live_chat.js" defer></script>
Usage #
- To start, import the following:
import 'package:live_chat_plus/live_chat_plus.dart';
- To open the chat window, call openChatView as follows:
await LiveChat().openChatWindow(
licenseId: '<LICENSE ID>',
username: '<USERNAME>',
email: '<EMAIL>',
groupId: '<GROUP ID>',
customParameters: <String, String>{'CUSTOM KEY': 'CUSTOM VALUE'},
);
- You can subscribe to an event stream to listen to events coming from livechat.
LiveChat().onLiveChatEventReceived?.listen((event) {
switch (event) {
case 'chatOpen':
break;
case 'chatClose':
break;
default:
// Messages - You can handle notification badge counts for example here.
}
});
- You call close the chat window by simply calling:
LiveChat().closeChatWindow();
- In order to clear the session in mobile, for example, after logging out, you can call:
LiveChat().clearChatSession();
This will call destroy on web.
Sample App #
Refer to the example folder for a working app. Just ensure you have a valid license id.