All files / apps/host/src/services/notification messages.ts

100% Statements 26/26
75% Branches 6/8
100% Functions 19/19
100% Lines 26/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 787x               2x         1x 1x               1x 1x 1x         2x 2x 2x 2x     1x 1x 1x 1x       1x   2x                 1x   1x 1x   1x     2x     1x             1x   1x   2x    
export const NotificationMessages = {
  // Initialization
  INITIALIZING: 'Initializing notification service...',
  INITIALIZED: 'Notification service initialized successfully',
  ALREADY_INITIALIZED: 'Service already initialized, skipping...',
  TOKEN_REFRESH_LISTENER_ALREADY_SET: 'Token refresh listener already set up, skipping...',
  FOREGROUND_MESSAGE_LISTENER_ALREADY_SET:
    'Foreground message listener already set up, skipping...',
  INIT_ERROR: (error: unknown) => `Error initializing: ${error}`,
 
  // Permissions
  PERMISSION_ALREADY_GRANTED: 'Permission already granted',
  REQUESTING_PERMISSION: 'Requesting notification permission...',
  PERMISSION_CHECK_ERROR: (error: unknown) => `Error checking permission: ${error}`,
  PERMISSION_REQUEST_ERROR: (error: unknown) => `Error requesting permission: ${error}`,
  IOS_PERMISSION_GRANTED: 'iOS permission granted',
  IOS_PERMISSION_DENIED: 'iOS permission denied',
  ANDROID_PERMISSION_GRANTED: 'Android permission granted',
  ANDROID_PERMISSION_DENIED: 'Android permission denied',
 
  // Token
  TOKEN_OBTAINED: 'Token obtained successfully',
  TOKEN_RECEIVED: (token: string) => `Token: ${token}`,
  TOKEN_REFRESHED: (token: string) => `Token refreshed: ${token}`,
  TOKEN_GET_ERROR: (error: unknown) => `Error getting token: ${error}`,
  TOKEN_OBTAINED_AFTER_PERMISSION: 'FCM token obtained immediately after permission grant',
  TOKEN_WILL_BE_OBTAINED_VIA_REFRESH: 'FCM token will be obtained via refresh listener',
  TOKEN_PERMISSION_DENIED: 'Cannot get token: permission not granted',
  TOKEN_REGISTER_ERROR: (error: unknown) => {
    const errorMsg = error instanceof Error ? error.message : String(error);
    const statusMatch = errorMsg.match(/status (\d+)/);
    const status = statusMatch ? statusMatch[1] : 'unknown';
    return `Failed to register notification token (HTTP ${status}): ${errorMsg}`;
  },
  TOKEN_DELETE_ERROR: (error: unknown) => {
    const errorMsg = error instanceof Error ? error.message : String(error);
    const statusMatch = errorMsg.match(/status (\d+)/);
    const status = statusMatch ? statusMatch[1] : 'unknown';
    return `Failed to delete notification token (HTTP ${status}): ${errorMsg}`;
  },
 
  // Notifications
  NOTIFICATION_DISPLAYING: (title: string) => `Displaying: ${title}`,
  NOTIFICATION_DISPLAYED: 'Notification displayed successfully',
  NOTIFICATION_DISPLAY_ERROR: (error: unknown) => `Error displaying notification: ${error}`,
  NOTIFICATION_INVALID_DATA: 'Invalid notification data',
  NOTIFICATION_PRESSED: 'Notification pressed',
  FOREGROUND_MESSAGE_RECEIVED: 'Foreground message received',
  REMOTE_MESSAGE_DATA_STORED: 'Remote message data stored for pending processing',
  INITIAL_NOTIFICATION_DATA_STORED: 'Initial notification data stored',
  NOTIFICATION_DATA_STORED: 'Notification data stored for pending processing',
 
  // Topics
  TOPIC_SUBSCRIBED: (topic: string) => `Subscribed to topic: ${topic}`,
  TOPIC_SUBSCRIBE_ERROR: (topic: string, error: unknown) =>
    `Error subscribing to topic ${topic}: ${error}`,
  TOPIC_UNSUBSCRIBED: (topic: string) => `Unsubscribed from topic: ${topic}`,
  TOPIC_UNSUBSCRIBE_ERROR: (topic: string, error: unknown) =>
    `Error unsubscribing from topic ${topic}: ${error}`,
 
  // Initial Notification
  INITIAL_NOTIFICATION_ERROR: (error: unknown) => `Error getting initial notification: ${error}`,
 
  // Settings
  SETTINGS_OPEN_ERROR: (error: unknown) => `Error opening settings: ${error}`,
 
  // Setup After Login
  SETUP_AFTER_LOGIN_START: 'Setting up notification system after login',
  SETUP_AFTER_LOGIN_REQUESTING_PERMISSION: 'Requesting notification permission',
  SETUP_AFTER_LOGIN_PERMISSION_DENIED: 'Notification permission denied by user',
  SETUP_AFTER_LOGIN_SUCCESS: (tokenLength: number) =>
    `Notification setup completed successfully (token length: ${tokenLength})`,
  SETUP_AFTER_LOGIN_TOKEN_FAILED: (status: string) =>
    `Failed to get FCM token after permission granted (status: ${status})`,
  SETUP_AFTER_LOGIN_ERROR: (error: unknown) =>
    `Error setting up notification after login: ${error}`,
} as const;