1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | function getGoogleMapsApiKey(config) {
|
4 | var _a, _b, _c, _d;
|
5 | return _d = (_c = (_b = (_a = config.android) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.googleMaps) === null || _c === void 0 ? void 0 : _c.apiKey, (_d !== null && _d !== void 0 ? _d : null);
|
6 | }
|
7 | exports.getGoogleMapsApiKey = getGoogleMapsApiKey;
|
8 | async function setGoogleMapsApiKey(config, manifestDocument) {
|
9 | const apiKey = getGoogleMapsApiKey(config);
|
10 | if (!apiKey) {
|
11 | return manifestDocument;
|
12 | }
|
13 | let mainApplication = manifestDocument.manifest.application.filter((e) => e['$']['android:name'] === '.MainApplication')[0];
|
14 |
|
15 | let existingMetaDataItem;
|
16 | const metaDataItem = {
|
17 | $: {
|
18 | 'android:name': 'com.google.android.geo.API_KEY',
|
19 | 'android:value': apiKey,
|
20 | },
|
21 | };
|
22 | if ('meta-data' in mainApplication) {
|
23 | existingMetaDataItem = mainApplication['meta-data'].filter((e) => e['$']['android:name'] === 'com.google.android.geo.API_KEY');
|
24 | if (existingMetaDataItem.length) {
|
25 | existingMetaDataItem[0]['$']['android:value'] = apiKey;
|
26 | }
|
27 | else {
|
28 | mainApplication['meta-data'].push(metaDataItem);
|
29 | }
|
30 | }
|
31 | else {
|
32 | mainApplication['meta-data'] = [metaDataItem];
|
33 | }
|
34 |
|
35 | let existingUsesLibraryItem;
|
36 | const newUsesLibraryItem = {
|
37 | $: {
|
38 | 'android:name': 'org.apache.http.legacy',
|
39 | 'android:required': 'false',
|
40 | },
|
41 | };
|
42 | if (mainApplication.hasOwnProperty('uses-library')) {
|
43 | existingUsesLibraryItem = mainApplication['uses-library'].filter((e) => e['$']['android:name'] === 'org.apache.http.legacy');
|
44 | if (existingUsesLibraryItem.length) {
|
45 | existingUsesLibraryItem[0]['$']['android:required'] = 'false';
|
46 | }
|
47 | else {
|
48 | mainApplication['uses-library'].push(newUsesLibraryItem);
|
49 | }
|
50 | }
|
51 | else {
|
52 | mainApplication['uses-library'] = [newUsesLibraryItem];
|
53 | }
|
54 | return manifestDocument;
|
55 | }
|
56 | exports.setGoogleMapsApiKey = setGoogleMapsApiKey;
|
57 |
|
\ | No newline at end of file |