Skip to content

Commit 5b6808b

Browse files
committed
Expo Android Manifest modification
1 parent 2001524 commit 5b6808b

3 files changed

Lines changed: 42 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
- Android AppsFlyer SDK **v6.17.3**
1616
- iOS AppsFlyer SDK **v6.17.3**
17-
- Tested with React-Native **v0.62.0** (older versions might be supported)
17+
- Minimum tested with React-Native **v0.62.0** (older versions might be supported)
1818

1919
## <a id="release-updates"> Release Updates
2020

android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerModule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,8 +850,7 @@ private void sendValidationResult(Map<String, ?> data) {
850850
}
851851

852852
private void sendValidationError(String errorMessage) {
853-
Map<String, Object> error = new HashMap<>();
854-
error.put("error", errorMessage);
853+
Map<String, Object> error = Collections.singletonMap("error", errorMessage);
855854
sendValidationResult(error);
856855
}
857856

expo/withAppsFlyerAndroid.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { withGradleProperties } = require('@expo/config-plugins');
1+
const { withGradleProperties, withAndroidManifest } = require('@expo/config-plugins');
22

33
function 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+
1651
module.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

Comments
 (0)