customerio-expo-plugin 3.1.0 → 3.2.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 +3 -2
- package/plugin/lib/commonjs/android/withCIOAndroid.js +13 -2
- package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/commonjs/android/withLocationGradleProperties.js +37 -0
- package/plugin/lib/commonjs/android/withLocationGradleProperties.js.map +1 -0
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js +21 -5
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/commonjs/helpers/native-files/android/CustomerIOSDKInitializer.kt +2 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/CustomerIOSDKInitializer.swift +2 -0
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +19 -2
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/patchLocationCode.js +50 -0
- package/plugin/lib/commonjs/helpers/utils/patchLocationCode.js.map +1 -0
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +3 -1
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -1
- package/plugin/lib/commonjs/index.js +2 -2
- package/plugin/lib/commonjs/index.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js +29 -4
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js +19 -9
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js +4 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
- package/plugin/lib/module/android/withCIOAndroid.js +13 -2
- package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/module/android/withLocationGradleProperties.js +30 -0
- package/plugin/lib/module/android/withLocationGradleProperties.js.map +1 -0
- package/plugin/lib/module/android/withMainApplicationModifications.js +20 -4
- package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/module/helpers/native-files/android/CustomerIOSDKInitializer.kt +2 -0
- package/plugin/lib/module/helpers/native-files/ios/CustomerIOSDKInitializer.swift +2 -0
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +18 -2
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/helpers/utils/patchLocationCode.js +44 -0
- package/plugin/lib/module/helpers/utils/patchLocationCode.js.map +1 -0
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +3 -2
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -1
- package/plugin/lib/module/index.js +2 -2
- package/plugin/lib/module/index.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIos.js +29 -4
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIosSwift.js +19 -9
- package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/module/ios/withXcodeProject.js +5 -1
- package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/module/types/cio-types.js.map +1 -1
- package/plugin/lib/typescript/android/withCIOAndroid.d.ts +2 -2
- package/plugin/lib/typescript/android/withLocationGradleProperties.d.ts +9 -0
- package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +7 -2
- package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +9 -1
- package/plugin/lib/typescript/helpers/utils/patchLocationCode.d.ts +12 -0
- package/plugin/lib/typescript/helpers/utils/patchPluginNativeCode.d.ts +3 -1
- package/plugin/lib/typescript/index.d.ts +2 -1
- package/plugin/lib/typescript/ios/withCIOIos.d.ts +2 -2
- package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +2 -2
- package/plugin/lib/typescript/ios/withXcodeProject.d.ts +8 -1
- package/plugin/lib/typescript/types/cio-types.d.ts +28 -0
- package/plugin/src/android/withCIOAndroid.ts +13 -2
- package/plugin/src/android/withLocationGradleProperties.ts +41 -0
- package/plugin/src/android/withMainApplicationModifications.ts +26 -4
- package/plugin/src/helpers/native-files/android/CustomerIOSDKInitializer.kt +2 -0
- package/plugin/src/helpers/native-files/ios/CustomerIOSDKInitializer.swift +2 -0
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +35 -3
- package/plugin/src/helpers/utils/patchLocationCode.ts +80 -0
- package/plugin/src/helpers/utils/patchPluginNativeCode.ts +10 -1
- package/plugin/src/index.ts +9 -3
- package/plugin/src/ios/withCIOIos.ts +24 -3
- package/plugin/src/ios/withCIOIosSwift.ts +20 -4
- package/plugin/src/ios/withXcodeProject.ts +20 -3
- package/plugin/src/types/cio-types.ts +30 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PLATFORM } from '../constants/common';
|
|
2
|
+
const VALID_TRACKING_MODES = ['OFF', 'MANUAL', 'ON_APP_START'];
|
|
3
|
+
|
|
4
|
+
/** Options for location module in generated native initializer */
|
|
5
|
+
|
|
6
|
+
function normalizeTrackingMode(rawMode) {
|
|
7
|
+
const upper = rawMode === null || rawMode === void 0 ? void 0 : rawMode.toUpperCase();
|
|
8
|
+
return upper && VALID_TRACKING_MODES.includes(upper) ? upper : 'MANUAL';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Replaces {{LOCATION_MODULE_IMPORT}} and {{LOCATION_MODULE_INIT}} placeholders
|
|
13
|
+
* in SDK initializer template content for the given platform.
|
|
14
|
+
*/
|
|
15
|
+
export function patchLocationPlaceholders(content, platform, locationOptions) {
|
|
16
|
+
const locationEnabled = (locationOptions === null || locationOptions === void 0 ? void 0 : locationOptions.enabled) === true;
|
|
17
|
+
const trackingMode = normalizeTrackingMode(locationOptions === null || locationOptions === void 0 ? void 0 : locationOptions.trackingMode);
|
|
18
|
+
if (platform === PLATFORM.ANDROID) {
|
|
19
|
+
if (locationEnabled) {
|
|
20
|
+
return content.replace(/\{\{LOCATION_MODULE_IMPORT\}\}/g, `import io.customer.location.LocationModuleConfig
|
|
21
|
+
import io.customer.location.LocationTrackingMode
|
|
22
|
+
import io.customer.location.ModuleLocation
|
|
23
|
+
`).replace(/\{\{LOCATION_MODULE_INIT\}\}/g, `if (io.customer.reactnative.sdk.BuildConfig.CIO_LOCATION_ENABLED) {
|
|
24
|
+
addCustomerIOModule(
|
|
25
|
+
ModuleLocation(
|
|
26
|
+
LocationModuleConfig.Builder()
|
|
27
|
+
.setLocationTrackingMode(LocationTrackingMode.${trackingMode})
|
|
28
|
+
.build()
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
return content.replace(/\n\{\{LOCATION_MODULE_IMPORT\}\}\n/g, '\n').replace(/\n\s*\{\{LOCATION_MODULE_INIT\}\}\n/g, '\n');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// iOS
|
|
38
|
+
if (locationEnabled) {
|
|
39
|
+
const modeSwift = trackingMode === 'OFF' ? '.off' : trackingMode === 'ON_APP_START' ? '.onAppStart' : '.manual';
|
|
40
|
+
return content.replace(/\{\{LOCATION_MODULE_IMPORT\}\}/g, 'import CioLocation\n').replace(/\{\{LOCATION_MODULE_INIT\}\}/g, `_ = builder.addModule(LocationModule(config: LocationConfig(mode: ${modeSwift})))`);
|
|
41
|
+
}
|
|
42
|
+
return content.replace(/\n\{\{LOCATION_MODULE_IMPORT\}\}\n/g, '\n').replace(/\n\s*\{\{LOCATION_MODULE_INIT\}\}\n/g, '\n\n');
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=patchLocationCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PLATFORM","VALID_TRACKING_MODES","normalizeTrackingMode","rawMode","upper","toUpperCase","includes","patchLocationPlaceholders","content","platform","locationOptions","locationEnabled","enabled","trackingMode","ANDROID","replace","modeSwift"],"sources":["patchLocationCode.ts"],"sourcesContent":["import type { LocationTrackingMode } from '../../types/cio-types';\nimport { PLATFORM, type Platform } from '../constants/common';\n\nconst VALID_TRACKING_MODES: LocationTrackingMode[] = ['OFF', 'MANUAL', 'ON_APP_START'];\n\n/** Options for location module in generated native initializer */\nexport type LocationInitOptions = {\n enabled: boolean;\n trackingMode?: LocationTrackingMode;\n};\n\nfunction normalizeTrackingMode(\n rawMode: string | undefined\n): LocationTrackingMode {\n const upper = rawMode?.toUpperCase();\n return upper && VALID_TRACKING_MODES.includes(upper as LocationTrackingMode)\n ? (upper as LocationTrackingMode)\n : 'MANUAL';\n}\n\n/**\n * Replaces {{LOCATION_MODULE_IMPORT}} and {{LOCATION_MODULE_INIT}} placeholders\n * in SDK initializer template content for the given platform.\n */\nexport function patchLocationPlaceholders(\n content: string,\n platform: Platform,\n locationOptions?: LocationInitOptions\n): string {\n const locationEnabled = locationOptions?.enabled === true;\n const trackingMode = normalizeTrackingMode(locationOptions?.trackingMode);\n\n if (platform === PLATFORM.ANDROID) {\n if (locationEnabled) {\n return content\n .replace(\n /\\{\\{LOCATION_MODULE_IMPORT\\}\\}/g,\n `import io.customer.location.LocationModuleConfig\nimport io.customer.location.LocationTrackingMode\nimport io.customer.location.ModuleLocation\n`\n )\n .replace(\n /\\{\\{LOCATION_MODULE_INIT\\}\\}/g,\n `if (io.customer.reactnative.sdk.BuildConfig.CIO_LOCATION_ENABLED) {\n addCustomerIOModule(\n ModuleLocation(\n LocationModuleConfig.Builder()\n .setLocationTrackingMode(LocationTrackingMode.${trackingMode})\n .build()\n )\n )\n }\n `\n );\n }\n return content\n .replace(/\\n\\{\\{LOCATION_MODULE_IMPORT\\}\\}\\n/g, '\\n')\n .replace(/\\n\\s*\\{\\{LOCATION_MODULE_INIT\\}\\}\\n/g, '\\n');\n }\n\n // iOS\n if (locationEnabled) {\n const modeSwift =\n trackingMode === 'OFF'\n ? '.off'\n : trackingMode === 'ON_APP_START'\n ? '.onAppStart'\n : '.manual';\n return content\n .replace(/\\{\\{LOCATION_MODULE_IMPORT\\}\\}/g, 'import CioLocation\\n')\n .replace(\n /\\{\\{LOCATION_MODULE_INIT\\}\\}/g,\n `_ = builder.addModule(LocationModule(config: LocationConfig(mode: ${modeSwift})))`\n );\n }\n return content\n .replace(/\\n\\{\\{LOCATION_MODULE_IMPORT\\}\\}\\n/g, '\\n')\n .replace(/\\n\\s*\\{\\{LOCATION_MODULE_INIT\\}\\}\\n/g, '\\n\\n');\n}\n"],"mappings":"AACA,SAASA,QAAQ,QAAuB,qBAAqB;AAE7D,MAAMC,oBAA4C,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC;;AAEtF;;AAMA,SAASC,qBAAqBA,CAC5BC,OAA2B,EACL;EACtB,MAAMC,KAAK,GAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,WAAW,CAAC,CAAC;EACpC,OAAOD,KAAK,IAAIH,oBAAoB,CAACK,QAAQ,CAACF,KAA6B,CAAC,GACvEA,KAAK,GACN,QAAQ;AACd;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,yBAAyBA,CACvCC,OAAe,EACfC,QAAkB,EAClBC,eAAqC,EAC7B;EACR,MAAMC,eAAe,GAAG,CAAAD,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAEE,OAAO,MAAK,IAAI;EACzD,MAAMC,YAAY,GAAGX,qBAAqB,CAACQ,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAEG,YAAY,CAAC;EAEzE,IAAIJ,QAAQ,KAAKT,QAAQ,CAACc,OAAO,EAAE;IACjC,IAAIH,eAAe,EAAE;MACnB,OAAOH,OAAO,CACXO,OAAO,CACN,iCAAiC,EACjC;AACV;AACA;AACA,CACQ,CAAC,CACAA,OAAO,CACN,+BAA+B,EAC/B;AACV;AACA;AACA;AACA,wEAAwEF,YAAY;AACpF;AACA;AACA;AACA;AACA,SACQ,CAAC;IACL;IACA,OAAOL,OAAO,CACXO,OAAO,CAAC,qCAAqC,EAAE,IAAI,CAAC,CACpDA,OAAO,CAAC,sCAAsC,EAAE,IAAI,CAAC;EAC1D;;EAEA;EACA,IAAIJ,eAAe,EAAE;IACnB,MAAMK,SAAS,GACbH,YAAY,KAAK,KAAK,GAClB,MAAM,GACNA,YAAY,KAAK,cAAc,GAC7B,aAAa,GACb,SAAS;IACjB,OAAOL,OAAO,CACXO,OAAO,CAAC,iCAAiC,EAAE,sBAAsB,CAAC,CAClEA,OAAO,CACN,+BAA+B,EAC/B,qEAAqEC,SAAS,KAChF,CAAC;EACL;EACA,OAAOR,OAAO,CACXO,OAAO,CAAC,qCAAqC,EAAE,IAAI,CAAC,CACpDA,OAAO,CAAC,sCAAsC,EAAE,MAAM,CAAC;AAC5D","ignoreList":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { getPluginVersion } from '../../utils/plugin';
|
|
2
2
|
import { validateNativeSDKConfig } from '../../utils/validation';
|
|
3
3
|
import { PLATFORM } from '../constants/common';
|
|
4
|
-
|
|
4
|
+
import { patchLocationPlaceholders } from './patchLocationCode';
|
|
5
5
|
/**
|
|
6
6
|
* Shared utility function to perform common SDK config replacements
|
|
7
7
|
* for both iOS and Android template files
|
|
8
8
|
*/
|
|
9
|
-
export function patchNativeSDKInitializer(rawContent, platform, sdkConfig) {
|
|
9
|
+
export function patchNativeSDKInitializer(rawContent, platform, sdkConfig, locationOptions) {
|
|
10
10
|
var _siteId, _migrationSiteId;
|
|
11
11
|
// Validate SDK configuration to ensure all fields are present and
|
|
12
12
|
// correct at the time of patching in prebuild
|
|
@@ -56,6 +56,7 @@ export function patchNativeSDKInitializer(rawContent, platform, sdkConfig) {
|
|
|
56
56
|
// Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)
|
|
57
57
|
replaceValue(/\{\{SITE_ID\}\}/g, ((_siteId = siteId) === null || _siteId === void 0 ? void 0 : _siteId.trim()) || undefined, configValue => `"${configValue}"`);
|
|
58
58
|
replaceValue(/\{\{MIGRATION_SITE_ID\}\}/g, ((_migrationSiteId = migrationSiteId) === null || _migrationSiteId === void 0 ? void 0 : _migrationSiteId.trim()) || undefined, configValue => `"${configValue}"`);
|
|
59
|
+
content = patchLocationPlaceholders(content, platform, locationOptions);
|
|
59
60
|
return content;
|
|
60
61
|
}
|
|
61
62
|
//# sourceMappingURL=patchPluginNativeCode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getPluginVersion","validateNativeSDKConfig","PLATFORM","patchNativeSDKInitializer","rawContent","platform","sdkConfig","_siteId","_migrationSiteId","content","replaceValue","placeholder","value","transform","fallback","ANDROID","undefined","replace","pluginVersion","cdpApiKey","region","configValue","logLevel","autoTrackDeviceAttributes","toString","trackApplicationLifecycleEvents","screenViewUse","siteId","migrationSiteId","trim"],"sources":["patchPluginNativeCode.ts"],"sourcesContent":["import type { NativeSDKConfig } from '../../types/cio-types';\nimport { getPluginVersion } from '../../utils/plugin';\nimport { validateNativeSDKConfig } from '../../utils/validation';\nimport { PLATFORM, type Platform } from '../constants/common';\n\n/**\n * Shared utility function to perform common SDK config replacements\n * for both iOS and Android template files\n */\nexport function patchNativeSDKInitializer(\n rawContent: string,\n platform: Platform,\n sdkConfig: NativeSDKConfig\n): string {\n // Validate SDK configuration to ensure all fields are present and \n // correct at the time of patching in prebuild\n validateNativeSDKConfig(sdkConfig);\n\n let content = rawContent;\n\n // Helper function to replace placeholders with platform-specific fallback values\n const replaceValue = <T>(\n placeholder: RegExp,\n value: T | undefined,\n transform: (configValue: T) => string,\n fallback: string = platform === PLATFORM.ANDROID ? 'null' : 'nil'\n ) => {\n if (value !== undefined && value !== null) {\n content = content.replace(placeholder, transform(value));\n } else {\n content = content.replace(placeholder, fallback);\n }\n };\n\n // Replace EXPO_PLUGIN_VERSION with actual plugin version\n const pluginVersion = getPluginVersion();\n content = content.replace(/\\{\\{EXPO_PLUGIN_VERSION\\}\\}/g, pluginVersion);\n\n // Replace CDP API Key (required field)\n content = content.replace(/\\{\\{CDP_API_KEY\\}\\}/g, sdkConfig.cdpApiKey);\n\n // Handle region - use empty string as fallback (nil not supported for region)\n replaceValue(\n /\\{\\{REGION\\}\\}/g,\n sdkConfig.region,\n (configValue) => `\"${configValue}\"`,\n '\"\"'\n );\n\n // Handle logLevel - use nil/null as fallback\n replaceValue(\n /\\{\\{LOG_LEVEL\\}\\}/g,\n sdkConfig.logLevel,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle optional boolean configurations\n replaceValue(\n /\\{\\{AUTO_TRACK_DEVICE_ATTRIBUTES\\}\\}/g,\n sdkConfig.autoTrackDeviceAttributes,\n (configValue) => configValue.toString()\n );\n\n replaceValue(\n /\\{\\{TRACK_APPLICATION_LIFECYCLE_EVENTS\\}\\}/g,\n sdkConfig.trackApplicationLifecycleEvents,\n (configValue) => configValue.toString()\n );\n\n // Handle screenViewUse - use nil/null as fallback\n replaceValue(\n /\\{\\{SCREEN_VIEW_USE\\}\\}/g,\n sdkConfig.screenViewUse,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle siteId/migrationSiteId business logic\n let siteId = sdkConfig.siteId;\n let migrationSiteId = sdkConfig.migrationSiteId;\n\n // Business rule: if only siteId provided, copy to migrationSiteId; if only migrationSiteId provided, set siteId to undefined\n if (siteId && !migrationSiteId) {\n migrationSiteId = siteId;\n } else if (migrationSiteId && !siteId) {\n siteId = undefined;\n }\n\n // Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)\n replaceValue(\n /\\{\\{SITE_ID\\}\\}/g,\n siteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n replaceValue(\n /\\{\\{MIGRATION_SITE_ID\\}\\}/g,\n migrationSiteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n return content;\n}\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,uBAAuB,QAAQ,wBAAwB;AAChE,SAASC,QAAQ,QAAuB,qBAAqB
|
|
1
|
+
{"version":3,"names":["getPluginVersion","validateNativeSDKConfig","PLATFORM","patchLocationPlaceholders","patchNativeSDKInitializer","rawContent","platform","sdkConfig","locationOptions","_siteId","_migrationSiteId","content","replaceValue","placeholder","value","transform","fallback","ANDROID","undefined","replace","pluginVersion","cdpApiKey","region","configValue","logLevel","autoTrackDeviceAttributes","toString","trackApplicationLifecycleEvents","screenViewUse","siteId","migrationSiteId","trim"],"sources":["patchPluginNativeCode.ts"],"sourcesContent":["import type { NativeSDKConfig } from '../../types/cio-types';\nimport { getPluginVersion } from '../../utils/plugin';\nimport { validateNativeSDKConfig } from '../../utils/validation';\nimport { PLATFORM, type Platform } from '../constants/common';\nimport {\n type LocationInitOptions,\n patchLocationPlaceholders,\n} from './patchLocationCode';\n\nexport type { LocationInitOptions };\n\n/**\n * Shared utility function to perform common SDK config replacements\n * for both iOS and Android template files\n */\nexport function patchNativeSDKInitializer(\n rawContent: string,\n platform: Platform,\n sdkConfig: NativeSDKConfig,\n locationOptions?: LocationInitOptions\n): string {\n // Validate SDK configuration to ensure all fields are present and \n // correct at the time of patching in prebuild\n validateNativeSDKConfig(sdkConfig);\n\n let content = rawContent;\n\n // Helper function to replace placeholders with platform-specific fallback values\n const replaceValue = <T>(\n placeholder: RegExp,\n value: T | undefined,\n transform: (configValue: T) => string,\n fallback: string = platform === PLATFORM.ANDROID ? 'null' : 'nil'\n ) => {\n if (value !== undefined && value !== null) {\n content = content.replace(placeholder, transform(value));\n } else {\n content = content.replace(placeholder, fallback);\n }\n };\n\n // Replace EXPO_PLUGIN_VERSION with actual plugin version\n const pluginVersion = getPluginVersion();\n content = content.replace(/\\{\\{EXPO_PLUGIN_VERSION\\}\\}/g, pluginVersion);\n\n // Replace CDP API Key (required field)\n content = content.replace(/\\{\\{CDP_API_KEY\\}\\}/g, sdkConfig.cdpApiKey);\n\n // Handle region - use empty string as fallback (nil not supported for region)\n replaceValue(\n /\\{\\{REGION\\}\\}/g,\n sdkConfig.region,\n (configValue) => `\"${configValue}\"`,\n '\"\"'\n );\n\n // Handle logLevel - use nil/null as fallback\n replaceValue(\n /\\{\\{LOG_LEVEL\\}\\}/g,\n sdkConfig.logLevel,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle optional boolean configurations\n replaceValue(\n /\\{\\{AUTO_TRACK_DEVICE_ATTRIBUTES\\}\\}/g,\n sdkConfig.autoTrackDeviceAttributes,\n (configValue) => configValue.toString()\n );\n\n replaceValue(\n /\\{\\{TRACK_APPLICATION_LIFECYCLE_EVENTS\\}\\}/g,\n sdkConfig.trackApplicationLifecycleEvents,\n (configValue) => configValue.toString()\n );\n\n // Handle screenViewUse - use nil/null as fallback\n replaceValue(\n /\\{\\{SCREEN_VIEW_USE\\}\\}/g,\n sdkConfig.screenViewUse,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle siteId/migrationSiteId business logic\n let siteId = sdkConfig.siteId;\n let migrationSiteId = sdkConfig.migrationSiteId;\n\n // Business rule: if only siteId provided, copy to migrationSiteId; if only migrationSiteId provided, set siteId to undefined\n if (siteId && !migrationSiteId) {\n migrationSiteId = siteId;\n } else if (migrationSiteId && !siteId) {\n siteId = undefined;\n }\n\n // Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)\n replaceValue(\n /\\{\\{SITE_ID\\}\\}/g,\n siteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n replaceValue(\n /\\{\\{MIGRATION_SITE_ID\\}\\}/g,\n migrationSiteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n content = patchLocationPlaceholders(content, platform, locationOptions);\n\n return content;\n}\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,uBAAuB,QAAQ,wBAAwB;AAChE,SAASC,QAAQ,QAAuB,qBAAqB;AAC7D,SAEEC,yBAAyB,QACpB,qBAAqB;AAI5B;AACA;AACA;AACA;AACA,O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J,WAAW,IAAKA,WAAW,CAACG,QAAQ,CAAC,CACxC,CAAC;;EAED;EACAd,YAAY,CACV,0BAA0B,EAC1BL,SAAS,CAACqB,aAAa,EACtBL,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;;EAED;EACA,IAAIM,MAAM,GAAGtB,SAAS,CAACsB,MAAM;EAC7B,IAAIC,eAAe,GAAGvB,SAAS,CAACuB,eAAe;;EAE/C;EACA,IAAID,MAAM,IAAI,CAACC,eAAe,EAAE;IAC9BA,eAAe,GAAGD,MAAM;EAC1B,CAAC,MAAM,IAAIC,eAAe,IAAI,CAACD,MAAM,EAAE;IACrCA,MAAM,GAAGX,SAAS;EACpB;;EAEA;EACAN,YAAY,CACV,kBAAkB,EAClB,EAAAH,OAAA,GAAAoB,MAAM,cAAApB,OAAA,uBAANA,OAAA,CAAQsB,IAAI,CAAC,CAAC,KAAIb,SAAS,EAC1BK,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAEDX,YAAY,CACV,4BAA4B,EAC5B,EAAAF,gBAAA,GAAAoB,eAAe,cAAApB,gBAAA,uBAAfA,gBAAA,CAAiBqB,IAAI,CAAC,CAAC,KAAIb,SAAS,EACnCK,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAEDZ,OAAO,GAAGR,yBAAyB,CAACQ,OAAO,EAAEL,QAAQ,EAAEE,eAAe,CAAC;EAEvE,OAAOG,OAAO;AAChB","ignoreList":[]}
|
|
@@ -9,8 +9,8 @@ function withCustomerIOPlugin(config, props) {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
// Apply platform specific modifications
|
|
12
|
-
config = withCIOIos(config, props.config, props.ios);
|
|
13
|
-
config = withCIOAndroid(config, props.config, props.android);
|
|
12
|
+
config = withCIOIos(config, props.config, props.ios, props.location);
|
|
13
|
+
config = withCIOAndroid(config, props.config, props.android, props.location);
|
|
14
14
|
return config;
|
|
15
15
|
}
|
|
16
16
|
export default withCustomerIOPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withCIOAndroid","isExpoVersion53OrHigher","withCIOIos","withCustomerIOPlugin","config","props","Error","ios","android"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { isExpoVersion53OrHigher } from './ios/utils';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {
|
|
1
|
+
{"version":3,"names":["withCIOAndroid","isExpoVersion53OrHigher","withCIOIos","withCustomerIOPlugin","config","props","Error","ios","location","android"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { isExpoVersion53OrHigher } from './ios/utils';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {\n CustomerIOPluginOptions,\n LocationTrackingMode,\n NativeSDKConfig,\n} from './types/cio-types';\n\nexport type { LocationTrackingMode, NativeSDKConfig };\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n // Check if config is being used with unsupported Expo version\n if (props.config && !isExpoVersion53OrHigher(config)) {\n throw new Error(\n 'CustomerIO auto initialization (config property) requires Expo SDK 53 or higher. ' +\n 'Please upgrade to Expo SDK 53+ or use manual initialization instead. ' +\n 'See documentation for manual setup instructions.'\n );\n }\n\n // Apply platform specific modifications\n config = withCIOIos(config, props.config, props.ios, props.location);\n config = withCIOAndroid(config, props.config, props.android, props.location);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,uBAAuB,QAAQ,aAAa;AACrD,SAASC,UAAU,QAAQ,kBAAkB;AAS7C;AACA,SAASC,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA;EACA,IAAIA,KAAK,CAACD,MAAM,IAAI,CAACH,uBAAuB,CAACG,MAAM,CAAC,EAAE;IACpD,MAAM,IAAIE,KAAK,CACb,mFAAmF,GACnF,uEAAuE,GACvE,kDACF,CAAC;EACH;;EAEA;EACAF,MAAM,GAAGF,UAAU,CAACE,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACE,GAAG,EAAEF,KAAK,CAACG,QAAQ,CAAC;EACpEJ,MAAM,GAAGJ,cAAc,CAACI,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACI,OAAO,EAAEJ,KAAK,CAACG,QAAQ,CAAC;EAE5E,OAAOJ,MAAM;AACf;AAEA,eAAeD,oBAAoB","ignoreList":[]}
|
|
@@ -6,12 +6,13 @@ import { withCIOIosSwift } from './withCIOIosSwift';
|
|
|
6
6
|
import { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';
|
|
7
7
|
import { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';
|
|
8
8
|
import { withCioXcodeProject } from './withXcodeProject';
|
|
9
|
-
export function withCIOIos(config, sdkConfig, props) {
|
|
9
|
+
export function withCIOIos(config, sdkConfig, props, location) {
|
|
10
10
|
const isSwiftProject = isExpoVersion53OrHigher(config);
|
|
11
11
|
const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);
|
|
12
|
+
const locationEnabled = (location === null || location === void 0 ? void 0 : location.enabled) === true;
|
|
12
13
|
if (platformConfig !== null && platformConfig !== void 0 && platformConfig.pushNotification) {
|
|
13
14
|
if (isSwiftProject) {
|
|
14
|
-
config = withCIOIosSwift(config, sdkConfig, platformConfig);
|
|
15
|
+
config = withCIOIosSwift(config, sdkConfig, platformConfig, location);
|
|
15
16
|
} else {
|
|
16
17
|
// Auto initialization is only supported in Swift projects (Expo SDK 53+)
|
|
17
18
|
// Legacy Objective-C projects only support push notifications
|
|
@@ -19,10 +20,34 @@ export function withCIOIos(config, sdkConfig, props) {
|
|
|
19
20
|
}
|
|
20
21
|
platformConfig.pushNotification.env = platformConfig.pushNotification.env || mergeConfigWithEnvValues(platformConfig, sdkConfig);
|
|
21
22
|
config = withCioNotificationsXcodeProject(config, platformConfig);
|
|
22
|
-
config = withCioXcodeProject(config,
|
|
23
|
+
config = withCioXcodeProject(config, {
|
|
24
|
+
...platformConfig,
|
|
25
|
+
podfileOptions: {
|
|
26
|
+
locationEnabled,
|
|
27
|
+
hasPush: true
|
|
28
|
+
}
|
|
29
|
+
});
|
|
23
30
|
config = withGoogleServicesJsonFile(config, platformConfig);
|
|
24
31
|
} else if (sdkConfig && isSwiftProject) {
|
|
25
|
-
config = withCIOIosSwift(config, sdkConfig, platformConfig);
|
|
32
|
+
config = withCIOIosSwift(config, sdkConfig, platformConfig, location);
|
|
33
|
+
if (locationEnabled) {
|
|
34
|
+
config = withCioXcodeProject(config, {
|
|
35
|
+
...platformConfig,
|
|
36
|
+
podfileOptions: {
|
|
37
|
+
locationEnabled: true,
|
|
38
|
+
hasPush: false
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
} else if (locationEnabled) {
|
|
43
|
+
// Location-only: no push, no config. Still add Podfile location subspec so CIO_LOCATION_ENABLED is set and native location code is included.
|
|
44
|
+
config = withCioXcodeProject(config, {
|
|
45
|
+
...platformConfig,
|
|
46
|
+
podfileOptions: {
|
|
47
|
+
locationEnabled: true,
|
|
48
|
+
hasPush: false
|
|
49
|
+
}
|
|
50
|
+
});
|
|
26
51
|
}
|
|
27
52
|
return config;
|
|
28
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["mergeConfigWithEnvValues","logger","isExpoVersion53OrHigher","withAppDelegateModifications","withCIOIosSwift","withGoogleServicesJsonFile","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","sdkConfig","props","isSwiftProject","platformConfig","mergeDeprecatedPropertiesAndLogWarnings","pushNotification","env","deprecatedTopLevelProperties","showPushAppInForeground","autoTrackPushEvents","handleDeeplinkInKilledState","disableNotificationRegistration","autoFetchDeviceToken","Object","entries","forEach","key","value","undefined","warn","propKey"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginPushNotificationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { mergeConfigWithEnvValues } from '../utils/config';\nimport { logger } from '../utils/logger';\nimport { isExpoVersion53OrHigher } from './utils';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCIOIosSwift } from './withCIOIosSwift';\nimport { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n) {\n const isSwiftProject = isExpoVersion53OrHigher(config);\n const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);\n\n if (platformConfig?.pushNotification) {\n if (isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig);\n } else {\n // Auto initialization is only supported in Swift projects (Expo SDK 53+)\n // Legacy Objective-C projects only support push notifications\n config = withAppDelegateModifications(config, platformConfig);\n }\n\n platformConfig.pushNotification.env = platformConfig.pushNotification.env\n || mergeConfigWithEnvValues(platformConfig, sdkConfig);\n config = withCioNotificationsXcodeProject(config, platformConfig);\n config = withCioXcodeProject(config, platformConfig);\n config = withGoogleServicesJsonFile(config, platformConfig);\n } else if (sdkConfig && isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig);\n }\n\n return config;\n}\n\n/** The basic purpose of this function is to centralize where we handle the deprecation\n by merging the deprecated properties into the new ios.pushNotification.* properties\n and logging a warning if they are set. This way, we can remove the deprecated properties\n from the top level of the ios object in the future, and update this function\n while the rest of the plugin code remains unchanged.\n*/\nconst mergeDeprecatedPropertiesAndLogWarnings = (\n props?: CustomerIOPluginOptionsIOS,\n): CustomerIOPluginOptionsIOS | undefined => {\n // The deprecatedTopLevelProperties maps the top level properties\n // that are deprecated to the new ios.pushNotification.* properties\n // that should be used instead. The deprecated properties are\n // still available for backwards compatibility, but they will\n // be removed in the future.\n\n if (!props) {\n return props\n }\n\n const deprecatedTopLevelProperties = {\n showPushAppInForeground: props.showPushAppInForeground,\n autoTrackPushEvents: props.autoTrackPushEvents,\n handleDeeplinkInKilledState: props.handleDeeplinkInKilledState,\n disableNotificationRegistration: props.disableNotificationRegistration,\n autoFetchDeviceToken: props.autoFetchDeviceToken,\n };\n\n // loop over all the deprecated properties and log a warning if they are set\n Object.entries(deprecatedTopLevelProperties).forEach(([key, value]) => {\n if (value !== undefined) {\n logger.warn(\n `The ios.${key} property is deprecated. Please use ios.pushNotification.${key} instead.`\n );\n\n if (props.pushNotification === undefined) {\n props.pushNotification = {} as CustomerIOPluginPushNotificationOptions;\n }\n const propKey = key as keyof CustomerIOPluginPushNotificationOptions;\n if (props.pushNotification[propKey] === undefined) {\n props.pushNotification = {\n ...props.pushNotification,\n [propKey]: value,\n };\n } else {\n logger.warn(\n `The ios.${key} property is deprecated. Since the value of ios.pushNotification.${key} is set, it will be used.`\n );\n }\n }\n });\n\n return props;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["mergeConfigWithEnvValues","logger","isExpoVersion53OrHigher","withAppDelegateModifications","withCIOIosSwift","withGoogleServicesJsonFile","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","sdkConfig","props","location","isSwiftProject","platformConfig","mergeDeprecatedPropertiesAndLogWarnings","locationEnabled","enabled","pushNotification","env","podfileOptions","hasPush","deprecatedTopLevelProperties","showPushAppInForeground","autoTrackPushEvents","handleDeeplinkInKilledState","disableNotificationRegistration","autoFetchDeviceToken","Object","entries","forEach","key","value","undefined","warn","propKey"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginPushNotificationOptions,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { mergeConfigWithEnvValues } from '../utils/config';\nimport { logger } from '../utils/logger';\nimport { isExpoVersion53OrHigher } from './utils';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCIOIosSwift } from './withCIOIosSwift';\nimport { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n) {\n const isSwiftProject = isExpoVersion53OrHigher(config);\n const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);\n const locationEnabled = location?.enabled === true;\n\n if (platformConfig?.pushNotification) {\n if (isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig, location);\n } else {\n // Auto initialization is only supported in Swift projects (Expo SDK 53+)\n // Legacy Objective-C projects only support push notifications\n config = withAppDelegateModifications(config, platformConfig);\n }\n\n platformConfig.pushNotification.env = platformConfig.pushNotification.env\n || mergeConfigWithEnvValues(platformConfig, sdkConfig);\n config = withCioNotificationsXcodeProject(config, platformConfig);\n config = withCioXcodeProject(config, {\n ...platformConfig,\n podfileOptions: {\n locationEnabled,\n hasPush: true,\n },\n });\n config = withGoogleServicesJsonFile(config, platformConfig);\n } else if (sdkConfig && isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig, location);\n if (locationEnabled) {\n config = withCioXcodeProject(config, {\n ...platformConfig,\n podfileOptions: { locationEnabled: true, hasPush: false },\n });\n }\n } else if (locationEnabled) {\n // Location-only: no push, no config. Still add Podfile location subspec so CIO_LOCATION_ENABLED is set and native location code is included.\n config = withCioXcodeProject(config, {\n ...platformConfig,\n podfileOptions: { locationEnabled: true, hasPush: false },\n });\n }\n\n return config;\n}\n\n/** The basic purpose of this function is to centralize where we handle the deprecation\n by merging the deprecated properties into the new ios.pushNotification.* properties\n and logging a warning if they are set. This way, we can remove the deprecated properties\n from the top level of the ios object in the future, and update this function\n while the rest of the plugin code remains unchanged.\n*/\nconst mergeDeprecatedPropertiesAndLogWarnings = (\n props?: CustomerIOPluginOptionsIOS,\n): CustomerIOPluginOptionsIOS | undefined => {\n // The deprecatedTopLevelProperties maps the top level properties\n // that are deprecated to the new ios.pushNotification.* properties\n // that should be used instead. The deprecated properties are\n // still available for backwards compatibility, but they will\n // be removed in the future.\n\n if (!props) {\n return props\n }\n\n const deprecatedTopLevelProperties = {\n showPushAppInForeground: props.showPushAppInForeground,\n autoTrackPushEvents: props.autoTrackPushEvents,\n handleDeeplinkInKilledState: props.handleDeeplinkInKilledState,\n disableNotificationRegistration: props.disableNotificationRegistration,\n autoFetchDeviceToken: props.autoFetchDeviceToken,\n };\n\n // loop over all the deprecated properties and log a warning if they are set\n Object.entries(deprecatedTopLevelProperties).forEach(([key, value]) => {\n if (value !== undefined) {\n logger.warn(\n `The ios.${key} property is deprecated. Please use ios.pushNotification.${key} instead.`\n );\n\n if (props.pushNotification === undefined) {\n props.pushNotification = {} as CustomerIOPluginPushNotificationOptions;\n }\n const propKey = key as keyof CustomerIOPluginPushNotificationOptions;\n if (props.pushNotification[propKey] === undefined) {\n props.pushNotification = {\n ...props.pushNotification,\n [propKey]: value,\n };\n } else {\n logger.warn(\n `The ios.${key} property is deprecated. Since the value of ios.pushNotification.${key} is set, it will be used.`\n );\n }\n }\n });\n\n return props;\n};\n"],"mappings":"AAOA,SAASA,wBAAwB,QAAQ,iBAAiB;AAC1D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,uBAAuB,QAAQ,SAAS;AACjD,SAASC,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,U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ACL/B,MAAM,CAACiC,IAAI,CACT,WAAWH,GAAG,oEAAoEA,GAAG,2BACvF,CAAC;MACH;IACF;EACF,CAAC,CAAC;EAEF,OAAOpB,KAAK;AACd,CAAC","ignoreList":[]}
|
|
@@ -17,7 +17,7 @@ const CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CL
|
|
|
17
17
|
/**
|
|
18
18
|
* Copy and configure the CioSdkAppDelegateHandler.swift file
|
|
19
19
|
*/
|
|
20
|
-
const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props) => {
|
|
20
|
+
const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props, location) => {
|
|
21
21
|
// Destination path in the iOS project
|
|
22
22
|
const projectName = config.modRequest.projectName || '';
|
|
23
23
|
if (!projectName) {
|
|
@@ -38,7 +38,8 @@ const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props) => {
|
|
|
38
38
|
iosProjectRoot,
|
|
39
39
|
projectName,
|
|
40
40
|
sdkConfig,
|
|
41
|
-
props
|
|
41
|
+
props,
|
|
42
|
+
location
|
|
42
43
|
});
|
|
43
44
|
} else if (sdkConfig) {
|
|
44
45
|
// Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications
|
|
@@ -47,7 +48,8 @@ const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props) => {
|
|
|
47
48
|
group,
|
|
48
49
|
iosProjectRoot,
|
|
49
50
|
projectName,
|
|
50
|
-
sdkConfig
|
|
51
|
+
sdkConfig,
|
|
52
|
+
location
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
return config;
|
|
@@ -58,7 +60,8 @@ const copyAndConfigurePushAppDelegateHandler = ({
|
|
|
58
60
|
iosProjectRoot,
|
|
59
61
|
projectName,
|
|
60
62
|
sdkConfig,
|
|
61
|
-
props
|
|
63
|
+
props,
|
|
64
|
+
location
|
|
62
65
|
}) => {
|
|
63
66
|
var _props$pushNotificati, _props$pushNotificati2, _props$pushNotificati3, _props$pushNotificati4;
|
|
64
67
|
const useFcm = isFcmPushProvider(props);
|
|
@@ -94,7 +97,8 @@ const copyAndConfigurePushAppDelegateHandler = ({
|
|
|
94
97
|
group,
|
|
95
98
|
iosProjectRoot,
|
|
96
99
|
projectName,
|
|
97
|
-
sdkConfig
|
|
100
|
+
sdkConfig,
|
|
101
|
+
location
|
|
98
102
|
});
|
|
99
103
|
|
|
100
104
|
// Inject auto initialization call before MessagingPush initialization
|
|
@@ -107,8 +111,14 @@ const copyAndConfigureNativeSDKInitializer = ({
|
|
|
107
111
|
group,
|
|
108
112
|
iosProjectRoot,
|
|
109
113
|
projectName,
|
|
110
|
-
sdkConfig
|
|
114
|
+
sdkConfig,
|
|
115
|
+
location
|
|
111
116
|
}) => {
|
|
117
|
+
var _sdkConfig$location;
|
|
118
|
+
const locationOptions = location ? {
|
|
119
|
+
enabled: location.enabled === true,
|
|
120
|
+
trackingMode: sdkConfig === null || sdkConfig === void 0 || (_sdkConfig$location = sdkConfig.location) === null || _sdkConfig$location === void 0 ? void 0 : _sdkConfig$location.trackingMode
|
|
121
|
+
} : undefined;
|
|
112
122
|
const filename = 'CustomerIOSDKInitializer.swift';
|
|
113
123
|
const sourcePath = path.join(getIosNativeFilesPath(), filename);
|
|
114
124
|
// Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler
|
|
@@ -118,14 +128,14 @@ const copyAndConfigureNativeSDKInitializer = ({
|
|
|
118
128
|
projectName,
|
|
119
129
|
sourceFilePath: sourcePath,
|
|
120
130
|
targetFileName: filename,
|
|
121
|
-
transform: content => patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig),
|
|
131
|
+
transform: content => patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig, locationOptions),
|
|
122
132
|
customerIOGroup: group
|
|
123
133
|
});
|
|
124
134
|
};
|
|
125
|
-
export const withCIOIosSwift = (configOuter, sdkConfig, props) => {
|
|
135
|
+
export const withCIOIosSwift = (configOuter, sdkConfig, props, location) => {
|
|
126
136
|
// First, copy required swift files to iOS folder and add it to Xcode project
|
|
127
137
|
configOuter = withXcodeProject(configOuter, async config => {
|
|
128
|
-
return copyAndConfigureAppDelegateHandler(config, sdkConfig, props);
|
|
138
|
+
return copyAndConfigureAppDelegateHandler(config, sdkConfig, props, location);
|
|
129
139
|
});
|
|
130
140
|
|
|
131
141
|
// Modify the AppDelegate based on configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAppDelegate","withXcodeProject","path","PLATFORM","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","replaceCodeByRegex","FileManagement","patchNativeSDKInitializer","logger","getIosNativeFilesPath","copyFileToXcode","getOrCreateCustomerIOGroup","isFcmPushProvider","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","projectName","modRequest","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","join","group","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","useFcm","handlerSourcePath","handlerDestPath","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","replace","writeFile","filename","sourcePath","sourceFilePath","targetFileName","transform","content","IOS","customerIOGroup","withCIOIosSwift","configOuter","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","_props$pushNotificati5","appDelegateContent","contents","includes","info","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type {\n ExportedConfigWithProps,\n XcodeProject,\n} from '@expo/config-plugins';\nimport { withAppDelegate, withXcodeProject } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\nimport { PLATFORM } from '../helpers/constants/common';\nimport {\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_CALL,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type { CustomerIOPluginOptionsIOS, NativeSDKConfig } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { copyFileToXcode, getOrCreateCustomerIOGroup } from '../utils/xcode';\nimport { isFcmPushProvider } from './utils';\n\n// Constants\nconst CIO_SDK_APP_DELEGATE_HANDLER_CLASS = 'CioSdkAppDelegateHandler';\nconst CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}.swift`;\n\n/**\n * Copy and configure the CioSdkAppDelegateHandler.swift file\n */\nconst copyAndConfigureAppDelegateHandler = (\n config: ExportedConfigWithProps<XcodeProject>,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n): ExportedConfigWithProps<XcodeProject> => {\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n logger.warn(\n 'Project name is undefined, cannot copy CustomerIO files'\n );\n return config;\n }\n\n // Add files to the Xcode project\n const xcodeProject = config.modResults;\n const projectRoot = config.modRequest.projectRoot;\n const iosProjectRoot = path.join(projectRoot, 'ios');\n\n const group = getOrCreateCustomerIOGroup(xcodeProject, projectName);\n if (props?.pushNotification) {\n // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support\n copyAndConfigurePushAppDelegateHandler({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n });\n } else if (sdkConfig) {\n // Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications\n copyAndConfigureNativeSDKInitializer({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n });\n }\n\n return config;\n};\n\nconst copyAndConfigurePushAppDelegateHandler = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig | undefined;\n props: CustomerIOPluginOptionsIOS;\n}) => {\n const useFcm = isFcmPushProvider(props);\n\n // Source path for the handler file\n const handlerSourcePath = path.join(\n getIosNativeFilesPath(),\n useFcm ? 'fcm' : 'apn',\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n const handlerDestPath = path.join(\n iosProjectRoot,\n projectName,\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n FileManagement.copyFile(handlerSourcePath, handlerDestPath);\n\n // Add the file to the Xcode project\n xcodeProject.addSourceFile(\n `${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`,\n null,\n group\n );\n\n let handlerFileContent = FileManagement.readFile(handlerDestPath);\n\n const disableNotificationRegistration =\n props.pushNotification?.disableNotificationRegistration;\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2;\n }\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n snippet\n );\n\n const autoTrackPushEvents =\n props.pushNotification?.autoTrackPushEvents !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n props.pushNotification?.autoFetchDeviceToken !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n props.pushNotification?.showPushAppInForeground !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n // Also copy CustomerIOSDKInitializer.swift for auto-initialization\n copyAndConfigureNativeSDKInitializer({ xcodeProject, group, iosProjectRoot, projectName, sdkConfig });\n\n // Inject auto initialization call before MessagingPush initialization\n handlerFileContent = handlerFileContent.replace(CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET + '$1');\n }\n\n FileManagement.writeFile(handlerDestPath, handlerFileContent);\n};\n\nconst copyAndConfigureNativeSDKInitializer = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig;\n}) => {\n const filename = 'CustomerIOSDKInitializer.swift';\n const sourcePath = path.join(getIosNativeFilesPath(), filename);\n // Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler\n copyFileToXcode({\n xcodeProject,\n iosProjectRoot,\n projectName,\n sourceFilePath: sourcePath,\n targetFileName: filename,\n transform: (content) => patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig),\n customerIOGroup: group,\n });\n};\n\nexport const withCIOIosSwift = (\n configOuter: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n) => {\n // First, copy required swift files to iOS folder and add it to Xcode project\n configOuter = withXcodeProject(configOuter, async (config) => {\n return copyAndConfigureAppDelegateHandler(config, sdkConfig, props);\n });\n\n // Modify the AppDelegate based on configuration\n if (props?.pushNotification) {\n // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithPushAppDelegateHandler(config, props);\n });\n } else if (sdkConfig) {\n // Without push notifications: directly inject auto initialization into AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithNativeSDKInitializer(config);\n });\n } else {\n return configOuter;\n }\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithPushAppDelegateHandler = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n props: CustomerIOPluginOptionsIOS\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Add the handler property declaration\n let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n modifiedContent = modifyDidFinishLaunchingWithOptions(\n modifiedContent,\n ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `\n );\n\n // Add didRegisterForRemoteNotificationsWithDeviceToken implementation\n modifiedContent =\n addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);\n\n // Add didFailToRegisterForRemoteNotificationsWithError implementation\n modifiedContent =\n addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);\n\n // Add deep link handling for killed state if enabled\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);\n }\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithNativeSDKInitializer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n const modifiedContent = modifyDidFinishLaunchingWithOptions(\n appDelegateContent,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n );\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Check if a method exists in the AppDelegate content\n * @param content The AppDelegate content\n * @param methodSignature The method signature to check for\n * @returns true if the method exists, false otherwise\n */\nconst methodExistsInAppDelegate = (\n content: string,\n methodSignature: string\n): boolean => {\n return content.includes(methodSignature);\n};\n\n/**\n * Add handler property declaration to the AppDelegate class\n * This adds the line: let cioSdkHandler = CioSdkAppDelegateHandler()\n * to the AppDelegate class\n */\nconst addHandlerPropertyDeclaration = (content: string): string => {\n // Look for the AppDelegate class declaration\n const classDeclarationRegex = /class\\s+AppDelegate\\s*:\\s*.*\\s*{/;\n const match = content.match(classDeclarationRegex);\n\n if (!match) {\n logger.warn('Could not find AppDelegate class declaration');\n return content;\n }\n\n const position = (match.index ?? 0) + match[0].length;\n return (\n content.substring(0, position) +\n `\\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\\n` +\n content.substring(position)\n );\n};\n\n/**\n * Modify didFinishLaunchingWithOptions to inject Customer.io code\n * Injects the provided code (either handler call or auto initialization) before the return statement\n */\nconst modifyDidFinishLaunchingWithOptions = (content: string, codeToInject: string): string => {\n // Find the return statement in didFinishLaunchingWithOptions\n // Always look for launchOptions since modifiedLaunchOptions is only set later\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn(\n 'Could not find return statement with super.application in didFinishLaunchingWithOptions'\n );\n return content;\n }\n\n // Inject Customer.io code before the return statement\n const insertPosition = returnStatementMatch.index ?? 0;\n\n return (\n content.substring(0, insertPosition) +\n codeToInject +\n content.substring(insertPosition)\n );\n};\n\n/**\n * Add or modify didRegisterForRemoteNotificationsWithDeviceToken implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didRegisterForRemoteNotificationsWithDeviceToken\\s+deviceToken\\s*:\\s*Data\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle device token registration\\n' +\n ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add or modify didFailToRegisterForRemoteNotificationsWithError implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didFailToRegisterForRemoteNotificationsWithError\\s+error\\s*:\\s*Error\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle remote notification registration errors\\n' +\n ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add deep link handling for killed state\n * This replaces the return statement with deep link handling code\n * and a modified return statement that uses modifiedLaunchOptions\n */\nconst addHandleDeeplinkInKilledState = (content: string): string => {\n // Check if deep link code snippet is already present\n const deepLinkMarker = 'Deep link workaround for app killed state start';\n if (content.includes(deepLinkMarker)) {\n return content;\n }\n\n // Find the return statement with launchOptions\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn('Could not find return statement with launchOptions');\n return content;\n }\n\n // Create the replacement code with deep link handling and modified return statement\n const modifiedReturnStatement =\n 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';\n const replacementCode =\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET +\n '\\n\\n ' +\n modifiedReturnStatement;\n\n // Replace the return statement with deep link handling code and modified return statement\n return content.replace(returnStatementRegex, replacementCode);\n};\n"],"mappings":"AAIA,SAASA,eAAe,EAAEC,gBAAgB,QAAQ,sBAAsB;AAExE,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SACEC,+CAA+C,EAC/CC,0CAA0C,EAC1CC,8BAA8B,EAC9BC,iCAAiC,EACjCC,wCAAwC,EACxCC,0CAA0C,QACrC,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,yBAAyB,QAAQ,wCAAwC;AAElF,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,eAAe,EAAEC,0BAA0B,QAAQ,gBAAgB;AAC5E,SAASC,iBAAiB,QAAQ,SAAS;;AAE3C;AACA,MAAMC,kCAAkC,GAAG,0BAA0B;AACrE,MAAMC,qCAAqC,GAAG,GAAGD,kCAAkC,QAAQ;;AAE3F;AACA;AACA;AACA,MAAME,kCAAkC,GAAGA,CACzCC,MAA6C,EAC7CC,SAA2B,EAC3BC,KAAkC,KACQ;EAC1C;EACA,MAAMC,WAAW,GAAGH,MAAM,CAACI,UAAU,CAACD,WAAW,IAAI,EAAE;EACvD,IAAI,CAACA,WAAW,EAAE;IAChBX,MAAM,CAACa,IAAI,CACT,yDACF,CAAC;IACD,OAAOL,MAAM;EACf;;EAEA;EACA,MAAMM,YAAY,GAAGN,MAAM,CAACO,UAAU;EACtC,MAAMC,WAAW,GAAGR,MAAM,CAACI,UAAU,CAACI,WAAW;EACjD,MAAMC,cAAc,GAAG5B,IAAI,CAAC6B,IAAI,CAACF,WAAW,EAAE,KAAK,CAAC;EAEpD,MAAMG,KAAK,GAAGhB,0BAA0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C,OAAO;EAChB;;EAEA;EACA,MAAM4B,oBAAoB,GACxB,6GAA6G;EAC/G,MAAMC,oBAAoB,GAAG7B,OAAO,CAACsB,KAAK,CAACM,oBAAoB,CAAC;EAEhE,IAAI,CAACC,oBAAoB,EAAE;IACzB5E,MAAM,CAACa,IAAI,CAAC,oDAAoD,CAAC;IACjE,OAAOkC,OAAO;EAChB;;EAEA;EACA,MAAMuC,uBAAuB,GAC3B,6FAA6F;EAC/F,MAAMC,eAAe,GACnBhG,+CAA+C,GAC/C,UAAU,GACV+F,uBAAuB;;EAEzB;EACA,OAAOvC,OAAO,CAACP,OAAO,CAACmC,oBAAoB,EAAEY,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["withAppDelegate","withXcodeProject","path","PLATFORM","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","replaceCodeByRegex","FileManagement","patchNativeSDKInitializer","logger","getIosNativeFilesPath","copyFileToXcode","getOrCreateCustomerIOGroup","isFcmPushProvider","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","location","projectName","modRequest","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","join","group","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","useFcm","handlerSourcePath","handlerDestPath","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","replace","writeFile","_sdkConfig$location","locationOptions","enabled","trackingMode","undefined","filename","sourcePath","sourceFilePath","targetFileName","transform","content","IOS","customerIOGroup","withCIOIosSwift","configOuter","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","_props$pushNotificati5","appDelegateContent","contents","includes","info","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type {\n ExportedConfigWithProps,\n XcodeProject,\n} from '@expo/config-plugins';\nimport { withAppDelegate, withXcodeProject } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\nimport { PLATFORM } from '../helpers/constants/common';\nimport {\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_CALL,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { copyFileToXcode, getOrCreateCustomerIOGroup } from '../utils/xcode';\nimport { isFcmPushProvider } from './utils';\n\n// Constants\nconst CIO_SDK_APP_DELEGATE_HANDLER_CLASS = 'CioSdkAppDelegateHandler';\nconst CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}.swift`;\n\n/**\n * Copy and configure the CioSdkAppDelegateHandler.swift file\n */\nconst copyAndConfigureAppDelegateHandler = (\n config: ExportedConfigWithProps<XcodeProject>,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n): ExportedConfigWithProps<XcodeProject> => {\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n logger.warn(\n 'Project name is undefined, cannot copy CustomerIO files'\n );\n return config;\n }\n\n // Add files to the Xcode project\n const xcodeProject = config.modResults;\n const projectRoot = config.modRequest.projectRoot;\n const iosProjectRoot = path.join(projectRoot, 'ios');\n\n const group = getOrCreateCustomerIOGroup(xcodeProject, projectName);\n if (props?.pushNotification) {\n // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support\n copyAndConfigurePushAppDelegateHandler({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n location,\n });\n } else if (sdkConfig) {\n // Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications\n copyAndConfigureNativeSDKInitializer({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n location,\n });\n }\n\n return config;\n};\n\nconst copyAndConfigurePushAppDelegateHandler = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n location,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig | undefined;\n props: CustomerIOPluginOptionsIOS;\n location?: CustomerIOPluginLocationOptions;\n}) => {\n const useFcm = isFcmPushProvider(props);\n\n // Source path for the handler file\n const handlerSourcePath = path.join(\n getIosNativeFilesPath(),\n useFcm ? 'fcm' : 'apn',\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n const handlerDestPath = path.join(\n iosProjectRoot,\n projectName,\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n FileManagement.copyFile(handlerSourcePath, handlerDestPath);\n\n // Add the file to the Xcode project\n xcodeProject.addSourceFile(\n `${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`,\n null,\n group\n );\n\n let handlerFileContent = FileManagement.readFile(handlerDestPath);\n\n const disableNotificationRegistration =\n props.pushNotification?.disableNotificationRegistration;\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2;\n }\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n snippet\n );\n\n const autoTrackPushEvents =\n props.pushNotification?.autoTrackPushEvents !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n props.pushNotification?.autoFetchDeviceToken !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n props.pushNotification?.showPushAppInForeground !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n // Also copy CustomerIOSDKInitializer.swift for auto-initialization\n copyAndConfigureNativeSDKInitializer({ xcodeProject, group, iosProjectRoot, projectName, sdkConfig, location });\n\n // Inject auto initialization call before MessagingPush initialization\n handlerFileContent = handlerFileContent.replace(CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET + '$1');\n }\n\n FileManagement.writeFile(handlerDestPath, handlerFileContent);\n};\n\nconst copyAndConfigureNativeSDKInitializer = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n location,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n}) => {\n const locationOptions = location\n ? { enabled: location.enabled === true, trackingMode: sdkConfig?.location?.trackingMode }\n : undefined;\n const filename = 'CustomerIOSDKInitializer.swift';\n const sourcePath = path.join(getIosNativeFilesPath(), filename);\n // Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler\n copyFileToXcode({\n xcodeProject,\n iosProjectRoot,\n projectName,\n sourceFilePath: sourcePath,\n targetFileName: filename,\n transform: (content) =>\n patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig, locationOptions),\n customerIOGroup: group,\n });\n};\n\nexport const withCIOIosSwift = (\n configOuter: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n) => {\n // First, copy required swift files to iOS folder and add it to Xcode project\n configOuter = withXcodeProject(configOuter, async (config) => {\n return copyAndConfigureAppDelegateHandler(config, sdkConfig, props, location);\n });\n\n // Modify the AppDelegate based on configuration\n if (props?.pushNotification) {\n // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithPushAppDelegateHandler(config, props);\n });\n } else if (sdkConfig) {\n // Without push notifications: directly inject auto initialization into AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithNativeSDKInitializer(config);\n });\n } else {\n return configOuter;\n }\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithPushAppDelegateHandler = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n props: CustomerIOPluginOptionsIOS\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Add the handler property declaration\n let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n modifiedContent = modifyDidFinishLaunchingWithOptions(\n modifiedContent,\n ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `\n );\n\n // Add didRegisterForRemoteNotificationsWithDeviceToken implementation\n modifiedContent =\n addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);\n\n // Add didFailToRegisterForRemoteNotificationsWithError implementation\n modifiedContent =\n addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);\n\n // Add deep link handling for killed state if enabled\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);\n }\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithNativeSDKInitializer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n const modifiedContent = modifyDidFinishLaunchingWithOptions(\n appDelegateContent,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n );\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Check if a method exists in the AppDelegate content\n * @param content The AppDelegate content\n * @param methodSignature The method signature to check for\n * @returns true if the method exists, false otherwise\n */\nconst methodExistsInAppDelegate = (\n content: string,\n methodSignature: string\n): boolean => {\n return content.includes(methodSignature);\n};\n\n/**\n * Add handler property declaration to the AppDelegate class\n * This adds the line: let cioSdkHandler = CioSdkAppDelegateHandler()\n * to the AppDelegate class\n */\nconst addHandlerPropertyDeclaration = (content: string): string => {\n // Look for the AppDelegate class declaration\n const classDeclarationRegex = /class\\s+AppDelegate\\s*:\\s*.*\\s*{/;\n const match = content.match(classDeclarationRegex);\n\n if (!match) {\n logger.warn('Could not find AppDelegate class declaration');\n return content;\n }\n\n const position = (match.index ?? 0) + match[0].length;\n return (\n content.substring(0, position) +\n `\\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\\n` +\n content.substring(position)\n );\n};\n\n/**\n * Modify didFinishLaunchingWithOptions to inject Customer.io code\n * Injects the provided code (either handler call or auto initialization) before the return statement\n */\nconst modifyDidFinishLaunchingWithOptions = (content: string, codeToInject: string): string => {\n // Find the return statement in didFinishLaunchingWithOptions\n // Always look for launchOptions since modifiedLaunchOptions is only set later\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn(\n 'Could not find return statement with super.application in didFinishLaunchingWithOptions'\n );\n return content;\n }\n\n // Inject Customer.io code before the return statement\n const insertPosition = returnStatementMatch.index ?? 0;\n\n return (\n content.substring(0, insertPosition) +\n codeToInject +\n content.substring(insertPosition)\n );\n};\n\n/**\n * Add or modify didRegisterForRemoteNotificationsWithDeviceToken implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didRegisterForRemoteNotificationsWithDeviceToken\\s+deviceToken\\s*:\\s*Data\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle device token registration\\n' +\n ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add or modify didFailToRegisterForRemoteNotificationsWithError implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didFailToRegisterForRemoteNotificationsWithError\\s+error\\s*:\\s*Error\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle remote notification registration errors\\n' +\n ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add deep link handling for killed state\n * This replaces the return statement with deep link handling code\n * and a modified return statement that uses modifiedLaunchOptions\n */\nconst addHandleDeeplinkInKilledState = (content: string): string => {\n // Check if deep link code snippet is already present\n const deepLinkMarker = 'Deep link workaround for app killed state start';\n if (content.includes(deepLinkMarker)) {\n return content;\n }\n\n // Find the return statement with launchOptions\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn('Could not find return statement with launchOptions');\n return content;\n }\n\n // Create the replacement code with deep link handling and modified return statement\n const modifiedReturnStatement =\n 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';\n const replacementCode =\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET +\n '\\n\\n ' +\n modifiedReturnStatement;\n\n // Replace the return statement with deep link handling code and modified return statement\n return content.replace(returnStatementRegex, replacementCode);\n};\n"],"mappings":"AAIA,SAASA,eAAe,EAAEC,gBAAgB,QAAQ,sBAAsB;AAExE,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SACEC,+CAA+C,EAC/CC,0CAA0C,EAC1CC,8BAA8B,EAC9BC,iCAAiC,EACjCC,wCAAwC,EACxCC,0CAA0C,QACrC,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,yBAAyB,QAAQ,wCAAwC;AAMlF,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,eAAe,EAAEC,0BAA0B,QAAQ,gBAAgB;AAC5E,SAASC,iBAAiB,QAAQ,SAAS;;AAE3C;AACA,MAAMC,kCAAkC,GAAG,0BAA0B;AACrE,MAAMC,qCAAqC,GAAG,GAAGD,kCAAkC,QAAQ;;AAE3F;AACA;AACA;AACA,MAAME,kCAAkC,GAAGA,C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AAoB,EAAEY,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { withXcodeProject } from '@expo/config-plugins';
|
|
2
2
|
import { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
|
|
3
3
|
import { isFcmPushProvider } from './utils';
|
|
4
|
+
|
|
5
|
+
/** Props for the CIO Xcode project mod; push options are optional when only location is enabled. */
|
|
6
|
+
|
|
4
7
|
export const withCioXcodeProject = (config, cioProps) => {
|
|
5
8
|
return withXcodeProject(config, async props => {
|
|
6
9
|
const iosPath = props.modRequest.platformProjectRoot;
|
|
7
|
-
|
|
10
|
+
const podfileOptions = cioProps === null || cioProps === void 0 ? void 0 : cioProps.podfileOptions;
|
|
11
|
+
await injectCIOPodfileCode(iosPath, isFcmPushProvider(cioProps), podfileOptions);
|
|
8
12
|
return props;
|
|
9
13
|
});
|
|
10
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withXcodeProject","injectCIOPodfileCode","isFcmPushProvider","withCioXcodeProject","config","cioProps","props","iosPath","modRequest","platformProjectRoot"],"sources":["withXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {
|
|
1
|
+
{"version":3,"names":["withXcodeProject","injectCIOPodfileCode","isFcmPushProvider","withCioXcodeProject","config","cioProps","props","iosPath","modRequest","platformProjectRoot","podfileOptions"],"sources":["withXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {\n injectCIOPodfileCode,\n type InjectCIOPodfileOptions,\n} from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\n\nexport type WithCioXcodeProjectOptions = {\n /** Options for Podfile host app snippet (location subspec, etc.) */\n podfileOptions?: InjectCIOPodfileOptions;\n};\n\n/** Props for the CIO Xcode project mod; push options are optional when only location is enabled. */\nexport type WithCioXcodeProjectProps = Partial<CustomerIOPluginOptionsIOS> &\n WithCioXcodeProjectOptions;\n\nexport const withCioXcodeProject: ConfigPlugin<WithCioXcodeProjectProps> = (\n config,\n cioProps\n) => {\n return withXcodeProject(config, async (props) => {\n const iosPath = props.modRequest.platformProjectRoot;\n const podfileOptions = cioProps?.podfileOptions;\n\n await injectCIOPodfileCode(\n iosPath,\n isFcmPushProvider(cioProps as CustomerIOPluginOptionsIOS | undefined),\n podfileOptions\n );\n\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,sBAAsB;AAEvD,SACEC,oBAAoB,QAEf,uCAAuC;AAE9C,SAASC,iBAAiB,QAAQ,SAAS;;AAO3C;;AAIA,OAAO,MAAMC,mBAA2D,GAAGA,CACzEC,MAAM,EACNC,QAAQ,KACL;EACH,OAAOL,gBAAgB,CAACI,MAAM,EAAE,MAAOE,KAAK,IAAK;IAC/C,MAAMC,OAAO,GAAGD,KAAK,CAACE,UAAU,CAACC,mBAAmB;IACpD,MAAMC,cAAc,GAAGL,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEK,cAAc;IAE/C,MAAMT,oBAAoB,CACxBM,OAAO,EACPL,iBAAiB,CAACG,QAAkD,CAAC,EACrEK,cACF,CAAC;IAED,OAAOJ,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["/**\n * Properties set by the user in their app config file (e.g: app.json or app.plugin.js)\n * @public\n */\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n/**\n * Plugin options for iOS platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n\n useFrameworks?: 'static' | 'dynamic';\n\n pushNotification?: CustomerIOPluginPushNotificationOptions;\n\n /**\n * @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.\n */\n handleNotificationClick?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoFetchDeviceToken instead\n */\n autoFetchDeviceToken?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.showPushAppInForeground instead\n */\n showPushAppInForeground?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoTrackPushEvents instead\n */\n autoTrackPushEvents?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.handleDeeplinkInKilledState instead\n */\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.disableNotificationRegistration instead\n */\n disableNotificationRegistration?: boolean;\n};\n\n/**\n * Plugin options for Android platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n pushNotification?: {\n channel?: {\n id?: string;\n name?: string;\n importance?: number;\n };\n };\n /**\n * Controls whether to disable Android 16 support by downgrading androidx dependencies.\n *\n * When true (default for Expo SDK 53), forces older androidx versions compatible with\n * Android API 35 and AGP 8.8.2, preventing Android 16 incompatibility errors.\n *\n * When false (default for Expo SDK 54+), allows newer androidx versions that support Android 16\n * but require Android API 36 and AGP 8.9.1+.\n *\n * If not specified, the plugin auto-detects based on Expo SDK version:\n * - Expo SDK ≤53: true (disables Android 16)\n * - Expo SDK ≥54: false (enables Android 16)\n */\n disableAndroid16Support?: boolean;\n};\n\n/**\n * SDK configuration options for auto initialization\n * @public\n */\nexport type NativeSDKConfig = {\n cdpApiKey: string; // Required\n region?: 'US' | 'EU'; // Default: 'US'. The workspace region set for your workspace on the Customer.io dashboard\n autoTrackDeviceAttributes?: boolean; // Default: true\n trackApplicationLifecycleEvents?: boolean; // Default: true\n screenViewUse?: 'all' | 'inapp'; // Default: 'all'. 'all': sent to server + in-app messages, 'inapp': in-app messages only\n logLevel?: 'none' | 'error' | 'info' | 'debug'; // Default: 'debug'. Controls SDK logging verbosity\n siteId?: string; // Optional, if only siteId defined, migrationSiteId = siteId\n migrationSiteId?: string; // Optional, if only migrationSiteId defined, siteId should be null\n};\n\n/**\n * Combined plugin options for both iOS and Android platforms\n * @public\n */\nexport type CustomerIOPluginOptions = {\n config?: NativeSDKConfig; // If defined, enables auto initialization of native SDK\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n\n/**\n * Rich push configuration used to initialize Notification Service Extension (NSE) on the native side\n * @public\n */\nexport type RichPushConfig = {\n cdpApiKey: string;\n region?: string;\n};\n\n/**\n * Push notification configuration options\n * @public\n */\nexport type CustomerIOPluginPushNotificationOptions = {\n provider?: 'apn' | 'fcm';\n googleServicesFile?: string;\n useRichPush?: boolean;\n autoFetchDeviceToken?: boolean;\n autoTrackPushEvents?: boolean;\n showPushAppInForeground?: boolean;\n disableNotificationRegistration?: boolean;\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * Rich push config should match the values used to initialize SDK in the app.\n * Optional if `config` is provided at the top level.\n */\n env?: RichPushConfig;\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["/**\n * Properties set by the user in their app config file (e.g: app.json or app.plugin.js)\n * @public\n */\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n/**\n * Plugin options for iOS platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n\n useFrameworks?: 'static' | 'dynamic';\n\n pushNotification?: CustomerIOPluginPushNotificationOptions;\n\n /**\n * @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.\n */\n handleNotificationClick?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoFetchDeviceToken instead\n */\n autoFetchDeviceToken?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.showPushAppInForeground instead\n */\n showPushAppInForeground?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoTrackPushEvents instead\n */\n autoTrackPushEvents?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.handleDeeplinkInKilledState instead\n */\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.disableNotificationRegistration instead\n */\n disableNotificationRegistration?: boolean;\n};\n\n/**\n * Plugin options for Android platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n pushNotification?: {\n channel?: {\n id?: string;\n name?: string;\n importance?: number;\n };\n };\n /**\n * Controls whether to disable Android 16 support by downgrading androidx dependencies.\n *\n * When true (default for Expo SDK 53), forces older androidx versions compatible with\n * Android API 35 and AGP 8.8.2, preventing Android 16 incompatibility errors.\n *\n * When false (default for Expo SDK 54+), allows newer androidx versions that support Android 16\n * but require Android API 36 and AGP 8.9.1+.\n *\n * If not specified, the plugin auto-detects based on Expo SDK version:\n * - Expo SDK ≤53: true (disables Android 16)\n * - Expo SDK ≥54: false (enables Android 16)\n */\n disableAndroid16Support?: boolean;\n};\n\n/**\n * Location tracking mode for the Customer.io SDK location module.\n * Location is off by default. Only used when location is enabled (plugin option location.enabled: true).\n * @public\n */\nexport type LocationTrackingMode = 'OFF' | 'MANUAL' | 'ON_APP_START';\n\n/**\n * SDK configuration options for auto initialization\n * @public\n */\nexport type NativeSDKConfig = {\n cdpApiKey: string; // Required\n region?: 'US' | 'EU'; // Default: 'US'. The workspace region set for your workspace on the Customer.io dashboard\n autoTrackDeviceAttributes?: boolean; // Default: true\n trackApplicationLifecycleEvents?: boolean; // Default: true\n screenViewUse?: 'all' | 'inapp'; // Default: 'all'. 'all': sent to server + in-app messages, 'inapp': in-app messages only\n logLevel?: 'none' | 'error' | 'info' | 'debug'; // Default: 'debug'. Controls SDK logging verbosity\n siteId?: string; // Optional, if only siteId defined, migrationSiteId = siteId\n migrationSiteId?: string; // Optional, if only migrationSiteId defined, siteId should be null\n /**\n * Location module config. Location is off by default; only applied when plugin option location.enabled is true.\n * trackingMode: 'MANUAL' (host app controls when location is captured, default),\n * 'ON_APP_START' (SDK captures once per launch when app becomes active), or 'OFF'.\n */\n location?: {\n trackingMode?: LocationTrackingMode;\n };\n};\n\n/**\n * Location is off by default. When true, enables the Customer.io SDK location native module (iOS Podfile location subspec,\n * Android gradle.properties flag). Permissions and privacy keys (Info.plist, AndroidManifest)\n * remain the host app's responsibility.\n * @public\n */\nexport type CustomerIOPluginLocationOptions = {\n enabled?: boolean;\n};\n\n/**\n * Combined plugin options for both iOS and Android platforms\n * @public\n */\nexport type CustomerIOPluginOptions = {\n config?: NativeSDKConfig; // If defined, enables auto initialization of native SDK\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n /**\n * Location is off by default. When location.enabled is true, the plugin adds SDK build-time setup (Podfile location subspec,\n * gradle.properties). Host apps must add their own location permissions and privacy usage strings.\n */\n location?: CustomerIOPluginLocationOptions;\n};\n\n/**\n * Rich push configuration used to initialize Notification Service Extension (NSE) on the native side\n * @public\n */\nexport type RichPushConfig = {\n cdpApiKey: string;\n region?: string;\n};\n\n/**\n * Push notification configuration options\n * @public\n */\nexport type CustomerIOPluginPushNotificationOptions = {\n provider?: 'apn' | 'fcm';\n googleServicesFile?: string;\n useRichPush?: boolean;\n autoFetchDeviceToken?: boolean;\n autoTrackPushEvents?: boolean;\n showPushAppInForeground?: boolean;\n disableNotificationRegistration?: boolean;\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * Rich push config should match the values used to initialize SDK in the app.\n * Optional if `config` is provided at the top level.\n */\n env?: RichPushConfig;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ExpoConfig } from '@expo/config-types';
|
|
2
|
-
import type { CustomerIOPluginOptionsAndroid, NativeSDKConfig } from '../types/cio-types';
|
|
3
|
-
export declare function withCIOAndroid(config: ExpoConfig, sdkConfig?: NativeSDKConfig, props?: CustomerIOPluginOptionsAndroid): ExpoConfig;
|
|
2
|
+
import type { CustomerIOPluginOptionsAndroid, CustomerIOPluginLocationOptions, NativeSDKConfig } from '../types/cio-types';
|
|
3
|
+
export declare function withCIOAndroid(config: ExpoConfig, sdkConfig?: NativeSDKConfig, props?: CustomerIOPluginOptionsAndroid, location?: CustomerIOPluginLocationOptions): ExpoConfig;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import type { CustomerIOPluginLocationOptions } from '../types/cio-types';
|
|
3
|
+
/**
|
|
4
|
+
* Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.
|
|
5
|
+
* The Customer.io React Native SDK reads this to enable the location native module.
|
|
6
|
+
*/
|
|
7
|
+
export declare const withLocationGradleProperties: ConfigPlugin<{
|
|
8
|
+
location?: CustomerIOPluginLocationOptions;
|
|
9
|
+
}>;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
-
import type { NativeSDKConfig } from '../types/cio-types';
|
|
3
|
-
|
|
2
|
+
import type { CustomerIOPluginLocationOptions, NativeSDKConfig } from '../types/cio-types';
|
|
3
|
+
type MainApplicationModParams = {
|
|
4
|
+
sdkConfig: NativeSDKConfig;
|
|
5
|
+
location?: CustomerIOPluginLocationOptions;
|
|
6
|
+
};
|
|
7
|
+
export declare const withMainApplicationModifications: ConfigPlugin<MainApplicationModParams>;
|
|
8
|
+
export {};
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';
|
|
2
|
-
export
|
|
2
|
+
export type InjectCIOPodfileOptions = {
|
|
3
|
+
/** When true, add the location subspec. When false/omit, use single push subspec only. */
|
|
4
|
+
locationEnabled?: boolean;
|
|
5
|
+
/** When false and locationEnabled, inject only :subspecs => ['location']. When true, use push + location. */
|
|
6
|
+
hasPush?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/** Builds the host app pod line for the Podfile (single subspec or :subspecs with location). Exported for tests. */
|
|
9
|
+
export declare function buildHostAppPodSnippet(iosPath: string, isFcmPushProvider: boolean, options?: InjectCIOPodfileOptions): string;
|
|
10
|
+
export declare function injectCIOPodfileCode(iosPath: string, isFcmPushProvider: boolean, options?: InjectCIOPodfileOptions): Promise<void>;
|
|
3
11
|
export declare function injectCIONotificationPodfileCode(iosPath: string, useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'], isFcmPushProvider: boolean): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LocationTrackingMode } from '../../types/cio-types';
|
|
2
|
+
import { type Platform } from '../constants/common';
|
|
3
|
+
/** Options for location module in generated native initializer */
|
|
4
|
+
export type LocationInitOptions = {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
trackingMode?: LocationTrackingMode;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Replaces {{LOCATION_MODULE_IMPORT}} and {{LOCATION_MODULE_INIT}} placeholders
|
|
10
|
+
* in SDK initializer template content for the given platform.
|
|
11
|
+
*/
|
|
12
|
+
export declare function patchLocationPlaceholders(content: string, platform: Platform, locationOptions?: LocationInitOptions): string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { NativeSDKConfig } from '../../types/cio-types';
|
|
2
2
|
import { type Platform } from '../constants/common';
|
|
3
|
+
import { type LocationInitOptions } from './patchLocationCode';
|
|
4
|
+
export type { LocationInitOptions };
|
|
3
5
|
/**
|
|
4
6
|
* Shared utility function to perform common SDK config replacements
|
|
5
7
|
* for both iOS and Android template files
|
|
6
8
|
*/
|
|
7
|
-
export declare function patchNativeSDKInitializer(rawContent: string, platform: Platform, sdkConfig: NativeSDKConfig): string;
|
|
9
|
+
export declare function patchNativeSDKInitializer(rawContent: string, platform: Platform, sdkConfig: NativeSDKConfig, locationOptions?: LocationInitOptions): string;
|