rasel_chatting_sdk 0.1.7
rasel_chatting_sdk: ^0.1.7 copied to clipboard
Flutter/Dart client for the Rasel Chatting SDK — REST API, WebSocket chat, groups, media, reactions, search, and push device registration.
rasel_chatting_sdk #
Flutter/Dart client for the Rasel Chatting SDK — a multi-tenant chat-as-a-service platform. Connect your app to the REST API and real-time WebSocket layer for groups, messages, media, reactions, search, and push notifications.
Features #
- REST client: auth, groups, messages, file upload, profile, reactions, search
- Real-time chat via
ChatSocket(Socket.IO) - Message edit/delete with
onMessageUpdatedlistener - Emoji reactions (REST + socket)
- Server-side message search within a conversation
- Push device registration (
registerDevice/unregisterDevice) - English and Arabic i18n (
ChattingI18n)
Install #
Add to your app's pubspec.yaml:
dependencies:
rasel_chatting_sdk: ^0.1.6
flutter pub get
Quick start #
import 'package:flutter/widgets.dart';
import 'package:rasel_chatting_sdk/rasel_chatting_sdk.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await ChattingSdk.initialize(
ChattingSdkConfig(
sdkKey: 'csk_sdk_…', // from your tenant dashboard
apiBaseUrl: 'https://api.your-domain.com',
locale: 'en', // optional — English and Arabic supported
),
);
runApp(const MyApp());
}
// Recommended: your backend mints a chat JWT after the user signs in.
final session = await ChattingSdk.instance.connectWithAccessToken(chatToken);
final groups = await ChattingSdk.instance.listGroups(session.accessToken);
final socket = ChattingSdk.instance.createChatSocket();
socket.connect(token: session.accessToken, userId: session.user.id);
socket.onMessage((message) => print(message.content));
socket.onMessageUpdated((message) => print('updated: ${message.id}'));
await socket.joinGroup(groups.first.id);
SDK key vs chat login #
| Step | Credential | Purpose |
|---|---|---|
ChattingSdk.initialize |
SDK key (csk_sdk_…) |
Binds your app to a tenant workspace |
connectWithAccessToken |
Chat JWT from your backend | Attaches session — no chat password on device |
login (legacy) |
Chat user or employer email + password | Chat users and employer staff accounts |
Push notifications #
- Obtain a device token from your push provider (e.g.
firebase_messaging). - Register it after login:
await ChattingSdk.instance.registerDevice(
session.accessToken,
fcmToken,
platform: 'android', // or ios / web
);
- Toggle delivery with
updateProfile(..., notificationsEnabled: true/false). - Call
unregisterDeviceon logout.
The server delivers pushes when FCM_SERVER_KEY is configured on the API.
Server-side session minting #
Never ship your tenant API key in a mobile client. Mint chat sessions on your backend:
// Server-side only (Dart backend or via your own API):
final session = await ChattingSdk.instance.mintChatSession(
apiKey: tenantApiKey,
externalId: user.id,
email: user.email,
name: user.name,
);
// Return session.accessToken to the mobile app.
More information #
- Changelog
- Source repository
License #
MIT — see LICENSE.