Class NotificationController
java.lang.Object
com.example.iconic_raffleevent.controller.NotificationController
Controller class responsible for managing notifications for users.
Provides methods to retrieve notifications and mark them as read.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Callback interface for retrieving notifications for a user.static interface
Callback interface for marking a notification as read.static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptioncom.google.firebase.firestore.FirebaseFirestore
com.google.firebase.firestore.CollectionReference
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new NotificationController and initializes the Firebase Firestore instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
getNotifications
(String userId, NotificationController.GetNotificationsCallback callback) Retrieves the notifications for a specified user.void
markNotificationAsRead
(String notificationId, NotificationController.MarkNotificationAsReadCallback callback) Marks a notification as read by updating its "read" status in Firestore.void
sendNotification
(Notification notification, NotificationController.SendNotificationCallback callback) Uploads a new notification to the Notification collection in firebase
-
Field Details
-
db
public com.google.firebase.firestore.FirebaseFirestore db -
notificationsCollection
public com.google.firebase.firestore.CollectionReference notificationsCollection -
firebaseAttendee
-
-
Constructor Details
-
NotificationController
public NotificationController()Constructs a new NotificationController and initializes the Firebase Firestore instance. Also sets up the reference to the "Notification" collection in Firestore.
-
-
Method Details
-
sendNotification
public void sendNotification(Notification notification, NotificationController.SendNotificationCallback callback) Uploads a new notification to the Notification collection in firebase- Parameters:
notification
- Notification to be uploadedcallback
- The callback interface to handle the uploaded notifications or error
-
getNotifications
public void getNotifications(String userId, NotificationController.GetNotificationsCallback callback) Retrieves the notifications for a specified user.- Parameters:
userId
- The ID of the user for whom to fetch the notifications.callback
- The callback interface to handle the fetched notifications or error.
-
markNotificationAsRead
public void markNotificationAsRead(String notificationId, NotificationController.MarkNotificationAsReadCallback callback) Marks a notification as read by updating its "read" status in Firestore.- Parameters:
notificationId
- The ID of the notification to mark as read.callback
- The callback interface to handle the success or failure of the operation.
-