Orientação gerada a partir de informações públicas. Apenas para referência.
Crisp Chat é um plugin Flutter que permite a integração nativa da plataforma de chat Crisp em dispositivos Android e iOS. Ele permite que desenvolvedores incorporarem funcionalidades de suporte ao cliente em tempo real diretamente em seus aplicativos Flutter, proporcionando comunicação fluida entre usuários e equipes de suporte. O pacote utiliza SDKs nativos do Crisp para desempenho ótimo e completa funcionalidade. Suporta identificação de usuário, gerenciamento de sessão e rastreamento de mensagens, garantindo uma experiência consistente entre plataformas.
Casos de uso
Suporte ao cliente no aplicativo
Assistência em tempo real ao usuário
Integração de chat ao vivo em aplicativos móveis
Engajamento do usuário por meio de mensagens
Criação de ticket de suporte por chat
Consistência de chat multiplataforma
Principais recursos
Implementação nativa para Android e iOS
Gerenciamento de sessão do usuário
Mensagens em tempo real
Suporte para identificação de usuário
Leve e fácil configuração
Otimizações específicas de plataforma
Indicado para
Aplicativos móveis que exigem suporte ao vivo
Aplicativos de comércio eletrônico e baseados em serviços
Aplicativos com alta necessidade de engajamento do usuário
Desenvolvedores usando o Crisp como sua plataforma de suporte
Projetos que precisam de confiabilidade de chat multiplataforma
Considerações
Requer conta Crisp e chaves de API
Limitado ao conjunto de recursos do Crisp
Depende das atualizações do SDK Crisp
Sem suporte a web ou desktop
Pode exigir configuração adicional para recursos avançados
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
Crisp Chat
A Flutter plugin for Crisp live chat on Android, iOS, Web, and desktop (macOS, Windows, Linux).
Chat with website visitors, integrate your favorite tools, and deliver a great customer experience. On mobile, the plugin uses the official Crisp Android and iOS SDKs. On Web and desktop, it uses the official Crisp Web Chat SDK (embedded chatbox or desktop WebView). The same Dart API covers session data, events, and REST helpers where supported.
📖 Full Documentation — Comprehensive guides, API reference, and examples.
Note: Contributions are highly appreciated. If you have an idea or suggestion to improve this package, feel free to reach out. Before contributing, please review the CONTRIBUTING.md file for guidelines and setup instructions.
Features
Null-safety enable
Easy to use
Customizable
User configuration with company and geoLocation
Send user notification about missing messages
Optional iOS video/audio calls (build-time opt-in via CrispWebRTC SDK)
Helpdesk / FAQ — open the Crisp helpdesk search or a specific article directly (Android, iOS, Web, and desktop)
Bot Scenarios — trigger a configured Crisp Bot scenario by ID (Android, iOS, Web, and desktop)
Android, iOS, Web, macOS, Windows, and Linux
Platform overview
Platform
How chat opens
Extra setup
Android
Native Crisp SDK
Internet permission, compileSdk / minSdk
iOS
Native Crisp SDK
Privacy keys in Info.plist; optional video via $CrispChatWebRTC (CocoaPods) or CRISP_CHAT_WEBRTC (SPM)
Web
Crisp Web Chat SDK ($crisp)
Valid websiteID; optional CSP for client.crisp.chat
To use the Flutter Crisp Chat, simply import the crisp_chat package:
Run this on your project terminal:
flutterpubaddcrisp_chat
or manually configure pubspec.yml file
dependencies:flutter:sdk:fluttercrisp_chat:^2.8.0
Web / desktop: No native Crisp SDK install. Web loads client.crisp.chat at runtime. Desktop uses an embedded WebView (desktop_webview_window) or opens your browser if WebView is unavailable. See Supported platforms in the docs.
2. Setup platform specific settings
iOS and Android
Configure permissions and push as below. Web and desktop only need a valid websiteID unless you use REST unread helpers (prefer a backend proxy on web).
iOS
Add three rows to the ios/Runner/Info.plist:
key Privacy - Camera Usage Description and a usage description.
key Privacy - Photo Library Additions Usage Description and a usage description.
key Privacy - Microphone Usage Description and a usage description.
Optional — video/audio calls (iOS only):CocoaPods:$CrispChatWebRTC = true in ios/Podfile, then pod install. SPM (Flutter 3.44+ default):CRISP_CHAT_WEBRTC=true flutter build ios. Adds ~10 MB. Android native video is not supported yet by Crisp. See Platform setup — Enable video calls.
Android
Add Internet permission on AndroidManifest.xml in your android/app/src/main/AndroidManifest.xml file.
Identity verification: only pass User.signature when it is a real HMAC-SHA256 hex string from your server (32+ hex characters). Placeholder values can leave the chat stuck on the loading skeleton.
If you use a Content-Security-Policy, allow https://client.crisp.chat and https://*.crisp.chat
For REST unread helpers on Web, do not ship API secrets in the client — use a backend proxy in production
Run the example:
cd example && flutter run -d chrome --dart-define=websiteId=YOUR_WEBSITE_ID
Desktop (macOS, Windows, Linux)
Uses the same Crisp Web Chat SDK in an embedded window (desktop_webview_window), or opens the system browser if WebView is unavailable.
Notifications will be handled by CrispCrispNotificationService and a tap on it will launch your MainActivity and automatically open the Crisp ChatActivity with the corresponding session.
Option B: Open app first, then chatbox (recommended)
If you want your app to open first (so the user sees your app UI) and then open the Crisp chatbox programmatically, use the SDK's CrispChatNotificationService instead:
Then in your Flutter code, handle the notification tap to open the chatbox:
@overridevoidinitState() {
super.initState();
// Handle app launched from a Crisp notification (terminated state)FlutterCrispChat.openChatboxFromNotification();
// Handle notification tap while app is in the backgroundFlutterCrispChat.setOnNotificationTappedCallback(() {
FlutterCrispChat.openChatboxFromNotification();
});
}
openChatboxFromNotification() — Checks if the app was launched from a Crisp notification and opens the chatbox. Returns true if successful, false otherwise.
setOnNotificationTappedCallback(callback) — Sets a callback that fires when a Crisp notification is tapped while the app is already running in the background.
iv). Customize Push notifications for android app
Crisp Push notifications customizable in 3 ways: color, icon and sound.
For the first two, you can update them from your AndroidManifest.xml as you would do with Firebase.
Currently, push notifications are only sent to production APNs channels. Notifications will not be received when testing with development provisioning profiles or in sandbox mode. This limitation will be resolved in a future update.
vii). Ensure Firebase initialization in your Flutter project
The process of handling background messages is different on native Android and Apple platforms.
There are a few things to keep in mind about your background message handler:
It must not be an anonymous function.
It must be a top-level function (e.g. not a class method which requires initialization).
When using Flutter version 3.3.0 or higher, the message handler must be annotated with @pragma('vm:entry-point') right above the function declaration (otherwise it may be removed during tree shaking for release mode).
import'package:firebase_core/firebase_core.dart';
import'package:firebase_messaging/firebase_messaging.dart';
import'firebase_options.dart';
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
// If you're going to use other Firebase services in the background, such as Firestore,// make sure you call `initializeApp` before using other Firebase services.awaitFirebase.initializeApp();
print("Handling a background message: ${message.messageId}");
}
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
awaitFirebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(constMyApp());
}
Android / iOS: disable Lock the chatbox to website domain (and subdomains) under Settings → Website Settings → Chatbox & Email Settings → Chatbox Security. With domain lock enabled, chat fails with "Error starting chat" even when the Website ID is valid. See docs — Chatbox Security.
5. Setup your flutter app to use Crisp
Here's a more detailed example of how to configure CrispConfig and use the plugin methods. To open ChatView for crisp, use the openCrispChat method of the FlutterCrispChat class:
import'package:flutter/material.dart';
import'package:crisp_chat/crisp_chat.dart';
import'package:flutter/foundation.dart'; // For kDebugModeclassCrispChatPageextendsStatefulWidget{
constCrispChatPage({super.key});
@overrideState<CrispChatPage> createState() => _CrispChatPageState();
}
class_CrispChatPageStateextendsState<CrispChatPage> {
finalString websiteID = 'YOUR_WEBSITE_ID'; // Replace with your actual Website IDfinalString identifier = 'YOUR_CRISP_API_IDENTIFIER'; // Replace with your actual Crisp API IdentifierfinalString crispApiKey = 'YOUR_CRISP_API_KEY'; // Replace with your actual Crisp API Keyint count = 0;
lateCrispConfig _crispConfig;
@overridevoidinitState() {
super.initState();
// Handle Crisp notification tap (Option B only - see section 3.iii)// Opens the chatbox if the app was launched from a Crisp notification (terminated state)FlutterCrispChat.openChatboxFromNotification();
// Listen for Crisp notification taps while the app is in the backgroundFlutterCrispChat.setOnNotificationTappedCallback(() {
FlutterCrispChat.openChatboxFromNotification();
});
// Configure Crisp User (Optional)// All user fields are optional. Only provide what you have.final crispUser = User(
email: "user@example.com",
signature: "USER_EMAIL_HMAC_SHA256_SIGNATURE",
nickName: "John Doe",
phone: "1234567890",
avatar: "https://example.com/avatar.png",
company: Company(
name: "Example Corp",
url: "https://example.com",
companyDescription: "A sample company providing excellent services.",
employment: Employment(title: "Lead Developer", role: "Software Engineer"),
geoLocation: GeoLocation(city: "New York", country: "USA"),
),
);
// 1. Initialize CrispConfig with all desired parameters.
_crispConfig = CrispConfig(
websiteID: websiteID, // [required] Your Crisp website ID.
tokenId: "your_user_token_id_optional", // Optional: Assign a unique token to this session.
sessionSegment: "beta_testers", // Optional: Assign a segment to categorize users (e.g., "premium", "trial").
user: crispUser, // Optional: Provide user details.
enableNotifications: true, // Optional: Enable or disable push notifications. Defaults to true.
modalPresentationStyle: ModalPresentationStyle.fullScreen, // Optional: iOS modal presentation style. Defaults to fullScreen.
);
// 2. Optionally, set additional session data *before* opening the chat.// This data is associated with the session when it's created or next resumed.// Useful for sending custom attributes that might not fit into the User object.FlutterCrispChat.setSessionString(key: "custom_data_point", value: "some_important_value");
FlutterCrispChat.setSessionInt(key: "user_score", value: 120);
FlutterCrispChat.setSessionSegments(segments: ["registered_user", "newsletter_subscriber"], overwrite: false);
}
void_openChat() async {
// 3. Open the Crisp Chat UI using the prepared configuration.awaitFlutterCrispChat.openCrispChat(config: _crispConfig);
// 4. Optionally, retrieve the session identifier after the chat is opened.// This can be useful for logging or internal tracking.String? sessionId = awaitFlutterCrispChat.getSessionIdentifier();
if (sessionId != null) {
if (kDebugMode) {
print('Crisp Session ID: $sessionId');
}
} else {
if (kDebugMode) {
print('No active Crisp session found or an error occurred while retrieving the ID.');
}
}
}
void_resetSession() async {
// Call resetCrispChatSession, for example, when your app user logs out.// This is crucial for privacy and ensuring that the next user (or a guest)// does not see or interact with the previous user's chat history and data// within the Crisp SDK session on the device.awaitFlutterCrispChat.resetCrispChatSession();
if (kDebugMode) {
print('Crisp session has been reset. The previous user\'s data is cleared from the local SDK session.');
}
}
void_checkUnreadMessages() async {
// Call getUnreadMessageCount to check for unread messages.int? unreadCount = awaitFlutterCrispChat.getUnreadMessageCount(
websiteId: websiteID,
identifier: identifier,
key: crispApiKey,
);
if (unreadCount != null && unreadCount > 0) {
if (kDebugMode) {
print('You have $unreadCount unread messages.');
}
setState(() {
count = unreadCount;
});
}
}
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
appBar: AppBar(
title: constText('Crisp Chat Example'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: _openChat,
child: constText('Open Crisp Chat (Full Config)'),
),
constSizedBox(height: 20),
ElevatedButton(
onPressed: _resetSession,
child: constText('Reset Crisp Session'),
),
constSizedBox(height: 20),
Badge.count(
count: count,
isLabelVisible: count != 0,
maxCount: 9,
child: ElevatedButton(
onPressed: _checkUnreadMessages,
child: Text('Unread'),
),
)
],
),
),
);
}
}
To use this code, replace YOUR_WEBSITE_ID with your own website ID from the Crisp dashboard. The example demonstrates initializing CrispConfig with detailed user and company information, setting additional session data, opening the chat interface, retrieving the session ID, and resetting the session. Adjust the configuration and data according to your application's needs.
iOS Modal Presentation Styles
The modalPresentationStyle parameter in CrispConfig allows you to control how the Crisp chat view is presented on iOS devices. This is particularly important for preventing touch events from passing through to the underlying Flutter UI.
Available Modal Presentation Styles:
ModalPresentationStyle.fullScreen (Default) - The view controller covers the entire screen. This prevents touch events from passing through to the underlying UI.
ModalPresentationStyle.pageSheet - The view controller is displayed as a page sheet with a dimmed background.
ModalPresentationStyle.formSheet - The view controller is displayed as a form sheet, centered on the screen.
ModalPresentationStyle.overFullScreen - The view controller covers the screen but allows underlying content to show through.
ModalPresentationStyle.overCurrentContext - The view controller is displayed over the parent view controller's content.
ModalPresentationStyle.popover - Popover on iPad (centered); on iPhone UIKit adapts to full screen.
Note: This parameter is iOS-specific and will only affect iOS devices. On Android, the chat will always use the platform's default presentation behavior. On Web and desktop, it is ignored.
iOS video and audio calls (optional)
Crisp video/audio calls are iOS-only and opt-in at build time (not a CrispConfig flag). Default builds use the standard Crisp SDK without calls.
Build system
Enable video
CocoaPods
$CrispChatWebRTC = true in ios/Podfile, then pod install
SPM
CRISP_CHAT_WEBRTC=true flutter build ios
Check at runtime:
final supported = awaitFlutterCrispChat.isVideoCallsSupported();
// true on iOS WebRTC builds, Web, and desktop; false on Android and default iOS builds
Open the Crisp Helpdesk/FAQ interface directly without going through the live chat. Useful when you want to direct users to self-service help content.
Platform support: All platforms — Android, iOS, Web, macOS, Windows, and Linux. Android/iOS use the native SDK; Web and desktop use the Crisp Web Chat SDK ($crisp.push).
awaitFlutterCrispChat.openHelpdeskArticle(
websiteId: 'YOUR_WEBSITE_ID',
locale: 'en', // article language code
slug: 'article-slug', // article slug from your Crisp Helpdesk dashboard
title: 'Optional title', // optional
category: 'Optional cat', // optional
);
The slug for an article can be found in the Crisp dashboard under Helpdesk → open the article → the URL contains the slug. Both methods throw ArgumentError if required fields are empty.
For every request that you make to getUnreadMessageCount or markMessagesAsRead, you must submit your authentication token (identifier and key), as well as your website_id.
::: tip iOS unread count
On iOS, unread.visitor may not reset after reading chat in the native SDK. Call FlutterCrispChat.markMessagesAsRead() after the visitor closes chat. See docs/unread-count-verification.md.
:::
Sign in or create an account (this account is different from your main Crisp account)
Once logged-in, go to Plugins and click on the New Plugin button
Select the plugin type, in this case Private
Name your plugin a name, eg. "My First Crisp Plugin", and hit Create
On the plugin tab, go to Tokens and scroll down to Development Token to view (and manage) your token identifier/key pair
Obtaining a production token is the next natural step once you are ready to step into production with your plugin or if your usage requires higher quotas.
Before using your development token, you now need to associate your marketplace account to your Crisp workspace. This is done by specifying a Trusted Workspace:
Go to the Settings of your Crisp Marketplace account
Click on Add Trusted Workspace and submit your website_id
Enter the credentials of your main Crisp account (the ones you use to access your main Crisp account) and then submit your 2FA token (if any is enabled)
You're all done! You are now ready to use REST API and start building your plugin
Chat Events
Listen to native Crisp SDK events — useful for updating an unread badge in real time instead of polling getUnreadMessageCount().
Platform support: Android and iOS only. The stream never emits on Web/desktop.
final subscription = FlutterCrispChat.onCrispEvent.listen((event) {
switch (event.type) {
caseCrispEventType.sessionLoaded:
print('Session loaded: ${event.sessionId}');
caseCrispEventType.chatOpened:
print('Chat opened');
caseCrispEventType.chatClosed:
print('Chat closed');
caseCrispEventType.messageSent:
caseCrispEventType.messageReceived:
print('Message from ${event.message?.from}: ${event.message?.text}');
caseCrispEventType.notificationReceived:
print('Notification data: ${event.notificationData}'); // Android-only
}
});
// Later, when no longer needed:await subscription.cancel();
The native event callback is registered on the first .listen() call and unregistered once the last listener cancels, so it's safe to listen and cancel freely.
CrispMessage (carried by messageSent/messageReceived events) is a minimal summary — isMe, from, origin, timestamp, fingerprint, contentType, and text (only populated when contentType is CrispMessageContentType.text). Rich content (carousel targets, picker choices, file/audio metadata) is not mapped in this version.
CrispEventType.notificationReceived is Android-only — the iOS Crisp SDK has no matching callback, so iOS never emits it.
Bot Scenarios
Run a Bot scenario configured in the Bot plugin on your Crisp website — useful for kicking off an automated flow (e.g. onboarding, FAQ triage) from within your app.
Platform support: All platforms — Android, iOS, Web, macOS, Windows, and Linux.
This plugin aims to stay compatible with the latest Crisp SDKs. As of the latest update, it has been tested with:
Crisp Android SDK version: 2.0.24
Crisp iOS SDK version: ~> 2.13.0
Crisp Web Chat SDK: loaded from https://client.crisp.chat/l.js at runtime (Web and desktop)
Minimum for Web/desktop (v2.5.0+): Flutter 3.24.0+, Dart 3.5.0+
While the plugin may work with other versions, using versions close to these is recommended for optimal compatibility. Please refer to the official Crisp SDK documentation for the most current SDK details.