1import * as Application from 'expo-application'; 2import Constants from 'expo-constants'; 3import { Platform } from 'react-native'; 4 5const bareMap = { 6 ios: { 7 // bare-expo 8 'dev.expo.Payments': '629683148649-uvkfsi3pckps3lc4mbc2mi7pna8pqej5', 9 // NCL standalone 10 'host.exp.nclexp': '29635966244-1vu5o3e9ucoh12ujlsjpn30kt3dbersv', 11 }, 12 android: { 13 // bare-expo 14 'dev.expo.payments': '29635966244-knmlpr1upnv6rs4bumqea7hpit4o7kg2', 15 // NCL standalone 16 'host.exp.nclexp': '29635966244-lbejmv84iurcge3hn7fo6aapu953oivs', 17 }, 18}; 19const BARE_GUIDs = Platform.select<Record<string, string>>(bareMap); 20 21const managedMap = { 22 ios: '29635966244-td9jmh1m5trn8uuqa0je1mansia76cln', 23 android: '29635966244-knmlpr1upnv6rs4bumqea7hpit4o7kg2', 24}; 25const GUID = Platform.select<string>(managedMap); 26 27export function getGUID(): string { 28 if (['storeClient', 'standalone'].includes(Constants.executionEnvironment)) { 29 if (!GUID) 30 throw new Error( 31 `No valid GUID for Expo Go on platform: ${ 32 Platform.OS 33 }. Supported native platforms are currently: ${Object.keys(managedMap).join(', ')}` 34 ); 35 return GUID; 36 } else if (Constants.executionEnvironment === 'bare') { 37 if (!BARE_GUIDs) { 38 throw new Error( 39 `No valid GUID for bare projects on platform: ${ 40 Platform.OS 41 }. Supported native platforms are currently: ${Object.keys(bareMap).join(', ')}` 42 ); 43 } 44 45 if (!Application.applicationId) { 46 throw new Error('Cannot get GUID with null `Application.applicationId`'); 47 } 48 if (!(Application.applicationId in BARE_GUIDs)) { 49 throw new Error( 50 `No valid GUID for native app Id: ${Application.applicationId}. Valid GUIDs exist for ${ 51 Platform.OS 52 } projects with native Id: ${Object.keys(BARE_GUIDs).join(', ')}` 53 ); 54 } 55 return BARE_GUIDs[Application.applicationId]; 56 } else { 57 throw new Error( 58 `No GUID available for executionEnvironment: ${Constants.executionEnvironment}` 59 ); 60 } 61} 62