The Engagespot SDK for Flutter provides functionalities to integrate the Engagespot service into your Flutter applications. With this SDK, you can handle notifications, mark notifications as read, register Firebase Cloud Messaging (FCM) tokens, and listen to real-time notification events.
To use the Engagespot SDK in your Flutter project, follow these steps:
- Add the
engagespot_sdkdependency to yourpubspec.yamlfile:
dependencies:
engagespot_sdk: ^0.0.6- Install the package by running the following command in your terminal:
flutter pub get
Before using any functionalities of the Engagespot SDK, you need to initialize it with your API key and secret. You can do this by calling the initSdk method:
Engagespot.initSdk(
apiKey: 'your_api_key',
isDebug: true, // Set to true for debugging
);To login a user, use the loginUser method:
Engagespot.loginUser(userId: 'user_id');You can mark notification as read using the markNotificationAsRead method:
bool isSuccess = await Engagespot.markNotificationAsRead(notificationID: {{notificationID}});
if (isSuccess) {
print("Notification marked as read successfully.");
} else {
print("Failed to mark notification as read.");
}You can mark notification as read using the markNotificationAsSeen method:
bool isSuccess = await Engagespot.markNotificationAsSeen(notificationID: {{notificationID}});
if (isSuccess) {
print("Notification marked as seen successfully.");
} else {
print("Failed to mark notification as seen.");
}You can mark all notifications as seen using the markAllAsSeen method:
Engagespot.markAllAsSeen();You can delete notification using the deleteNotification method:
Engagespot.deleteNotification(notificationID : "notificationID" );You can delete all notification using the clearAllNotification method:
Engagespot.clearAllNotification();To register FCM tokens with Engagespot, use the registerFCM method:
Engagespot.registerFCM('your_fcm_token');You can listen to real-time notification events using the listenMessage method. Provide callbacks to handle incoming messages and when all notifications are marked as read:
Engagespot.listenMessage(
onMessage: (EsMessage es) {
// Handle incoming message
}
);Retrieve notifications using the getNotifications method. This returns a NotificationSet object containing unread notification count and a list of notifications:
NotificationSet notificationSet = await Engagespot.getNotifications();
int unSeenCount = notificationSet.unSeenCount;
List<EsMessage> notifications = notificationSet.NotificationMessage;- Ensure that you have the necessary permissions and configurations set up on the Engagespot dashboard before using the SDK functionalities.
- Handle errors and edge cases appropriately in your application logic.
- Refer to the Engagespot API documentation for more details on available endpoints and functionalities.
That's it! You've successfully integrated the Engagespot SDK into your Flutter application. Happy coding!# engagespot