1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | function getBranchApiKey(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.branch) === null || _c === void 0 ? void 0 : _c.apiKey, (_d !== null && _d !== void 0 ? _d : null);
|
6 | }
|
7 | exports.getBranchApiKey = getBranchApiKey;
|
8 | async function setBranchApiKey(config, manifestDocument) {
|
9 | const apiKey = getBranchApiKey(config);
|
10 | if (!apiKey) {
|
11 | return manifestDocument;
|
12 | }
|
13 | let mainApplication = manifestDocument.manifest.application.filter((e) => e['$']['android:name'] === '.MainApplication')[0];
|
14 | let existingBranchApiKeyItem;
|
15 | const newBranchApiKeyItem = {
|
16 | $: {
|
17 | 'android:name': 'io.branch.sdk.BranchKey',
|
18 | 'android:value': apiKey,
|
19 | },
|
20 | };
|
21 | if (mainApplication.hasOwnProperty('meta-data')) {
|
22 | existingBranchApiKeyItem = mainApplication['meta-data'].filter((e) => e['$']['android:name'] === 'io.branch.sdk.BranchKey');
|
23 | if (existingBranchApiKeyItem.length) {
|
24 | existingBranchApiKeyItem[0]['$']['android:value'] = apiKey;
|
25 | }
|
26 | else {
|
27 | mainApplication['meta-data'].push(newBranchApiKeyItem);
|
28 | }
|
29 | }
|
30 | else {
|
31 | mainApplication['meta-data'] = [newBranchApiKeyItem];
|
32 | }
|
33 | return manifestDocument;
|
34 | }
|
35 | exports.setBranchApiKey = setBranchApiKey;
|
36 |
|
\ | No newline at end of file |