forked from emirhanalptekin/expo-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.config.ts
124 lines (109 loc) · 2.78 KB
/
app.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import {
AndroidManifest,
ConfigPlugin,
withAndroidManifest,
} from '@expo/config-plugins';
import { ExpoConfig } from '@expo/config-types';
import xml2js from 'xml2js';
const queriesXml = `
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="wc"/>
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https"/>
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="wss"/>
</intent>
</queries>`;
type KeyValuePair = {
$: {
[key: string]: string | undefined;
}
};
type Intent = {
action?: KeyValuePair[],
data?: KeyValuePair[]
};
type Queries = {
intent?: Intent[];
};
type ParseResult = {
queries: Queries;
}
type AndroidManifestWithQuery = AndroidManifest & {
manifest: {
$: {
['queries']?: any;
}
}
};
/**
* Does not currently work as expected, need to run `expo prebuild`
* to configure plugins, but this breaks the `Expo Go` app functionality
*
* @param androidManifest A AndroidManifest file that has been updated
* to accept queries as a parameter
* @returns an updated AndroidManifest file
*
* @see https://chafikgharbi.com/expo-android-manifest/
* @see https://docs.expo.dev/workflow/customizing/
* @see https://docs.expo.dev/workflow/configuration/
* @see https://docs.expo.dev/guides/config-plugins/#modifying-the-androidmanifestxml
*/
const addQueryToManifest = (androidManifest: AndroidManifestWithQuery) => {
const { manifest } = androidManifest;
let packageQuery: Queries;
xml2js.parseString(queriesXml, (err, result: ParseResult) => {
packageQuery = result.queries
if (!Array.isArray(manifest.$['queries'])) {
manifest.$['queries'] = [];
}
manifest.$['queries'].push(packageQuery);
});
return androidManifest;
};
const withPackageVisibility: ConfigPlugin = (config) => {
return withAndroidManifest(config, (config) => {
config.modResults = addQueryToManifest(config.modResults);
return config;
});
};
const config: ExpoConfig = {
name: 'test-dapp',
slug: 'test-dapp',
version: "1.0.0",
orientation: "portrait",
icon: "./assets/images/icon.png",
scheme: "myapp",
userInterfaceStyle: "automatic",
splash: {
image: "./assets/images/splash.png",
resizeMode: "contain",
backgroundColor: "#ffffff"
},
updates: {
fallbackToCacheTimeout: 0
},
assetBundlePatterns: [
"**/*"
],
ios: {
"supportsTablet": true
},
android: {
package: "com.clxyder.testdapp",
adaptiveIcon: {
foregroundImage: "./assets/images/adaptive-icon.png",
backgroundColor: "#ffffff"
}
},
web: {
favicon: "./assets/images/favicon.png"
}
};
export default withPackageVisibility(config);