using FirebaseAdmin.Messaging; using eprintServer.Entities; namespace eprintServer.Services; public class FirebaseNotificationService { public async Task SendNotificationAsync(NotificationModel notification, string deviceToken) { // 1. Map your model data to the Firebase Message var message = new Message() { Token = deviceToken, // The unique ID of the user's phone/browser Notification = new Notification() { Title = notification.Subject, Body = notification.Content }, Data = notification.ToMap() }; try { // 2. Send the message string response = await FirebaseMessaging.DefaultInstance.SendAsync(message); return response; // Returns the message ID } catch (Exception ex) { // Handle errors (e.g., invalid token) return $"Error: {ex.Message}"; } } }