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