Flutter SDK API Reference for Event Tracking, Notifications, and User Lifecycle
User Management, Account Configuration, and Event Tracking
SignUp
This API can be used to register a user to the platform and report when a user registers.
static Future<bool> signUp({
required HydraUserDetails userDetails,
Map<String, dynamic>? customData,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
userDetails | HydraUserDetails | required | Read more about this class here |
customData | Map<String, dynamic>? | optional | Custom attributes for analytics |
Returns: Future<bool>
indicating if sign up was successfully requested
Usage:
bool signUpResult = await HydraCore.signUp(
userDetails: userDetails,
);
Sign In
This API can be used to sign in a user to the platform and report when a user signs in.
static Future<bool> signIn({
required HydraUserDetails userDetails,
Map<String, dynamic>? customData,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
userDetails | HydraUserDetails | required | Read more about this class here |
customData | Map<String, dynamic>? | optional | Custom attributes for analytics |
Returns: Future<bool>
indicating if sign in was successfully requested
Usage:
bool signInResult = await HydraCore.signIn(
userDetails: userDetails,
);
Sign Out
This API can be used to sign out a user and report when a user has signed out.
static Future<bool> signOut({
required String customerId,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
customerId | String | required | User's customer ID |
Returns: Future<bool>
indicating if sign out was successful
Usage:
bool signOutResult = await HydraCore.signOut(
customerId: "8888888888",
);
Update User
This API can be used to update a user's profile and report when a user has updated their profile.
static Future<bool> updateUser({
required HydraUserDetails userDetails,
Map<String, dynamic>? customData,
List<Map<String, dynamic>>? subscriptions,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
userDetails | HydraUserDetails | required | Read more about this class here |
customData | Map<String, dynamic>? | optional | Custom attributes for analytics |
subscriptions | List<Map<String, dynamic>>? | optional | List of Subscriptions with channel, accountId, priority, type and sourcename |
Returns: Future<bool>
indicating if update was successfully requested
Usage:
bool updateUserResult = await HydraCore.updateUser(
userDetails: updatedUserDetails,
customData: {"Key" : "Value"},
subscriptions: [
{"channel": "channel1", "type": "topic1", "priority": 1},
],
);
Update Geo Config
This API can be used to update a user's geo config and report when a user has updated their geo config.
static Future<bool> updateGeoConfig({
required HydraGeoConfig config,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
config | HydraGeoConfig | required | Read more about this class here |
Returns: Future<bool>
indicating if geo config update was successful
Usage:
bool updateGeoConfigResult = await HydraCore.updateGeoConfig(
config: config,
);
Update User Push Preferences
This API can be used to update a user's push preference and report when a user has updated their push preference.
static Future<bool> updatePushPreferences({
required String customerId,
required HydraPushPreferences preferences,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
customerId | String | required | User's customer ID |
preferences | HydraPushPreferences | required | Read more about this class here |
Returns: Future<bool>
indicating if preferences update was successful
Usage:
bool result = await HydraCore.updatePushPreferences(
preferences: pushPreferences,
customerId: "8888888888",
);
Report custom user events
This API can be used to report custom user events.
static Future<bool> reportUserEvent({
required String eventName,
Map<String, dynamic>? attributes,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
eventName | String | required | Name of the event |
attributes | Map<String, dynamic>? | optional | Additional event data |
Returns: Future<bool>
indicating if event reporting was successful
Usage:
bool sendEventResult = await HydraCore.reportUserEvent(
eventName: "TestEvent",
attributes: {"Key" : "Value"},
);
Managing Push Notifications
Get FCM Token
This API can be used to get the FCM token and report when the token is retrieved.
static Future<String> getFCMToken();
Returns: Future<String>
containing FCM token (throws error if unavailable)
Usage:
String fcmToken = await HydraPushNotification.getFCMToken();
Request Permission for Push notifications
This API can be used to request permission for push notifications from the user and report when the push permission has been granted.
static Future<bool> requestPermission();
Returns: Future<bool>
indicating if permission was granted
Usage:
bool granted = await HydraPushNotification.requestPermission();
Managing the Notification Inbox
Get list of Hydra Notifications
This API can be used to get the list of notifications.
static Future<List<HydraNotification>> getInboxMessages();
Returns: Future<List<HydraNotification>>
Usage:
List<HydraNotification> notifications = await HydraInbox.getInboxMessages();
Get Unread Hydra Notifications Count
This API can be used to get the number of unread notifications.
static Future<int> getUnreadInboxMessagesCount();
Returns: Future<int>
with unread count
Usage:
int unreadNotificationCount = await HydraInbox.getUnreadInboxMessagesCount();
Mark a Hydra Notification as read
This API can be used to mark a notification as read and report when a notification has been marked as read.
static Future<bool> markInboxMessageAsRead({
required HydraNotification notification,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
notification | HydraNotification | required | Notification to mark as read. The list of Hydra Notifications are obtained from here. |
Returns: Future<bool>
indicating success
Usage:
bool marked = await HydraInbox.markInboxMessageAsRead(notification: notification);
Delete a Hydra Notification
This API can be used to delete a notification and report when a notification has been deleted.
static Future<bool> deleteInboxMessage({
required HydraNotification notification,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
notification | HydraNotification | required | Notification to delete. The list of Hydra Notifications are obtained from here. |
Returns: Future<bool>
indicating success
Usage:
bool deleted = await HydraInbox.deleteInboxMessage(notification: notification);
Delete all Hydra Notifications
This API can be used to delete all notifications and report when all notifications have been deleted.
static Future<bool> deleteAllInboxMessages();
Returns: Future<bool>
indicating success
Usage:
bool deleted = await HydraInbox.deleteAllInboxMessages();
HydraInboxUI class APIs
Show In-Built Notification Center
This API can be used to show the built-in notification center.
static Future<void> showNotificationCenter();
Usage:
HydraInboxUI.showNotificationCenter();
Hide In-Built Notification Center if Showing
This API can be used to hide the built-in notification center.
static Future<void> hideNotificationCenterIfShowing();
Usage:
await HydraInboxUI.hideNotificationCenterIfShowing();
HydraNativeEvent class APIs
Add event handler
This API can be used to add and report when an event handler is added.
static void addEventHandler(HydraNativeEventHandler handler);
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
handler | HydraNativeEventHandler | required | Handler instance |
Usage:
HydraNativeEvents.addEventHandler(handler);
Remove event handler
This API can be used to add and report when an event handler is removed.
static void removeEventHandler(HydraNativeEventHandler handler);
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
handler | HydraNativeEventHandler | required | Handler instance |
Usage:
HydraNativeEvents.removeEventHandler(handler);
Remove all event handlers
This API can be used to add and report when all event handlers are removed.
static void removeAllEventHandlers();
Usage:
HydraNativeEvents.removeAllEventHandlers();
SDK Event Tracking
This class stores the details of the event handler.
class HydraNativeEventHandler {
void onTokenAvailable({required String token}) {}
void onHydraNotificationReceived({required HydraNotification notification}) {}
void onHydraNotificationClicked({HydraNotificationCTA? cta, HydraNotification? notification}) {}
void onHydraNotificationDismissed({required HydraNotification notification}) {}
void onHydraNotificationShown({required HydraNotification notification}) {}
void onNotificationCenterDismissed() {}
void onHydraSdkInitializationResult({required bool success, String? error}) {}
}
Callback Descriptions
- onTokenAvailable: New FCM token available
- onHydraNotificationReceived: Notification received
- onHydraNotificationClicked: Notification/CTA clicked
- onHydraNotificationDismissed: Notification dismissed
- onHydraNotificationShown: Notification shown
- onNotificationCenterDismissed: Notification center closed
- onHydraSDKInitializationResult: SDK initialization result
Managing User Data Structures
HydraUserDetails
This class stores the details of a user.
HydraUserDetails({
required this.customerId,
this.email,
this.phoneNumber,
this.firstName,
this.lastName,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
customerId | String | required | User identifier |
firstName | String? | optional | User's first name |
lastName | String? | optional | User's last name |
String? | optional | User's email | |
phoneNumber | String? | optional | User's phone number |
Usage:
HydraUserDetails userDetails = HydraUserDetails(
customerId: '8888888888',
firstName: 'FirstName',
lastName: 'LastName',
email: '[email protected]',
phoneNumber: '918888888888',
);
HydraGeoConfig
This class stores the geo config details of a user.
HydraGeoConfig({
required this.city,
required this.country,
required this.countryCode,
this.timezone,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
city | String | required | User's city |
country | String | required | User's country |
countryCode | String | required | Country code |
timezone | String? | optional | Timezone |
Usage:
HydraGeoConfig geoConfig = HydraGeoConfig(
city: "Bangalore",
country: "India",
countryCode: "IN",
timezone: "Asia/Kolkata",
);
HydraPushPreferences
This class stores the push preference details of a user.
HydraPushPreferences({
required this.promPushEnabled,
required this.transPushEnabled,
});
Parameters
Parameter | Type | Required/Optional | Description |
---|---|---|---|
promPushEnabled | bool | required | Promotional pushes |
transPushEnabled | bool | required | Transactional pushes |
Usage:
HydraPushPreferences pushPreferences = HydraPushPreferences(
promPushEnabled: false,
transPushEnabled: true,
);
Managing Notification Data Structures
HydraNotification Structure
This class stores the structure for a notification.
class HydraNotification {
final String? cuid;
final String? scope;
final String? campaignId;
final String? variationId;
// ... (other properties)
final HydraNotificationGateway? gateway;
final HydraNotificationBody? body;
final HydraNotificationExpandedDetails? expandableDetails;
// ... (other properties)
}
HydraNotificationBody
This class stores the body for a notification.
class HydraNotificationBody {
final String? title;
final String? message;
final String? image;
final HydraNotificationCTA? cta;
}
HydraNotificationCTA
This class stores the call to action (CTA) for a notification.
class HydraNotificationCTA {
final HydraNotificationCTAType? type;
final String? action;
final String? actionText;
}
HydraNotificationCTAType Enum
This class stores the call to action (CTA) type enums for a notification.
enum HydraNotificationCTAType {
external,
deepLink,
rating,
feedback,
appRating,
unknown,
}
HydraNotificationExpandedDetails
This class stores the expanded details for a notification.
class HydraNotificationExpandedDetails {
final List<HydraNotificationCTA>? ctas;
final String? message;
final String? image;
final String? style;
}
HydraNotificationGateway Enum
This class stores the gateway details for a notification.
enum HydraNotificationGateway {
fcm,
xiaomi,
unknown,
}
Updated 1 day ago