1import * as Application from 'expo-application';
2import { Platform } from 'react-native';
3
4const map = {
5  ios: {
6    // bare-expo
7    'dev.expo.Payments': '629683148649-uvkfsi3pckps3lc4mbc2mi7pna8pqej5',
8    // NCL standalone
9    'host.exp.nclexp': '29635966244-1vu5o3e9ucoh12ujlsjpn30kt3dbersv',
10  },
11  android: {
12    // bare-expo
13    'dev.expo.payments': '29635966244-knmlpr1upnv6rs4bumqea7hpit4o7kg2',
14    // NCL standalone
15    'host.exp.nclexp': '29635966244-lbejmv84iurcge3hn7fo6aapu953oivs',
16  },
17};
18const GUIDs = Platform.select<Record<string, string>>(map);
19
20export function getGUID(): string {
21  // This should only happen
22  if (!GUIDs) {
23    throw new Error(
24      `No valid GUID for bare projects on platform: ${
25        Platform.OS
26      }. Supported native platforms are currently: ${Object.keys(map).join(', ')}`
27    );
28  }
29
30  if (!Application.applicationId) {
31    throw new Error('Cannot get GUID with null `Application.applicationId`');
32  }
33  if (!(Application.applicationId in GUIDs)) {
34    throw new Error(
35      `No valid GUID for native app Id: ${Application.applicationId}. Valid GUIDs exist for ${
36        Platform.OS
37      } projects with native Id: ${Object.keys(GUIDs).join(', ')}`
38    );
39  }
40  return GUIDs[Application.applicationId];
41}
42