1- const { withGradleProperties } = require ( '@expo/config-plugins' ) ;
1+ const { withGradleProperties, withAndroidManifest } = require ( '@expo/config-plugins' ) ;
22
33function addPurchaseConnectorFlag ( config ) {
44 return withGradleProperties ( config , ( cfg ) => {
@@ -13,11 +13,50 @@ function addPurchaseConnectorFlag(config) {
1313 } ) ;
1414}
1515
16+ // withCustomAndroidManifest.js
17+ function withCustomAndroidManifest ( config ) {
18+ return withAndroidManifest ( config , async ( config ) => {
19+ console . log ( '[AppsFlyerPlugin] Starting Android manifest modifications...' ) ;
20+
21+ const androidManifest = config . modResults ;
22+ const manifest = androidManifest . manifest ;
23+
24+ // Ensure xmlns:tools is present in the <manifest> tag
25+ if ( ! manifest . $ [ 'xmlns:tools' ] ) {
26+ manifest . $ [ 'xmlns:tools' ] = 'http://schemas.android.com/tools' ;
27+ console . log ( '[AppsFlyerPlugin] Added xmlns:tools namespace' ) ;
28+ }
29+
30+ const application = manifest . application [ 0 ] ;
31+
32+ // Add tools:replace attribute for dataExtractionRules and fullBackupContent
33+ const existingReplace = application [ '$' ] [ 'tools:replace' ] ;
34+ if ( existingReplace ) {
35+ const newReplace = existingReplace + ', android:dataExtractionRules, android:fullBackupContent' ;
36+ application [ '$' ] [ 'tools:replace' ] = newReplace ;
37+ } else {
38+ application [ '$' ] [ 'tools:replace' ] = 'android:dataExtractionRules, android:fullBackupContent' ;
39+ }
40+
41+ // Set dataExtractionRules and fullBackupContent as attributes within <application>
42+ application [ '$' ] [ 'android:dataExtractionRules' ] = '@xml/secure_store_data_extraction_rules' ;
43+ application [ '$' ] [ 'android:fullBackupContent' ] = '@xml/secure_store_backup_rules' ;
44+
45+ console . log ( '[AppsFlyerPlugin] Android manifest modifications completed' ) ;
46+
47+ return config ;
48+ } ) ;
49+ }
50+
1651module . exports = function withAppsFlyerAndroid ( config , { shouldUsePurchaseConnector = false } = { } ) {
1752 if ( shouldUsePurchaseConnector ) {
1853 config = addPurchaseConnectorFlag ( config ) ;
1954 } else {
2055 console . log ( '[AppsFlyerPlugin] Purchase Connector disabled, skipping gradle property injection' ) ;
2156 }
57+
58+ // Always apply Android manifest modifications for secure data handling
59+ config = withCustomAndroidManifest ( config ) ;
60+
2261 return config ;
2362} ;
0 commit comments