customerio-expo-plugin 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +64 -59
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/commonjs/android/withAppGoogleServices.js +10 -7
- package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +18 -21
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/commonjs/android/withLocationGradleProperties.js +16 -12
- package/plugin/lib/commonjs/android/withLocationGradleProperties.js.map +1 -1
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js +19 -12
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +2 -1
- package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
- package/plugin/lib/commonjs/android/withProjectBuildGradle.js +29 -25
- package/plugin/lib/commonjs/android/withProjectBuildGradle.js.map +1 -1
- package/plugin/lib/commonjs/android/withProjectGoogleServices.js +9 -5
- package/plugin/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +63 -31
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +47 -33
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js +26 -42
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +46 -30
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +192 -122
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/android/withAndroidManifestUpdates.js +61 -58
- package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/module/android/withAppGoogleServices.js +9 -7
- package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
- package/plugin/lib/module/android/withGoogleServicesJSON.js +17 -21
- package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/module/android/withLocationGradleProperties.js +15 -12
- package/plugin/lib/module/android/withLocationGradleProperties.js.map +1 -1
- package/plugin/lib/module/android/withMainApplicationModifications.js +18 -12
- package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
- package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
- package/plugin/lib/module/android/withProjectBuildGradle.js +28 -25
- package/plugin/lib/module/android/withProjectBuildGradle.js.map +1 -1
- package/plugin/lib/module/android/withProjectGoogleServices.js +8 -5
- package/plugin/lib/module/android/withProjectGoogleServices.js.map +1 -1
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +61 -31
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/ios/withAppDelegateModifications.js +45 -33
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIosSwift.js +24 -42
- package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +45 -30
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +187 -122
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/typescript/android/withAndroidManifestUpdates.d.ts +2 -0
- package/plugin/lib/typescript/android/withAppGoogleServices.d.ts +1 -0
- package/plugin/lib/typescript/android/withGoogleServicesJSON.d.ts +1 -0
- package/plugin/lib/typescript/android/withLocationGradleProperties.d.ts +2 -0
- package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +6 -0
- package/plugin/lib/typescript/android/withNotificationChannelMetadata.d.ts +5 -0
- package/plugin/lib/typescript/android/withProjectBuildGradle.d.ts +9 -0
- package/plugin/lib/typescript/android/withProjectGoogleServices.d.ts +1 -0
- package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +14 -0
- package/plugin/lib/typescript/ios/withAppDelegateModifications.d.ts +13 -0
- package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +11 -0
- package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +14 -1
- package/plugin/lib/typescript/ios/withNotificationsXcodeProject.d.ts +53 -2
- package/plugin/src/android/withAndroidManifestUpdates.ts +83 -73
- package/plugin/src/android/withAppGoogleServices.ts +13 -11
- package/plugin/src/android/withGoogleServicesJSON.ts +30 -28
- package/plugin/src/android/withLocationGradleProperties.ts +23 -17
- package/plugin/src/android/withMainApplicationModifications.ts +25 -15
- package/plugin/src/android/withNotificationChannelMetadata.ts +1 -1
- package/plugin/src/android/withProjectBuildGradle.ts +37 -27
- package/plugin/src/android/withProjectGoogleServices.ts +14 -9
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +83 -48
- package/plugin/src/ios/withAppDelegateModifications.ts +61 -48
- package/plugin/src/ios/withCIOIosSwift.ts +33 -50
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +66 -48
- package/plugin/src/ios/withNotificationsXcodeProject.ts +257 -207
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "customerio-expo-plugin",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Expo config plugin for the Customer IO React Native SDK",
|
|
5
5
|
"main": "plugin/lib/commonjs/index",
|
|
6
6
|
"module": "plugin/lib/module/index",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"prepare": "npm run clean && bob build",
|
|
29
29
|
"postinstall": "node plugin/src/postInstall.js",
|
|
30
30
|
"test": "jest",
|
|
31
|
+
"test:scenarios": "jest --selectProjects scenarios",
|
|
31
32
|
"compatibility:create-test-app": "node scripts/compatibility/create-test-app.js",
|
|
32
33
|
"compatibility:setup-test-app": "node scripts/compatibility/setup-test-app.js",
|
|
33
34
|
"compatibility:configure-plugin": "node scripts/compatibility/configure-plugin.js",
|
|
@@ -3,75 +3,80 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.DEFAULT_LOW_PRIORITY = void 0;
|
|
7
|
+
exports.modifyAndroidManifestApplication = modifyAndroidManifestApplication;
|
|
8
|
+
exports.withAndroidManifestUpdates = void 0;
|
|
7
9
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
10
|
var _logger = require("../utils/logger");
|
|
9
11
|
// Default low priority for Firebase messaging service when setHighPriorityPushHandler is false
|
|
10
12
|
const DEFAULT_LOW_PRIORITY = exports.DEFAULT_LOW_PRIORITY = -10;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
function modifyAndroidManifestApplication(application, options) {
|
|
14
|
+
const customerIOMessagingpush = 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
|
|
15
|
+
if (!application[0].service) {
|
|
16
|
+
application[0].service = [];
|
|
17
|
+
}
|
|
18
|
+
const existingServiceIndex = application[0].service.findIndex(service => service.$['android:name'] === customerIOMessagingpush);
|
|
19
|
+
if (existingServiceIndex === -1) {
|
|
20
|
+
// Intent filter structure for Firebase messaging service
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
const intentFilter = {
|
|
23
|
+
action: [{
|
|
24
|
+
$: {
|
|
25
|
+
'android:name': 'com.google.firebase.MESSAGING_EVENT'
|
|
26
|
+
}
|
|
27
|
+
}]
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// Handle priority based on setHighPriorityPushHandler value
|
|
31
|
+
if (options.setHighPriorityPushHandler === true) {
|
|
32
|
+
// High priority - no priority attribute means default high priority
|
|
33
|
+
_logger.logger.info('Successfully set CustomerIO push handler as high priority in AndroidManifest.xml');
|
|
34
|
+
} else if (options.setHighPriorityPushHandler === false) {
|
|
35
|
+
// Low priority - set fixed priority
|
|
36
|
+
intentFilter.$ = {
|
|
37
|
+
'android:priority': DEFAULT_LOW_PRIORITY.toString()
|
|
38
|
+
};
|
|
39
|
+
_logger.logger.info(`Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
|
|
17
40
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
41
|
+
application[0].service.push({
|
|
42
|
+
'$': {
|
|
43
|
+
'android:name': customerIOMessagingpush,
|
|
44
|
+
'android:exported': 'false'
|
|
45
|
+
},
|
|
46
|
+
'intent-filter': [intentFilter]
|
|
47
|
+
});
|
|
48
|
+
} else if (options.setHighPriorityPushHandler === true) {
|
|
49
|
+
// Service exists, need to ensure it becomes high priority (remove priority attribute)
|
|
50
|
+
const existingService = application[0].service[existingServiceIndex];
|
|
51
|
+
if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
|
|
21
52
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
const intentFilter =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
}]
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// Handle priority based on setHighPriorityPushHandler value
|
|
31
|
-
if (options.setHighPriorityPushHandler === true) {
|
|
32
|
-
// High priority - no priority attribute means default high priority
|
|
33
|
-
_logger.logger.info('Successfully set CustomerIO push handler as high priority in AndroidManifest.xml');
|
|
34
|
-
} else if (options.setHighPriorityPushHandler === false) {
|
|
35
|
-
// Low priority - set fixed priority
|
|
36
|
-
intentFilter.$ = {
|
|
37
|
-
'android:priority': DEFAULT_LOW_PRIORITY.toString()
|
|
38
|
-
};
|
|
39
|
-
_logger.logger.info(`Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
|
|
53
|
+
const intentFilter = existingService['intent-filter'][0];
|
|
54
|
+
if (intentFilter.$ && intentFilter.$['android:priority']) {
|
|
55
|
+
delete intentFilter.$['android:priority'];
|
|
56
|
+
_logger.logger.info('Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml');
|
|
40
57
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
'intent-filter': [intentFilter]
|
|
47
|
-
});
|
|
48
|
-
} else if (options.setHighPriorityPushHandler === true) {
|
|
49
|
-
// Service exists, need to ensure it becomes high priority (remove priority attribute)
|
|
50
|
-
const existingService = application[0].service[existingServiceIndex];
|
|
51
|
-
if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
-
const intentFilter = existingService['intent-filter'][0];
|
|
54
|
-
if (intentFilter.$ && intentFilter.$['android:priority']) {
|
|
55
|
-
delete intentFilter.$['android:priority'];
|
|
56
|
-
_logger.logger.info('Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
} else if (options.setHighPriorityPushHandler === false) {
|
|
60
|
-
// Service exists, update to low priority
|
|
61
|
-
const existingService = application[0].service[existingServiceIndex];
|
|
58
|
+
}
|
|
59
|
+
} else if (options.setHighPriorityPushHandler === false) {
|
|
60
|
+
// Service exists, update to low priority
|
|
61
|
+
const existingService = application[0].service[existingServiceIndex];
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();
|
|
71
|
-
_logger.logger.info(`Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
|
|
63
|
+
// Update existing service intent-filter with fixed priority
|
|
64
|
+
if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
+
const intentFilter = existingService['intent-filter'][0];
|
|
67
|
+
if (!intentFilter.$) {
|
|
68
|
+
intentFilter.$ = {};
|
|
72
69
|
}
|
|
70
|
+
intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();
|
|
71
|
+
_logger.logger.info(`Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
|
|
73
72
|
}
|
|
74
|
-
|
|
73
|
+
}
|
|
74
|
+
return application;
|
|
75
|
+
}
|
|
76
|
+
const withAndroidManifestUpdates = (configOuter, options) => {
|
|
77
|
+
return (0, _configPlugins.withAndroidManifest)(configOuter, props => {
|
|
78
|
+
const application = props.modResults.manifest.application;
|
|
79
|
+
props.modResults.manifest.application = modifyAndroidManifestApplication(application, options);
|
|
75
80
|
return props;
|
|
76
81
|
});
|
|
77
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_logger","DEFAULT_LOW_PRIORITY","exports","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_logger","DEFAULT_LOW_PRIORITY","exports","modifyAndroidManifestApplication","application","options","customerIOMessagingpush","service","existingServiceIndex","findIndex","$","intentFilter","action","setHighPriorityPushHandler","logger","info","toString","push","existingService","length","withAndroidManifestUpdates","configOuter","withAndroidManifest","props","modResults","manifest"],"sources":["withAndroidManifestUpdates.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\n// Default low priority for Firebase messaging service when setHighPriorityPushHandler is false\nexport const DEFAULT_LOW_PRIORITY = -10;\n\n\nexport function modifyAndroidManifestApplication(\n application: ManifestApplication[],\n options: CustomerIOPluginOptionsAndroid\n): ManifestApplication[] {\n const customerIOMessagingpush =\n 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';\n\n if (!application[0].service) {\n application[0].service = [];\n }\n\n const existingServiceIndex = application[0].service.findIndex(\n (service) => service.$['android:name'] === customerIOMessagingpush\n );\n\n if (existingServiceIndex === -1) {\n // Intent filter structure for Firebase messaging service\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter: any = {\n action: [\n {\n $: {\n 'android:name': 'com.google.firebase.MESSAGING_EVENT',\n },\n },\n ],\n };\n\n // Handle priority based on setHighPriorityPushHandler value\n if (options.setHighPriorityPushHandler === true) {\n // High priority - no priority attribute means default high priority\n logger.info(\n 'Successfully set CustomerIO push handler as high priority in AndroidManifest.xml'\n );\n } else if (options.setHighPriorityPushHandler === false) {\n // Low priority - set fixed priority\n intentFilter.$ = {\n 'android:priority': DEFAULT_LOW_PRIORITY.toString(),\n };\n logger.info(\n `Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n\n application[0].service.push({\n '$': {\n 'android:name': customerIOMessagingpush,\n 'android:exported': 'false',\n },\n 'intent-filter': [intentFilter],\n });\n } else if (options.setHighPriorityPushHandler === true) {\n // Service exists, need to ensure it becomes high priority (remove priority attribute)\n const existingService = application[0].service[existingServiceIndex];\n\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (intentFilter.$ && intentFilter.$['android:priority']) {\n delete intentFilter.$['android:priority'];\n logger.info(\n 'Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml'\n );\n }\n }\n } else if (options.setHighPriorityPushHandler === false) {\n // Service exists, update to low priority\n const existingService = application[0].service[existingServiceIndex];\n\n // Update existing service intent-filter with fixed priority\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (!intentFilter.$) {\n intentFilter.$ = {};\n }\n intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();\n logger.info(\n `Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n }\n\n return application;\n}\n\nexport const withAndroidManifestUpdates: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, options) => {\n return withAndroidManifest(configOuter, (props) => {\n const application = props.modResults.manifest\n .application as ManifestApplication[];\n props.modResults.manifest.application = modifyAndroidManifestApplication(\n application,\n options\n );\n return props;\n });\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAIA,IAAAC,OAAA,GAAAD,OAAA;AAEA;AACO,MAAME,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,CAAC,EAAE;AAGhC,SAASE,gCAAgCA,CAC9CC,WAAkC,EAClCC,OAAuC,EAChB;EACvB,MAAMC,uBAAuB,GAC3B,8DAA8D;EAEhE,IAAI,CAACF,WAAW,CAAC,CAAC,CAAC,CAACG,OAAO,EAAE;IAC3BH,WAAW,CAAC,CAAC,CAAC,CAACG,OAAO,GAAG,EAAE;EAC7B;EAEA,MAAMC,oBAAoB,GAAGJ,WAAW,CAAC,CAAC,CAAC,CAACG,OAAO,CAACE,SAAS,CAC1DF,OAAO,IAAKA,OAAO,CAACG,CAAC,CAAC,cAAc,CAAC,KAAKJ,uBAC7C,CAAC;EAED,IAAIE,oBAAoB,KAAK,CAAC,CAAC,EAAE;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MAAMK,eAAe,GAAGd,WAAW,CAAC,CAAC,CAAC,CAACG,OAAO,CAACC,oBAAoB,CAAC;;IAEpE;IACA,IAAIU,eAAe,CAAC,eAAe,CAAC,IAAIA,eAAe,CAAC,eAAe,CAAC,CAACC,MAAM,GAAG,CAAC,EAAE;MACnF;MACA,MAAMR,YAAY,GAAGO,eAAe,CAAC,eAAe,CAAC,CAAC,CAAC,CAAQ;MAC/D,IAAI,CAACP,YAAY,CAACD,CAAC,EAAE;QACnBC,YAAY,CAACD,CAAC,GAAG,CAAC,CAAC;MACrB;MACAC,YAAY,CAACD,CAAC,CAAC,kBAAkB,CAAC,GAAGT,oBAAoB,CAACe,QAAQ,CAAC,CAAC;MACpEF,cAAM,CAACC,IAAI,CACT,0EAA0Ed,oBAAoB,0BAChG,CAAC;IACH;EACF;EAEA,OAAOG,WAAW;AACpB;AAEO,MAAMgB,0BAEZ,GAAGA,CAACC,WAAW,EAAEhB,OAAO,KAAK;EAC5B,OAAO,IAAAiB,kCAAmB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACjD,MAAMnB,WAAW,GAAGmB,KAAK,CAACC,UAAU,CAACC,QAAQ,CAC1CrB,WAAoC;IACvCmB,KAAK,CAACC,UAAU,CAACC,QAAQ,CAACrB,WAAW,GAAGD,gCAAgC,CACtEC,WAAW,EACXC,OACF,CAAC;IACD,OAAOkB,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACrB,OAAA,CAAAkB,0BAAA,GAAAA,0BAAA","ignoreList":[]}
|
|
@@ -3,19 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.modifyAppBuildGradle = modifyAppBuildGradle;
|
|
6
7
|
exports.withAppGoogleServices = void 0;
|
|
7
8
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
9
|
var _android = require("../helpers/constants/android");
|
|
9
10
|
var _logger = require("../utils/logger");
|
|
11
|
+
function modifyAppBuildGradle(contents) {
|
|
12
|
+
const regex = new RegExp(_android.CIO_APP_GOOGLE_SNIPPET);
|
|
13
|
+
if (regex.test(contents)) {
|
|
14
|
+
_logger.logger.info('app/build.gradle snippet already exists. Skipping...');
|
|
15
|
+
return contents;
|
|
16
|
+
}
|
|
17
|
+
return contents.replace(_android.CIO_APP_APPLY_REGEX, `$1\n${_android.CIO_APP_GOOGLE_SNIPPET}`);
|
|
18
|
+
}
|
|
10
19
|
const withAppGoogleServices = configOuter => {
|
|
11
20
|
return (0, _configPlugins.withAppBuildGradle)(configOuter, props => {
|
|
12
|
-
|
|
13
|
-
const match = props.modResults.contents.match(regex);
|
|
14
|
-
if (!match) {
|
|
15
|
-
props.modResults.contents = props.modResults.contents.replace(_android.CIO_APP_APPLY_REGEX, `$1\n${_android.CIO_APP_GOOGLE_SNIPPET}`);
|
|
16
|
-
} else {
|
|
17
|
-
_logger.logger.info('app/build.gradle snippet already exists. Skipping...');
|
|
18
|
-
}
|
|
21
|
+
props.modResults.contents = modifyAppBuildGradle(props.modResults.contents);
|
|
19
22
|
return props;
|
|
20
23
|
});
|
|
21
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_android","_logger","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_android","_logger","modifyAppBuildGradle","contents","regex","RegExp","CIO_APP_GOOGLE_SNIPPET","test","logger","info","replace","CIO_APP_APPLY_REGEX","withAppGoogleServices","configOuter","withAppBuildGradle","props","modResults","exports"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAppBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_APP_APPLY_REGEX,\n CIO_APP_GOOGLE_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { logger } from '../utils/logger';\n\nexport function modifyAppBuildGradle(contents: string): string {\n const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);\n if (regex.test(contents)) {\n logger.info('app/build.gradle snippet already exists. Skipping...');\n return contents;\n }\n return contents.replace(\n CIO_APP_APPLY_REGEX,\n `$1\\n${CIO_APP_GOOGLE_SNIPPET}`\n );\n}\n\nexport const withAppGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAppBuildGradle(configOuter, (props) => {\n props.modResults.contents = modifyAppBuildGradle(props.modResults.contents);\n return props;\n });\n};\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AAEO,SAASG,oBAAoBA,CAACC,QAAgB,EAAU;EAC7D,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACC,+BAAsB,CAAC;EAChD,IAAIF,KAAK,CAACG,IAAI,CAACJ,QAAQ,CAAC,EAAE;IACxBK,cAAM,CAACC,IAAI,CAAC,sDAAsD,CAAC;IACnE,OAAON,QAAQ;EACjB;EACA,OAAOA,QAAQ,CAACO,OAAO,CACrBC,4BAAmB,EACnB,OAAOL,+BAAsB,EAC/B,CAAC;AACH;AAEO,MAAMM,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,iCAAkB,EAACD,WAAW,EAAGE,KAAK,IAAK;IAChDA,KAAK,CAACC,UAAU,CAACb,QAAQ,GAAGD,oBAAoB,CAACa,KAAK,CAACC,UAAU,CAACb,QAAQ,CAAC;IAC3E,OAAOY,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACE,OAAA,CAAAL,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -3,33 +3,30 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.copyGoogleServicesFile = copyGoogleServicesFile;
|
|
6
7
|
exports.withGoogleServicesJSON = void 0;
|
|
7
8
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
9
|
var _logger = require("../utils/logger");
|
|
9
10
|
var _fileManagement = require("./../helpers/utils/fileManagement");
|
|
11
|
+
function copyGoogleServicesFile(androidPath, googleServicesFile) {
|
|
12
|
+
const destination = `${androidPath}/app/google-services.json`;
|
|
13
|
+
if (_fileManagement.FileManagement.exists(destination)) {
|
|
14
|
+
_logger.logger.info(`File already exists: ${destination}. Skipping...`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (googleServicesFile && _fileManagement.FileManagement.exists(googleServicesFile)) {
|
|
18
|
+
try {
|
|
19
|
+
_fileManagement.FileManagement.copyFile(googleServicesFile, destination);
|
|
20
|
+
} catch {
|
|
21
|
+
_logger.logger.info(`There was an error copying your google-services.json file. You can copy it manually into ${destination}`);
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
_logger.logger.info(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${destination}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
10
27
|
const withGoogleServicesJSON = (configOuter, cioProps) => {
|
|
11
28
|
return (0, _configPlugins.withProjectBuildGradle)(configOuter, props => {
|
|
12
|
-
|
|
13
|
-
androidPath: props.modRequest.platformProjectRoot,
|
|
14
|
-
googleServicesFile: cioProps === null || cioProps === void 0 ? void 0 : cioProps.googleServicesFile
|
|
15
|
-
};
|
|
16
|
-
const {
|
|
17
|
-
androidPath,
|
|
18
|
-
googleServicesFile
|
|
19
|
-
} = options;
|
|
20
|
-
if (!_fileManagement.FileManagement.exists(`${androidPath}/app/google-services.json`)) {
|
|
21
|
-
if (googleServicesFile && _fileManagement.FileManagement.exists(googleServicesFile)) {
|
|
22
|
-
try {
|
|
23
|
-
_fileManagement.FileManagement.copyFile(googleServicesFile, `${androidPath}/app/google-services.json`);
|
|
24
|
-
} catch {
|
|
25
|
-
_logger.logger.info(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`);
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
_logger.logger.info(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`);
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
_logger.logger.info(`File already exists: ${androidPath}/app/google-services.json. Skipping...`);
|
|
32
|
-
}
|
|
29
|
+
copyGoogleServicesFile(props.modRequest.platformProjectRoot, cioProps === null || cioProps === void 0 ? void 0 : cioProps.googleServicesFile);
|
|
33
30
|
return props;
|
|
34
31
|
});
|
|
35
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_logger","_fileManagement","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_logger","_fileManagement","copyGoogleServicesFile","androidPath","googleServicesFile","destination","FileManagement","exists","logger","info","copyFile","withGoogleServicesJSON","configOuter","cioProps","withProjectBuildGradle","props","modRequest","platformProjectRoot","exports"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } from '@expo/config-plugins';\n\nimport { logger } from '../utils/logger';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport function copyGoogleServicesFile(\n androidPath: string,\n googleServicesFile: string | undefined\n): void {\n const destination = `${androidPath}/app/google-services.json`;\n\n if (FileManagement.exists(destination)) {\n logger.info(`File already exists: ${destination}. Skipping...`);\n return;\n }\n\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(googleServicesFile, destination);\n } catch {\n logger.info(\n `There was an error copying your google-services.json file. You can copy it manually into ${destination}`\n );\n }\n } else {\n logger.info(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${destination}`\n );\n }\n}\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n copyGoogleServicesFile(\n props.modRequest.platformProjectRoot,\n cioProps?.googleServicesFile\n );\n return props;\n });\n};\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAGO,SAASG,sBAAsBA,CACpCC,WAAmB,EACnBC,kBAAsC,EAChC;EACN,MAAMC,WAAW,GAAG,GAAGF,WAAW,2BAA2B;EAE7D,IAAIG,8BAAc,CAACC,MAAM,CAACF,WAAW,CAAC,EAAE;IACtCG,cAAM,CAACC,IAAI,CAAC,wBAAwBJ,WAAW,eAAe,CAAC;IAC/D;EACF;EAEA,IAAID,kBAAkB,IAAIE,8BAAc,CAACC,MAAM,CAACH,kBAAkB,CAAC,EAAE;IACnE,IAAI;MACFE,8BAAc,CAACI,QAAQ,CAACN,kBAAkB,EAAEC,WAAW,CAAC;IAC1D,CAAC,CAAC,MAAM;MACNG,cAAM,CAACC,IAAI,CACT,4FAA4FJ,WAAW,EACzG,CAAC;IACH;EACF,CAAC,MAAM;IACLG,cAAM,CAACC,IAAI,CACT,wCAAwCL,kBAAkB,yDAAyDC,WAAW,EAChI,CAAC;EACH;AACF;AAEO,MAAMM,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAO,IAAAC,qCAAsB,EAACF,WAAW,EAAGG,KAAK,IAAK;IACpDb,sBAAsB,CACpBa,KAAK,CAACC,UAAU,CAACC,mBAAmB,EACpCJ,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAET,kBACZ,CAAC;IACD,OAAOW,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACG,OAAA,CAAAP,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -3,9 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.modifyGradleProperties = modifyGradleProperties;
|
|
6
7
|
exports.withLocationGradleProperties = void 0;
|
|
7
8
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
9
|
const CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';
|
|
10
|
+
function modifyGradleProperties(items) {
|
|
11
|
+
const existingIndex = items.findIndex(item => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY);
|
|
12
|
+
const newItem = {
|
|
13
|
+
type: 'property',
|
|
14
|
+
key: CUSTOMERIO_LOCATION_ENABLED_KEY,
|
|
15
|
+
value: 'true'
|
|
16
|
+
};
|
|
17
|
+
if (existingIndex >= 0) {
|
|
18
|
+
items[existingIndex] = newItem;
|
|
19
|
+
} else {
|
|
20
|
+
items.push(newItem);
|
|
21
|
+
}
|
|
22
|
+
return items;
|
|
23
|
+
}
|
|
9
24
|
|
|
10
25
|
/**
|
|
11
26
|
* Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.
|
|
@@ -18,18 +33,7 @@ const withLocationGradleProperties = (config, props) => {
|
|
|
18
33
|
}
|
|
19
34
|
return (0, _configPlugins.withGradleProperties)(config, config => {
|
|
20
35
|
const items = config.modResults;
|
|
21
|
-
|
|
22
|
-
const newItem = {
|
|
23
|
-
type: 'property',
|
|
24
|
-
key: CUSTOMERIO_LOCATION_ENABLED_KEY,
|
|
25
|
-
value: 'true'
|
|
26
|
-
};
|
|
27
|
-
if (existingIndex >= 0) {
|
|
28
|
-
items[existingIndex] = newItem;
|
|
29
|
-
} else {
|
|
30
|
-
items.push(newItem);
|
|
31
|
-
}
|
|
32
|
-
config.modResults = items;
|
|
36
|
+
config.modResults = modifyGradleProperties(items);
|
|
33
37
|
return config;
|
|
34
38
|
});
|
|
35
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","CUSTOMERIO_LOCATION_ENABLED_KEY","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","CUSTOMERIO_LOCATION_ENABLED_KEY","modifyGradleProperties","items","existingIndex","findIndex","item","type","key","newItem","value","push","withLocationGradleProperties","config","props","_props$location","location","enabled","withGradleProperties","modResults","exports"],"sources":["withLocationGradleProperties.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withGradleProperties } from '@expo/config-plugins';\nimport type { PropertiesItem } from '@expo/config-plugins/build/android/Properties';\n\nimport type { CustomerIOPluginLocationOptions } from '../types/cio-types';\n\nconst CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';\n\nexport function modifyGradleProperties(\n items: PropertiesItem[]\n): PropertiesItem[] {\n const existingIndex = items.findIndex(\n (item) => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY\n );\n\n const newItem: PropertiesItem = {\n type: 'property',\n key: CUSTOMERIO_LOCATION_ENABLED_KEY,\n value: 'true',\n };\n\n if (existingIndex >= 0) {\n items[existingIndex] = newItem;\n } else {\n items.push(newItem);\n }\n\n return items;\n}\n\n/**\n * Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.\n * The Customer.io React Native SDK reads this to enable the location native module.\n */\nexport const withLocationGradleProperties: ConfigPlugin<{\n location?: CustomerIOPluginLocationOptions;\n}> = (config, props) => {\n if (props?.location?.enabled !== true) {\n return config;\n }\n\n return withGradleProperties(config, (config) => {\n const items = config.modResults as PropertiesItem[];\n config.modResults = modifyGradleProperties(items);\n return config;\n });\n};\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAKA,MAAMC,+BAA+B,GAAG,6BAA6B;AAE9D,SAASC,sBAAsBA,CACpCC,KAAuB,EACL;EAClB,MAAMC,aAAa,GAAGD,KAAK,CAACE,SAAS,CAClCC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,UAAU,IAAID,IAAI,CAACE,GAAG,KAAKP,+BACrD,CAAC;EAED,MAAMQ,OAAuB,GAAG;IAC9BF,IAAI,EAAE,UAAU;IAChBC,GAAG,EAAEP,+BAA+B;IACpCS,KAAK,EAAE;EACT,CAAC;EAED,IAAIN,aAAa,IAAI,CAAC,EAAE;IACtBD,KAAK,CAACC,aAAa,CAAC,GAAGK,OAAO;EAChC,CAAC,MAAM;IACLN,KAAK,CAACQ,IAAI,CAACF,OAAO,CAAC;EACrB;EAEA,OAAON,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACO,MAAMS,4BAEX,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EAAA,IAAAC,eAAA;EACtB,IAAI,CAAAD,KAAK,aAALA,KAAK,gBAAAC,eAAA,GAALD,KAAK,CAAEE,QAAQ,cAAAD,eAAA,uBAAfA,eAAA,CAAiBE,OAAO,MAAK,IAAI,EAAE;IACrC,OAAOJ,MAAM;EACf;EAEA,OAAO,IAAAK,mCAAoB,EAACL,MAAM,EAAGA,MAAM,IAAK;IAC9C,MAAMV,KAAK,GAAGU,MAAM,CAACM,UAA8B;IACnDN,MAAM,CAACM,UAAU,GAAGjB,sBAAsB,CAACC,KAAK,CAAC;IACjD,OAAOU,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAACO,OAAA,CAAAR,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.injectCustomerIOInitializerIntoMainApplication = injectCustomerIOInitializerIntoMainApplication;
|
|
6
7
|
exports.withMainApplicationModifications = void 0;
|
|
7
8
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
9
|
var _android = require("../helpers/constants/android");
|
|
@@ -33,30 +34,36 @@ const getLocationInitOptions = (location, sdkConfig) => {
|
|
|
33
34
|
trackingMode: sdkConfig === null || sdkConfig === void 0 || (_sdkConfig$location = sdkConfig.location) === null || _sdkConfig$location === void 0 ? void 0 : _sdkConfig$location.trackingMode
|
|
34
35
|
};
|
|
35
36
|
};
|
|
37
|
+
const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
|
|
38
|
+
const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
|
|
39
|
+
const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
|
|
40
|
+
const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Pure string transform: given the existing MainApplication contents, returns the contents
|
|
44
|
+
* with the CustomerIOSDKInitializer import and onCreate call injected (idempotent — if the
|
|
45
|
+
* initialize call is already present, the call-injection step is skipped).
|
|
46
|
+
*/
|
|
47
|
+
function injectCustomerIOInitializerIntoMainApplication(contents) {
|
|
48
|
+
let next = (0, _android2.addImportToFile)(contents, SDK_INITIALIZER_IMPORT);
|
|
49
|
+
if (!next.includes(_android.CIO_NATIVE_SDK_INITIALIZE_CALL)) {
|
|
50
|
+
next = (0, _android2.addCodeToMethod)(next, _android.CIO_MAINAPPLICATION_ONCREATE_REGEX, _android.CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
|
|
51
|
+
}
|
|
52
|
+
return next;
|
|
53
|
+
}
|
|
36
54
|
|
|
37
55
|
/**
|
|
38
56
|
* Setup CustomerIOSDKInitializer for Android auto initialization
|
|
39
57
|
*/
|
|
40
58
|
const setupCustomerIOSDKInitializer = (config, sdkConfig, location) => {
|
|
41
|
-
const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
|
|
42
|
-
const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
|
|
43
|
-
const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
|
|
44
|
-
const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
|
|
45
59
|
const locationOptions = getLocationInitOptions(location, sdkConfig);
|
|
46
|
-
let content = config.modResults.contents;
|
|
47
60
|
try {
|
|
48
61
|
// Always regenerate the CustomerIOSDKInitializer file to reflect config changes
|
|
49
62
|
(0, _android2.copyTemplateFile)(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => (0, _patchPluginNativeCode.patchNativeSDKInitializer)(content, _common.PLATFORM.ANDROID, sdkConfig, locationOptions));
|
|
50
|
-
|
|
51
|
-
content = (0, _android2.addImportToFile)(content, SDK_INITIALIZER_IMPORT);
|
|
52
|
-
// Add initialization code to onCreate if not already present
|
|
53
|
-
if (!content.includes(_android.CIO_NATIVE_SDK_INITIALIZE_CALL)) {
|
|
54
|
-
content = (0, _android2.addCodeToMethod)(content, _android.CIO_MAINAPPLICATION_ONCREATE_REGEX, _android.CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
|
|
55
|
-
}
|
|
63
|
+
return injectCustomerIOInitializerIntoMainApplication(config.modResults.contents);
|
|
56
64
|
} catch (error) {
|
|
57
65
|
_logger.logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);
|
|
58
66
|
return config.modResults.contents;
|
|
59
67
|
}
|
|
60
|
-
return content;
|
|
61
68
|
};
|
|
62
69
|
//# sourceMappingURL=withMainApplicationModifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_android","_common","_patchPluginNativeCode","_android2","_logger","withMainApplicationModifications","configOuter","sdkConfig","location","withMainApplication","config","content","setupCustomerIOSDKInitializer","modResults","contents","exports","getLocationInitOptions","_sdkConfig$location","enabled","trackingMode","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_android","_common","_patchPluginNativeCode","_android2","_logger","withMainApplicationModifications","configOuter","sdkConfig","location","withMainApplication","config","content","setupCustomerIOSDKInitializer","modResults","contents","exports","getLocationInitOptions","_sdkConfig$location","enabled","trackingMode","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","injectCustomerIOInitializerIntoMainApplication","next","addImportToFile","includes","CIO_NATIVE_SDK_INITIALIZE_CALL","addCodeToMethod","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","locationOptions","copyTemplateFile","patchNativeSDKInitializer","PLATFORM","ANDROID","error","logger","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';\nimport { logger } from '../utils/logger';\n\ntype MainApplicationModParams = {\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n};\n\nexport const withMainApplicationModifications: ConfigPlugin<MainApplicationModParams> = (configOuter, { sdkConfig, location }) => {\n return withMainApplication(configOuter, async (config) => {\n const content = setupCustomerIOSDKInitializer(config, sdkConfig, location);\n config.modResults.contents = content;\n return config;\n });\n};\n\n/**\n * Build location options for native initializer from plugin config.\n * trackingMode comes from config.location.trackingMode (only used when location.enabled is true).\n */\nconst getLocationInitOptions = (\n location?: CustomerIOPluginLocationOptions,\n sdkConfig?: NativeSDKConfig\n) => ({\n enabled: location?.enabled === true,\n trackingMode: sdkConfig?.location?.trackingMode,\n});\n\nconst SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';\nconst SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';\nconst SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;\nconst SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;\n\n/**\n * Pure string transform: given the existing MainApplication contents, returns the contents\n * with the CustomerIOSDKInitializer import and onCreate call injected (idempotent — if the\n * initialize call is already present, the call-injection step is skipped).\n */\nexport function injectCustomerIOInitializerIntoMainApplication(\n contents: string\n): string {\n let next = addImportToFile(contents, SDK_INITIALIZER_IMPORT);\n if (!next.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n next = addCodeToMethod(\n next,\n CIO_MAINAPPLICATION_ONCREATE_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET\n );\n }\n return next;\n}\n\n/**\n * Setup CustomerIOSDKInitializer for Android auto initialization\n */\nconst setupCustomerIOSDKInitializer = (\n config: ExportedConfigWithProps<ApplicationProjectFile>,\n sdkConfig: NativeSDKConfig,\n location?: CustomerIOPluginLocationOptions,\n): string => {\n const locationOptions = getLocationInitOptions(location, sdkConfig);\n\n try {\n // Always regenerate the CustomerIOSDKInitializer file to reflect config changes\n copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>\n patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig, locationOptions)\n );\n return injectCustomerIOInitializerIntoMainApplication(config.modResults.contents);\n } catch (error) {\n logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);\n return config.modResults.contents;\n }\n};\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AAKA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAOO,MAAMM,gCAAwE,GAAGA,CAACC,WAAW,EAAE;EAAEC,SAAS;EAAEC;AAAS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A0C,KAC/B;EACX,MAAMwB,eAAe,GAAGhB,sBAAsB,CAACR,QAAQ,EAAED,SAAS,CAAC;EAEnE,IAAI;IACF;IACA,IAAA0B,0BAAgB,EAACvB,MAAM,EAAEY,oBAAoB,EAAED,uBAAuB,EAAGV,OAAO,IAC9E,IAAAuB,gDAAyB,EAACvB,OAAO,EAAEwB,gBAAQ,CAACC,OAAO,EAAE7B,SAAS,EAAEyB,eAAe,CACjF,CAAC;IACD,OAAOR,8CAA8C,CAACd,MAAM,CAACG,UAAU,CAACC,QAAQ,CAAC;EACnF,CAAC,CAAC,OAAOuB,KAAK,EAAE;IACdC,cAAM,CAACC,IAAI,CAAC,mBAAmBnB,qBAAqB,GAAG,EAAEiB,KAAK,CAAC;IAC/D,OAAO3B,MAAM,CAACG,UAAU,CAACC,QAAQ;EACnC;AACF,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.withNotificationChannelMetadata = void 0;
|
|
6
|
+
exports.withNotificationChannelMetadata = exports.addMetadataIfNotExists = void 0;
|
|
7
7
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
8
|
/**
|
|
9
9
|
* Adds a metadata entry to the Android manifest if it doesn't already exist
|
|
@@ -27,6 +27,7 @@ const addMetadataIfNotExists = (application, name, value) => {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
+
exports.addMetadataIfNotExists = addMetadataIfNotExists;
|
|
30
31
|
const withNotificationChannelMetadata = (config, props) => {
|
|
31
32
|
return (0, _configPlugins.withAndroidManifest)(config, manifestProps => {
|
|
32
33
|
var _props$pushNotificati;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","addMetadataIfNotExists","application","name","value","hasMetadata","some","metadata","$","push","withNotificationChannelMetadata","config","props","withAndroidManifest","manifestProps","_props$pushNotificati","modResults","manifest","channel","pushNotification","id","importance","undefined","String"
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","addMetadataIfNotExists","application","name","value","hasMetadata","some","metadata","$","push","exports","withNotificationChannelMetadata","config","props","withAndroidManifest","manifestProps","_props$pushNotificati","modResults","manifest","channel","pushNotification","id","importance","undefined","String"],"sources":["withNotificationChannelMetadata.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\n/**\n * Adds a metadata entry to the Android manifest if it doesn't already exist\n */\nexport const addMetadataIfNotExists = (\n application: ManifestApplication,\n name: string,\n value: string\n): void => {\n // Initialize meta-data array if it doesn't exist\n if (!application['meta-data']) {\n application['meta-data'] = [];\n }\n\n // Check if metadata already exists\n const hasMetadata = application['meta-data'].some(\n (metadata) => metadata.$['android:name'] === name\n );\n\n // Add metadata if it doesn't exist\n if (!hasMetadata) {\n application['meta-data'].push({\n $: {\n 'android:name': name,\n 'android:value': value,\n },\n });\n }\n};\n\nexport const withNotificationChannelMetadata: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (config, props) => {\n return withAndroidManifest(config, (manifestProps) => {\n const application = manifestProps.modResults.manifest\n .application as ManifestApplication[];\n const channel = props.pushNotification?.channel;\n\n // Only proceed if channel configuration exists\n if (\n channel &&\n (channel.id || channel.name || channel.importance !== undefined)\n ) {\n if (channel.id) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_id',\n channel.id\n );\n }\n\n if (channel.name) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_name',\n channel.name\n );\n }\n\n if (channel.importance !== undefined) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_importance',\n String(channel.importance)\n );\n }\n }\n\n manifestProps.modResults.manifest.application = application;\n return manifestProps;\n });\n};\n"],"mappings":";;;;;;A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AAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,uCAAuC,EACvCiB,OAAO,CAAChB,IACV,CAAC;MACH;MAEA,IAAIgB,OAAO,CAACG,UAAU,KAAKC,SAAS,EAAE;QACpCtB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,6CAA6C,EAC7CsB,MAAM,CAACL,OAAO,CAACG,UAAU,CAC3B,CAAC;MACH;IACF;IAEAP,aAAa,CAACE,UAAU,CAACC,QAAQ,CAAChB,WAAW,GAAGA,WAAW;IAC3D,OAAOa,aAAa;EACtB,CAAC,CAAC;AACJ,CAAC;AAACL,OAAA,CAAAC,+BAAA,GAAAA,+BAAA","ignoreList":[]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.modifyProjectBuildGradleAndroid16Support = modifyProjectBuildGradleAndroid16Support;
|
|
6
7
|
exports.withProjectBuildGradle = withProjectBuildGradle;
|
|
7
8
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
9
|
var _utils = require("../ios/utils");
|
|
@@ -23,6 +24,31 @@ function shouldDisableAndroid16Support(config, androidOptions) {
|
|
|
23
24
|
return (0, _utils.isExpoVersion53OrLower)(config);
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Pure string transform: injects an androidx resolution-strategy block into the
|
|
29
|
+
* project-level build.gradle's `allprojects { ... }` section when
|
|
30
|
+
* `disableAndroid16Support` is true. Idempotent — returns input unchanged if the
|
|
31
|
+
* snippet is already present, or if the flag is false.
|
|
32
|
+
*/
|
|
33
|
+
function modifyProjectBuildGradleAndroid16Support(contents, options) {
|
|
34
|
+
if (!options.disableAndroid16Support) {
|
|
35
|
+
return contents;
|
|
36
|
+
}
|
|
37
|
+
if (contents.includes('androidx.core:core-ktx:1.13.1')) {
|
|
38
|
+
return contents;
|
|
39
|
+
}
|
|
40
|
+
const resolutionStrategy = `
|
|
41
|
+
configurations.all {
|
|
42
|
+
resolutionStrategy {
|
|
43
|
+
// Disable Android 16 support by forcing older androidx versions
|
|
44
|
+
// Compatible with API 35 and AGP 8.8.2 (prevents API 36/AGP 8.9.1+ requirement)
|
|
45
|
+
force 'androidx.core:core-ktx:1.13.1'
|
|
46
|
+
force 'androidx.lifecycle:lifecycle-process:2.8.7'
|
|
47
|
+
}
|
|
48
|
+
}`;
|
|
49
|
+
return contents.replace(/allprojects\s*\{/, `allprojects {${resolutionStrategy}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
26
52
|
/**
|
|
27
53
|
* Adds dependency resolution strategy to force specific androidx versions.
|
|
28
54
|
* This disables Android 16 support for apps using Expo SDK 53 or older gradle versions.
|
|
@@ -35,31 +61,9 @@ function shouldDisableAndroid16Support(config, androidOptions) {
|
|
|
35
61
|
*/
|
|
36
62
|
function withProjectBuildGradle(config, androidOptions) {
|
|
37
63
|
return (0, _configPlugins.withProjectBuildGradle)(config, config => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Check if Android 16 support should be disabled
|
|
43
|
-
if (!shouldDisableAndroid16Support(config, androidOptions)) {
|
|
44
|
-
return config;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Skip if already applied
|
|
48
|
-
if (modResults.contents.includes('androidx.core:core-ktx:1.13.1')) {
|
|
49
|
-
return config;
|
|
50
|
-
}
|
|
51
|
-
const resolutionStrategy = `
|
|
52
|
-
configurations.all {
|
|
53
|
-
resolutionStrategy {
|
|
54
|
-
// Disable Android 16 support by forcing older androidx versions
|
|
55
|
-
// Compatible with API 35 and AGP 8.8.2 (prevents API 36/AGP 8.9.1+ requirement)
|
|
56
|
-
force 'androidx.core:core-ktx:1.13.1'
|
|
57
|
-
force 'androidx.lifecycle:lifecycle-process:2.8.7'
|
|
58
|
-
}
|
|
59
|
-
}`;
|
|
60
|
-
|
|
61
|
-
// Add resolution strategy inside allprojects block
|
|
62
|
-
modResults.contents = modResults.contents.replace(/allprojects\s*\{/, `allprojects {${resolutionStrategy}`);
|
|
64
|
+
config.modResults.contents = modifyProjectBuildGradleAndroid16Support(config.modResults.contents, {
|
|
65
|
+
disableAndroid16Support: shouldDisableAndroid16Support(config, androidOptions)
|
|
66
|
+
});
|
|
63
67
|
return config;
|
|
64
68
|
});
|
|
65
69
|
}
|