Flutter SDK Guide (hosteday_flutter)
The official
hosteday_flutterpackage provides a unified integration layer for connecting Flutter apps to your HosteDay App—covering automatic setup, authentication, Realtime WebSockets, and Push Notifications.
1. Installation & Setup via HosteDay CLI
From the HosteDay Flutter CLI Integration page in your App dashboard:
- Clone the official production-ready template (
--clone):
curl -fsSL https://dash.hosteday.com/cli/setup.sh | bash -s -- --project=YOUR_APP_SLUG --token='YOUR_CLI_TOKEN' --clone
- Or inject into an existing Flutter project (
--dir=.):
curl -fsSL https://dash.hosteday.com/cli/setup.sh | bash -s -- --project=YOUR_APP_SLUG --token='YOUR_CLI_TOKEN' --dir=.
The CLI generates lib/hosteday_config.dart and Firebase config files (google-services.json, GoogleService-Info.plist, web/firebase-config.json, web/firebase-messaging-sw.js). You can refresh configuration anytime via:
dart run hosteday_flutter:setup
2. Initialize the SDK in main.dart
await Hosteday.initializeApp(
baseUrl: HostedayConfig.baseUrl,
apiToken: HostedayConfig.apiToken,
);
3. Core SDK Modules
A. Realtime (Hosteday.realtime)
// Public channel
final publicChannel = await Hosteday.realtime.subscribePublic('news.updates');
publicChannel.bind('article.published', (data) => print(data));
// Private channel
final privateChannel = await Hosteday.realtime.subscribePrivate('orders.$userId');
privateChannel.bind('order.updated', (data) => print(data));
// Presence channel
final presenceChannel = await Hosteday.realtime.subscribePresence('chat.room.1');
presenceChannel.listenPresenceMembersList((members) => print(members.length));
B. Push Notifications (Hosteday.notifications)
// Sync device token
await Hosteday.notifications.syncDeviceToken(
deviceToken: fcmToken,
deviceId: deviceId,
deviceType: 'android',
);
// Unlink device on logout
await Hosteday.notifications.unlink(deviceId: deviceId);
Next Step
Review HosteDay's security model, API protection keys, and rate limits:
- Continue to: Security, Access Keys & Rate Limits