1import { CodedError } from 'expo-modules-core'; 2import { v4 as uuidv4 } from 'uuid'; 3const INSTALLATION_ID_KEY = 'EXPO_NOTIFICATIONS_INSTALLATION_ID'; 4const REGISTRATION_INFO_KEY = 'EXPO_NOTIFICATIONS_REGISTRATION_INFO'; 5// Lazy fallback installationId per session initializer 6let getFallbackInstallationId = () => { 7 const sessionInstallationId = uuidv4(); 8 getFallbackInstallationId = () => sessionInstallationId; 9}; 10export default { 11 getInstallationIdAsync: async () => { 12 let installationId; 13 try { 14 installationId = localStorage.getItem(INSTALLATION_ID_KEY); 15 if (!installationId || typeof installationId !== 'string') { 16 installationId = uuidv4(); 17 localStorage.setItem(INSTALLATION_ID_KEY, installationId); 18 } 19 } 20 catch { 21 installationId = getFallbackInstallationId(); 22 } 23 return installationId; 24 }, 25 getRegistrationInfoAsync: async () => { 26 return localStorage.getItem(REGISTRATION_INFO_KEY); 27 }, 28 setRegistrationInfoAsync: async (registrationInfo) => { 29 try { 30 if (registrationInfo) { 31 localStorage.setItem(REGISTRATION_INFO_KEY, registrationInfo); 32 } 33 else { 34 localStorage.removeItem(REGISTRATION_INFO_KEY); 35 } 36 } 37 catch (error) { 38 throw new CodedError('ERR_NOTIFICATIONS_STORAGE_ERROR', `Could not modify localStorage to persist auto-registration information: ${error}`); 39 } 40 }, 41 // mock implementations 42 addListener: () => { }, 43 removeListeners: () => { }, 44}; 45//# sourceMappingURL=ServerRegistrationModule.web.js.map