A livechat package for embedding mobile chat window in your mobile application.
dependencies:
livechatt: ^1.5.1
import 'package:livechatt/livechatt.dart';
Get the Crendentials for your LiveChat
- Edit AndroidManifest.xml as shown below
<uses-permission android:name="android.permission.INTERNET"/>
<activity android:name="com.livechatinc.inappchat.ChatWindowActivity" android:configChanges="orientation|screenSize" />
- Set minimum deployment target of iOS to 11.0
- Edit info.plist as shown below
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app require access to the microphone.</string>
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera.</string>
Add the below to your podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
end
end
- Regular usage
onPressed: (){
Livechat.beginChat(LICENSE_NO);
},
- Cases where there are custom parameters
var cmap = <String, String>{
'org': 'organizationTextController.text',
'position': 'positionTextController.text'
};
onPressed: (){
Livechat.beginChat(
LICENSE_NO,
groupId: GROUP_ID,
visitorName: VISITOR_NAME,
visitorEmail: VISITOR_EMAIL,
customParams: cmap,
);
},
For more info, please, refer to the main.dart
in the example.
The package now supports embedded views for custom positioning within your app’s layout:
var cmap = <String, String>{
'org': 'organizationTextController.text',
'position': 'positionTextController.text'
};
Livechat.embeddedChat(
licenseNo: 'your_license',
groupId: 'group_id',
visitorEmail: 'visitor_email',
visitorName: 'visitor_name',
customParams: cmap,
)
For more info, please refer to EmbeddedChatWidget
in main.dart
in the example.
Android only
The plugin streams various events such as new messages, visibility changes, and errors from the chat window. You can listen to events like this:
Livechat.chatEvents.listen((event) {
print(event);
});
For specific events, you can stream:
Livechat.newMessages.listen((message) {
print(message);
});
Livechat.visibilityChanges.listen((isVisible) {
print("Chat Window is visible: $isVisible");
});
Livechat.errors.listen((error) {
print("Error: ${error['errorDescription']}");
});
Livechat.uriHandlers.listen((message) {
print(message);
});
Livechat.filePickerActivity.listen((message) {
print(message);
});
Livechat.windowInitialized.listen((message) {
print(message);
});
For more info, please refer to EmbeddedChatWidget
in main.dart
in the example.
If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on Github and I'll look into it. Pull request are also welcome.
This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.