DNotifier Dart SDK
DNotifier is a real-time notification & messaging SDK for Dart and Flutter, supporting Android and iOS. It provides WebSocket and HTTP transports, binary streaming, and framed packet communication.
Features
- WebSocket & HTTP transport support
- Secure authentication handshake
- Real-time messaging (send/receive text and binary)
- Binary data transfer (files, images, media)
- AI pipeline: send messages to AI (
sendAI), fetch AI history (fetchAIHistory) - Plan limits from auth (
getPlanLimits) - Automatic packet framing & decoding
- Handles partial packets & large payloads
- Works on Android, iOS, and other Dart/Flutter platforms
Installation
Add to your pubspec.yaml:
dependencies:
dnotifier:
path: . # or git: https://github.com/...
Or publish the package and use:
dependencies:
dnotifier: ^1.0.0
Then run:
dart pub get
# or
flutter pub get
Usage
import 'package:dnotifier/dnotifier.dart';
void main() async {
final client = DNotifier(
appId: 'your-app-id',
secret: 'your-app-secret',
transport: 'ws',
userId: 'user-123',
onConnected: () => print('Connected'),
onMessage: (DNotifierMessage msg) {
print('Message from ${msg.metadata.sender}: ${msg.payload.toJSON()}');
},
onDisconnected: ({code, reason}) => print('Disconnected: $reason'),
);
await client.connect();
// Send a text message
client.send(
senderId: 'user-123',
receiverId: 'user-456',
data: {'text': 'Hello'},
);
// Send binary
client.sendBinary(
senderId: 'user-123',
receiverIds: ['user-456'],
buffer: [0x00, 0x01, 0x02],
);
// Plan limits (after connect)
final limits = client.getPlanLimits();
if (limits != null && limits.aiEnabled) {
// message: object with "text" (string) or "messages" (list of {role, content})
client.sendAI(
senderId: 'user-123',
message: {'text': 'Hello'},
);
// Or with chat history:
// client.sendAI(
// senderId: 'user-123',
// message: {
// 'messages': [
// {'role': 'system', 'content': 'You are a helpful assistant.'},
// {'role': 'user', 'content': 'Generate the plan.'},
// ],
// },
// );
client.fetchAIHistory(senderId: 'user-123');
}
}
API summary
| Method / property | Description |
|---|---|
DNotifier(appId, secret, transport, userId, ...) |
Build the client. transport is 'ws' or 'http'. |
connect() |
Authenticate and connect (WebSocket handshake when using ws). |
getPlanLimits() |
Plan limits from last auth (e.g. aiEnabled, maxAIRequestsPerMonth). Throws if not connected. |
send(senderId, receiverId/receiverIds, data) |
Send a text message (JSON-serializable data). |
sendAI(senderId, message) |
Send to the AI pipeline. message is an object: {text: string} or {messages: [{role, content}, ...]}. |
fetchAIHistory(senderId) |
Fetch AI conversation history for the sender. |
sendBinary(senderId, receiverIds, buffer, type?) |
Send raw bytes. |
sendWithOpenAI(senderId, message, ...) |
Deprecated: use sendAI instead. Forwards to AI pipeline. |
disconnect() |
Close the WebSocket. |
isConnected, aiEnabled |
Connection state and whether AI is enabled for the plan. |
onConnected |
Callback when connection is ready. |
onMessage |
Callback with DNotifierMessage (metadata + Payload). |
onDisconnected |
Callback when connection closes. |
Payload.raw(), .toString(), .toJSON(), .toBase64() |
Read received payload. |
DNotifierPlanLimits |
Plan limits: messagesHardLimit, maxAIRequestsPerMonth, maxAIWordsPerMonth, knowledgeBaseMaxWords, aiEnabled, maxUsers, maxRowsPerUser. |
Links
- Product: dnotifier.com
- Docs: Product docs