termii_resolve_livechat 0.1.0
termii_resolve_livechat: ^0.1.0 copied to clipboard
Termii Resolve Live Chat SDK for Flutter. Add Termii in-app customer support to any Flutter app in a few lines, with user identification and unread-count events.
Termii Resolve Live Chat Flutter SDK #
Termii Resolve Live Chat SDK for Flutter. Add Termii in-app customer support to any Flutter app in a few lines.
All chat UI, messaging, and real-time transport are hosted by Termii, so fixes and new features reach your users without an SDK update.
Features #
- 🚀 Easy integration with Flutter apps
- 💬 Real-time messaging with WebSocket support
- 📱 Works on iOS and Android
- 👤 Support for both anonymous and authenticated users
- 📎 File upload support (images, documents, videos)
- 😊 Emoji picker
- 🎨 Customizable themes and branding
- 🔔 Unread message badges
- 🔐 Automatic user authentication integration
- 🛡️ Built-in security: XSS prevention, input validation, and sanitization
Quick Start #
dependencies:
termii_resolve_livechat: ^0.1.0
import 'package:termii_resolve_livechat/termii_resolve_livechat.dart';
// Anonymous visitor
await TermiiLiveChat.open(context, widgetId: 'YOUR_WIDGET_ID');
// Signed-in user
await TermiiLiveChat.open(
context,
widgetId: 'YOUR_WIDGET_ID',
user: TermiiUser(
email: 'jane@example.com', // required
name: 'Jane Doe',
phone: '+2348012345678',
),
);
TermiiLiveChat.open pushes a full-screen chat route and pops it when the
user taps the chat's close button. Your widgetId comes from the
Termii dashboard.
User Authentication #
The SDK supports both anonymous and authenticated users. For signed-in users, pass TermiiUser data so they can start chatting immediately and their conversations are linked to their profile.
Security Note: You don't need to sanitize or validate user data - the widget handles all XSS prevention, input validation, and sanitization automatically.
Custom Layouts #
For custom layouts (tabs, split views), use the widget directly:
TermiiChatWidget(
widgetId: 'YOUR_WIDGET_ID',
user: TermiiUser(email: 'jane@example.com'),
onChatClosed: () => Navigator.of(context).pop(),
onUnreadCountChanged: (count) => setState(() => _badge = count),
onError: (event) => log('chat failed: ${event.errorCode}'),
)
Unread Badges #
Unread counts accrue while the chat is not visible. The SDK mirrors app background/foreground automatically (manageAppLifecycle: true); if you hide the chat another way (e.g. keeping it alive behind a tab), mirror it yourself with a controller:
final controller = TermiiChatController();
TermiiChatWidget(widgetId: '...', controller: controller);
controller.setChatVisibility(false); // hidden → replies count as unread
controller.setChatVisibility(true); // visible again → badge clears
controller.updateUser(TermiiUser(email: 'jane@example.com')); // post-login
File Attachments (Android) #
iOS presents its file picker natively. Android WebViews delegate picking to the host app — provide onAttachFile and return local file URIs, e.g. with file_picker:
TermiiChatWidget(
widgetId: '...',
onAttachFile: (request) async {
final result = await FilePicker.platform.pickFiles(
allowMultiple: request.allowMultiple,
);
return result?.files.map((f) => Uri.file(f.path!).toString()).toList() ?? [];
},
)
Links Inside the Chat #
Navigation away from the chat page is blocked. To open external links (e.g. in messages), handle onExternalUrl with url_launcher:
onExternalUrl: (url) => launchUrl(url, mode: LaunchMode.externalApplication),
Platform Setup #
Android #
- Minimum SDK version:
21+ - Add
INTERNETpermission toAndroidManifest.xml(debug builds already have it):<uses-permission android:name="android.permission.INTERNET" />
iOS #
- No additional setup required — the chat page is served over HTTPS.
Session Persistence: Visitor identity persists in the WebView's storage. Clearing app/WebView data resets anonymous visitors. Identified users are re-linked by email.
API Reference #
TermiiLiveChat #
open(context, widgetId, user): Push a full-screen chat route- Parameters:
context,widgetId(string),user(optional TermiiUser) - Closes when user taps the close button
- Parameters:
TermiiChatWidget #
widgetId(string, required): Widget ID from the Termii dashboarduser(TermiiUser, optional): User data for authenticationcontroller(TermiiChatController, optional): Control visibility and update user dataonChatClosed(callback): Called when user closes the chatonUnreadCountChanged(callback): Called when unread count changesonAttachFile(callback): Handle file attachments (Android)onExternalUrl(callback): Handle external linksmanageAppLifecycle(bool): Auto-manage visibility with app lifecycle (default: true)
TermiiChatController #
setChatVisibility(bool): Show or hide the chatupdateUser(TermiiUser): Update user data after initialization
TermiiUser #
email(string, required): User's email addressname(string, optional): User's full namephone(string, optional): User's phone number
Example #
See example/ — run with your own widget ID:
cd example
flutter run --dart-define=RESOLVE_WIDGET_ID=YOUR_WIDGET_ID
Documentation #
- 📖 Integration Guide - Detailed integration examples
Support #
- 📧 Email: support@termii.com
- 💬 Live Chat: Visit termii.com/products/resolve
- 🐛 Issues: GitHub Issues
Built with ❤️ by Termii