Client SDK · Mobile, web & desktop
Flutter / Dart SDK
Dart 3.4+ or a compatible Flutter SDK. Supports web, mobile and desktop. Android release builds need android.permission.INTERNET.
Install from GitHub
The SDK source is public on the main branch. These instructions use Git or a locally built package; package registry releases are a separate step.
# In pubspec.yaml:
dependencies:
pubb:
git:
url: https://github.com/pubbio/sdk-dart.git
ref: main
# Then run flutter pub get or dart pub get.
Commit pubspec.lock in your application to pin the resolved revision.
Subscribe to events
Use your public app key from the Pubb dashboard. Subscribe before publishing a matching event from your trusted backend.
import 'package:pubb/pubb.dart';
void startRealtime(Pubb pubb) {
pubb.errors.listen((error) => print(error));
pubb.subscribe('notifications').on('message.sent').listen((data) => print(data));
pubb.connect();
}
// Own Pubb(appKey: 'YOUR_PUBLIC_APP_KEY') outside widget build().
// On teardown, cancel listeners and call pubb.dispose().
connect starts asynchronously; observe states or read state and socketId. disconnect retains channels for later reuse, while dispose permanently closes the client. Automatic reconnect attempts are bounded. Refresh durable state after reconnecting.
Private and presence channels
Create HttpChannelAuthorizer with your authenticated backend URL and a callback for current session headers, then pass auth.call as authorizer to Pubb. Close the authorizer when its owner ends. Observe the presence channel's members and pubb:member_added / pubb:member_removed events.
Your backend receives socket_id and channel_name, checks the authenticated user’s access, and returns auth plus channel_data for presence. Derive the presence user ID from the session and forward the signed channel_data unchanged.
Keep the app secret on your trusted server. Public channels must not carry personal or restricted data. Read the channel access reference for the protocol.
Verify your integration
- Subscribe to
notificationsin your app or the dashboard’s Live console. - Publish
message.sentto the same application and channel from your backend. - Check the event payload, connection cleanup and recovery after a disconnect. Test denied access as well as successful private subscriptions.
The repositories include automated tests and examples. Verify end-to-end delivery with your own application before sending production traffic. Refetch durable state after reconnecting; missed events are not replayed.
Legacy pusher:* and pusher_internal:* control names are retained where required by the protocol. Their presence alone does not imply drop-in compatibility with every Pusher client or server.