@@ -38,18 +38,36 @@ const intents = ['geo', 'waze'].map((app) => {
3838 * @type {import('@expo/config-plugins').ConfigPlugin }
3939 */
4040module . exports = function withReactNativeMapLink ( config ) {
41- // eslint-disable-next-line no-shadow
4241 config = withAndroidManifest ( config , async ( config ) => {
4342 let intent = config . modResults . manifest . queries [ 0 ] . intent ?? [ ] ;
44- // @ts -expect-error unnecessary type gymnastics
45- config . modResults . manifest . queries [ 0 ] . intent = intent . concat ( intents ) ;
43+ intents . forEach ( ( newIntent ) => {
44+ const newScheme = newIntent . data . $ [ 'android:scheme' ] ;
45+ const existing = intent . some ( ( intentItem ) => {
46+ const existingScheme =
47+ intentItem . data ?. [ 0 ] ?. $ ?. [ 'android:scheme' ] ||
48+ intentItem . data ?. $ ?. [ 'android:scheme' ] ;
49+ return existingScheme === newScheme ;
50+ } ) ;
51+ if ( ! existing ) {
52+ intent . push ( newIntent ) ;
53+ }
54+ } ) ;
55+
56+ config . modResults . manifest . queries [ 0 ] . intent = intent ;
4657 return config ;
4758 } ) ;
4859
49- // eslint-disable-next-line no-shadow
50- return withInfoPlist ( config , ( config ) => {
51- config . modResults . LSApplicationQueriesSchemes =
52- config . modResults . LSApplicationQueriesSchemes ?. concat ( schemes ) ?? schemes ;
60+ config = withInfoPlist ( config , ( config ) => {
61+ const existing = config . modResults . LSApplicationQueriesSchemes ?? [ ] ;
62+ schemes . forEach ( ( scheme ) => {
63+ if ( ! existing . includes ( scheme ) ) {
64+ existing . push ( scheme ) ;
65+ }
66+ } ) ;
67+
68+ config . modResults . LSApplicationQueriesSchemes = existing ;
5369 return config ;
5470 } ) ;
71+
72+ return config ;
5573} ;
0 commit comments