-
-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathapp.plugin.js
More file actions
74 lines (67 loc) · 1.71 KB
/
app.plugin.js
File metadata and controls
74 lines (67 loc) · 1.71 KB
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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const {withAndroidManifest, withInfoPlist} = require('@expo/config-plugins');
const schemes = [
'comgooglemaps',
'citymapper',
'uber',
'lyft',
'transit',
'truckmap',
'waze',
'tomtomgo',
'yandexnavi',
'moovit',
'yandextaxi',
'yandexmaps',
'kakaomap',
'tmap',
'szn-mapy',
'mapsme',
'osmandmaps',
'gett',
'nmap',
'dgis',
'lftgpas',
'petalmaps',
'sygic',
'here-route',
];
const intents = ['geo', 'waze'].map((app) => {
return {
action: {$: {'android:name': 'android.intent.action.VIEW'}},
data: {$: {'android:scheme': app}},
};
});
/**
* @type {import('@expo/config-plugins').ConfigPlugin}
*/
module.exports = function withReactNativeMapLink(config) {
config = withAndroidManifest(config, async (config) => {
let intent = config.modResults.manifest.queries[0].intent ?? [];
intents.forEach((newIntent) => {
const newScheme = newIntent.data.$['android:scheme'];
const existing = intent.some((intentItem) => {
const existingScheme =
intentItem.data?.[0]?.$?.['android:scheme'] ||
intentItem.data?.$?.['android:scheme'];
return existingScheme === newScheme;
});
if (!existing) {
intent.push(newIntent);
}
});
config.modResults.manifest.queries[0].intent = intent;
return config;
});
config = withInfoPlist(config, (config) => {
const existing = config.modResults.LSApplicationQueriesSchemes ?? [];
schemes.forEach((scheme) => {
if (!existing.includes(scheme)) {
existing.push(scheme);
}
});
config.modResults.LSApplicationQueriesSchemes = existing;
return config;
});
return config;
};