customerio-expo-plugin 3.0.1 → 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
|
@@ -23,7 +23,7 @@ const CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CL
|
|
|
23
23
|
/**
|
|
24
24
|
* Copy and configure the CioSdkAppDelegateHandler.swift file
|
|
25
25
|
*/
|
|
26
|
-
const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props) => {
|
|
26
|
+
const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props, location) => {
|
|
27
27
|
// Destination path in the iOS project
|
|
28
28
|
const projectName = config.modRequest.projectName || '';
|
|
29
29
|
if (!projectName) {
|
|
@@ -44,7 +44,8 @@ const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props) => {
|
|
|
44
44
|
iosProjectRoot,
|
|
45
45
|
projectName,
|
|
46
46
|
sdkConfig,
|
|
47
|
-
props
|
|
47
|
+
props,
|
|
48
|
+
location
|
|
48
49
|
});
|
|
49
50
|
} else if (sdkConfig) {
|
|
50
51
|
// Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications
|
|
@@ -53,7 +54,8 @@ const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props) => {
|
|
|
53
54
|
group,
|
|
54
55
|
iosProjectRoot,
|
|
55
56
|
projectName,
|
|
56
|
-
sdkConfig
|
|
57
|
+
sdkConfig,
|
|
58
|
+
location
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
61
|
return config;
|
|
@@ -64,7 +66,8 @@ const copyAndConfigurePushAppDelegateHandler = ({
|
|
|
64
66
|
iosProjectRoot,
|
|
65
67
|
projectName,
|
|
66
68
|
sdkConfig,
|
|
67
|
-
props
|
|
69
|
+
props,
|
|
70
|
+
location
|
|
68
71
|
}) => {
|
|
69
72
|
var _props$pushNotificati, _props$pushNotificati2, _props$pushNotificati3, _props$pushNotificati4;
|
|
70
73
|
const useFcm = (0, _utils.isFcmPushProvider)(props);
|
|
@@ -100,7 +103,8 @@ const copyAndConfigurePushAppDelegateHandler = ({
|
|
|
100
103
|
group,
|
|
101
104
|
iosProjectRoot,
|
|
102
105
|
projectName,
|
|
103
|
-
sdkConfig
|
|
106
|
+
sdkConfig,
|
|
107
|
+
location
|
|
104
108
|
});
|
|
105
109
|
|
|
106
110
|
// Inject auto initialization call before MessagingPush initialization
|
|
@@ -113,8 +117,14 @@ const copyAndConfigureNativeSDKInitializer = ({
|
|
|
113
117
|
group,
|
|
114
118
|
iosProjectRoot,
|
|
115
119
|
projectName,
|
|
116
|
-
sdkConfig
|
|
120
|
+
sdkConfig,
|
|
121
|
+
location
|
|
117
122
|
}) => {
|
|
123
|
+
var _sdkConfig$location;
|
|
124
|
+
const locationOptions = location ? {
|
|
125
|
+
enabled: location.enabled === true,
|
|
126
|
+
trackingMode: sdkConfig === null || sdkConfig === void 0 || (_sdkConfig$location = sdkConfig.location) === null || _sdkConfig$location === void 0 ? void 0 : _sdkConfig$location.trackingMode
|
|
127
|
+
} : undefined;
|
|
118
128
|
const filename = 'CustomerIOSDKInitializer.swift';
|
|
119
129
|
const sourcePath = _path.default.join((0, _plugin.getIosNativeFilesPath)(), filename);
|
|
120
130
|
// Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler
|
|
@@ -124,14 +134,14 @@ const copyAndConfigureNativeSDKInitializer = ({
|
|
|
124
134
|
projectName,
|
|
125
135
|
sourceFilePath: sourcePath,
|
|
126
136
|
targetFileName: filename,
|
|
127
|
-
transform: content => (0, _patchPluginNativeCode.patchNativeSDKInitializer)(content, _common.PLATFORM.IOS, sdkConfig),
|
|
137
|
+
transform: content => (0, _patchPluginNativeCode.patchNativeSDKInitializer)(content, _common.PLATFORM.IOS, sdkConfig, locationOptions),
|
|
128
138
|
customerIOGroup: group
|
|
129
139
|
});
|
|
130
140
|
};
|
|
131
|
-
const withCIOIosSwift = (configOuter, sdkConfig, props) => {
|
|
141
|
+
const withCIOIosSwift = (configOuter, sdkConfig, props, location) => {
|
|
132
142
|
// First, copy required swift files to iOS folder and add it to Xcode project
|
|
133
143
|
configOuter = (0, _configPlugins.withXcodeProject)(configOuter, async config => {
|
|
134
|
-
return copyAndConfigureAppDelegateHandler(config, sdkConfig, props);
|
|
144
|
+
return copyAndConfigureAppDelegateHandler(config, sdkConfig, props, location);
|
|
135
145
|
});
|
|
136
146
|
|
|
137
147
|
// Modify the AppDelegate based on configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_path","_interopRequireDefault","_common","_ios","_codeInjection","_fileManagement","_patchPluginNativeCode","_logger","_plugin","_xcode","_utils","e","__esModule","default","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","projectName","modRequest","logger","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","path","join","group","getOrCreateCustomerIOGroup","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","useFcm","isFcmPushProvider","handlerSourcePath","getIosNativeFilesPath","handlerDestPath","FileManagement","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","replaceCodeByRegex","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","replace","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","writeFile","filename","sourcePath","copyFileToXcode","sourceFilePath","targetFileName","transform","content","patchNativeSDKInitializer","PLATFORM","IOS","customerIOGroup","withCIOIosSwift","configOuter","withXcodeProject","withAppDelegate","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","exports","_props$pushNotificati5","appDelegateContent","contents","includes","info","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","CIO_NATIVE_SDK_INITIALIZE_CALL","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET"],"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,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAQA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,sBAAA,GAAAP,OAAA;AAEA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAA4C,SAAAE,uBAAAU,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;A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B,CAAC,MAAM;IACL;IACA;IACA,MAAM0C,aAAa,GAAG,mBAAmB;IACzC,MAAMC,aAAa,GAAG3C,OAAO,CAAC4B,KAAK,CAACc,aAAa,CAAC;IAElD,IAAI,CAACC,aAAa,EAAE;MAClBzF,cAAM,CAACC,IAAI,CAAC,yCAAyC,CAAC;MACtD,OAAO6C,OAAO;IAChB;;IAEA;IACA,MAAM6B,QAAQ,GAAGc,aAAa,CAACb,KAAK,IAAI,CAAC;IACzC,OACE9B,OAAO,CAACgC,SAAS,CAAC,CAAC,EAAEH,QAAQ,CAAC,GAC9B,yDAAyD,GACzD,qIAAqI,GACrI,sCAAsC,GACtC,uGAAuG,GACvG,+FAA+F,GAC/F,OAAO,GACP7B,OAAO,CAACgC,SAAS,CAACH,QAAQ,CAAC;EAE/B;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMN,8BAA8B,GAAIvB,OAAe,IAAa;EAClE;EACA,MAAM4C,cAAc,GAAG,iDAAiD;EACxE,IAAI5C,OAAO,CAACe,QAAQ,CAAC6B,cAAc,CAAC,EAAE;IACpC,OAAO5C,OAAO;EAChB;;EAEA;EACA,MAAMkC,oBAAoB,GACxB,6GAA6G;EAC/G,MAAMC,oBAAoB,GAAGnC,OAAO,CAAC4B,KAAK,CAACM,oBAAoB,CAAC;EAEhE,IAAI,CAACC,oBAAoB,EAAE;IACzBjF,cAAM,CAACC,IAAI,CAAC,oDAAoD,CAAC;IACjE,OAAO6C,OAAO;EAChB;;EAEA;EACA,MAAM6C,uBAAuB,GAC3B,6FAA6F;EAC/F,MAAMC,eAAe,GACnBC,oDAA+C,GAC/C,UAAU,GACVF,uBAAuB;;EAEzB;EACA,OAAO7C,OAAO,CAACV,OAAO,CAAC4C,oBAAoB,EAAEY,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_path","_interopRequireDefault","_common","_ios","_codeInjection","_fileManagement","_patchPluginNativeCode","_logger","_plugin","_xcode","_utils","e","__esModule","default","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","location","projectName","modRequest","logger","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","path","join","group","getOrCreateCustomerIOGroup","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","useFcm","isFcmPushProvider","handlerSourcePath","getIosNativeFilesPath","handlerDestPath","FileManagement","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","replaceCodeByRegex","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","replace","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","writeFile","_sdkConfig$location","locationOptions","enabled","trackingMode","undefined","filename","sourcePath","copyFileToXcode","sourceFilePath","targetFileName","transform","content","patchNativeSDKInitializer","PLATFORM","IOS","customerIOGroup","withCIOIosSwift","configOuter","withXcodeProject","withAppDelegate","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","exports","_props$pushNotificati5","appDelegateContent","contents","includes","info","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","CIO_NATIVE_SDK_INITIALIZE_CALL","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET"],"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,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAQA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,sBAAA,GAAAP,OAAA;AAMA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAA4C,SAAAE,uBAAAU,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE5C;AACA,MAAMG,kCAAkC,GAAG,0BAA0B;AACrE,MAAMC,qCAAqC,GAAG,GAAGD,kCAAkC,QAAQ;;AAE3F;AACA;AACA;AACA,MAAME,kCAAkC,GAAGA,CACzCC,MAA6C,EAC7CC,SAA2B,EAC3BC,KAAkC,EAClCC,QAA0C,KACA;EAC1C;EACA,MAAMC,WAAW,GAAGJ,MAAM,CAACK,UAAU,CAACD,WAAW,IAAI,EAAE;EACvD,IAAI,CAACA,WAAW,EAAE;IAChBE,cAAM,CAACC,IAAI,CACT,yDACF,CAAC;IACD,OAAOP,MAAM;EACf;;EAEA;EACA,MAAMQ,YAAY,GAAGR,MAAM,CAACS,UAAU;EACtC,MAAMC,WAAW,GAAGV,MAAM,CAACK,UAAU,CAACK,WAAW;EACjD,MAAMC,cAAc,GAAGC,aAAI,CAACC,IAAI,CAACH,WAAW,EAAE,KAAK,CAAC;EAEpD,MAAMI,KAAK,GAAG,IAAAC,iCAA0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AAOkD,OAAO;IAChB;;IAEA;IACA,MAAM6B,QAAQ,GAAGc,aAAa,CAACb,KAAK,IAAI,CAAC;IACzC,OACE9B,OAAO,CAACgC,SAAS,CAAC,CAAC,EAAEH,QAAQ,CAAC,GAC9B,yDAAyD,GACzD,qIAAqI,GACrI,sCAAsC,GACtC,uGAAuG,GACvG,+FAA+F,GAC/F,OAAO,GACP7B,OAAO,CAACgC,SAAS,CAACH,QAAQ,CAAC;EAE/B;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMN,8BAA8B,GAAIvB,OAAe,IAAa;EAClE;EACA,MAAM4C,cAAc,GAAG,iDAAiD;EACxE,IAAI5C,OAAO,CAACe,QAAQ,CAAC6B,cAAc,CAAC,EAAE;IACpC,OAAO5C,OAAO;EAChB;;EAEA;EACA,MAAMkC,oBAAoB,GACxB,6GAA6G;EAC/G,MAAMC,oBAAoB,GAAGnC,OAAO,CAAC4B,KAAK,CAACM,oBAAoB,CAAC;EAEhE,IAAI,CAACC,oBAAoB,EAAE;IACzBtF,cAAM,CAACC,IAAI,CAAC,oDAAoD,CAAC;IACjE,OAAOkD,OAAO;EAChB;;EAEA;EACA,MAAM6C,uBAAuB,GAC3B,6FAA6F;EAC/F,MAAMC,eAAe,GACnBC,oDAA+C,GAC/C,UAAU,GACVF,uBAAuB;;EAEzB;EACA,OAAO7C,OAAO,CAACf,OAAO,CAACiD,oBAAoB,EAAEY,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
|
|
@@ -7,10 +7,13 @@ exports.withCioXcodeProject = void 0;
|
|
|
7
7
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
8
|
var _injectCIOPodfileCode = require("../helpers/utils/injectCIOPodfileCode");
|
|
9
9
|
var _utils = require("./utils");
|
|
10
|
+
/** Props for the CIO Xcode project mod; push options are optional when only location is enabled. */
|
|
11
|
+
|
|
10
12
|
const withCioXcodeProject = (config, cioProps) => {
|
|
11
13
|
return (0, _configPlugins.withXcodeProject)(config, async props => {
|
|
12
14
|
const iosPath = props.modRequest.platformProjectRoot;
|
|
13
|
-
|
|
15
|
+
const podfileOptions = cioProps === null || cioProps === void 0 ? void 0 : cioProps.podfileOptions;
|
|
16
|
+
await (0, _injectCIOPodfileCode.injectCIOPodfileCode)(iosPath, (0, _utils.isFcmPushProvider)(cioProps), podfileOptions);
|
|
14
17
|
return props;
|
|
15
18
|
});
|
|
16
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_injectCIOPodfileCode","_utils","withCioXcodeProject","config","cioProps","withXcodeProject","props","iosPath","modRequest","platformProjectRoot","injectCIOPodfileCode","isFcmPushProvider","exports"],"sources":["withXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_injectCIOPodfileCode","_utils","withCioXcodeProject","config","cioProps","withXcodeProject","props","iosPath","modRequest","platformProjectRoot","podfileOptions","injectCIOPodfileCode","isFcmPushProvider","exports"],"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,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,qBAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AAOA;;AAIO,MAAMG,mBAA2D,GAAGA,CACzEC,MAAM,EACNC,QAAQ,KACL;EACH,OAAO,IAAAC,+BAAgB,EAACF,MAAM,EAAE,MAAOG,KAAK,IAAK;IAC/C,MAAMC,OAAO,GAAGD,KAAK,CAACE,UAAU,CAACC,mBAAmB;IACpD,MAAMC,cAAc,GAAGN,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM,cAAc;IAE/C,MAAM,IAAAC,0CAAoB,EACxBJ,OAAO,EACP,IAAAK,wBAAiB,EAACR,QAAkD,CAAC,EACrEM,cACF,CAAC;IAED,OAAOJ,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACO,OAAA,CAAAX,mBAAA,GAAAA,mBAAA","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,12 +1,13 @@
|
|
|
1
1
|
import { withAndroidManifestUpdates } from './withAndroidManifestUpdates';
|
|
2
2
|
import { withAppGoogleServices } from './withAppGoogleServices';
|
|
3
3
|
import { withGoogleServicesJSON } from './withGoogleServicesJSON';
|
|
4
|
+
import { withLocationGradleProperties } from './withLocationGradleProperties';
|
|
4
5
|
import { withMainApplicationModifications } from './withMainApplicationModifications';
|
|
5
6
|
import { withNotificationChannelMetadata } from './withNotificationChannelMetadata';
|
|
6
7
|
import { withProjectBuildGradle } from './withProjectBuildGradle';
|
|
7
8
|
import { withProjectGoogleServices } from './withProjectGoogleServices';
|
|
8
9
|
import { withProjectStrings } from './withProjectStrings';
|
|
9
|
-
export function withCIOAndroid(config, sdkConfig, props) {
|
|
10
|
+
export function withCIOAndroid(config, sdkConfig, props, location) {
|
|
10
11
|
// Only run notification setup if props are provided
|
|
11
12
|
if (props) {
|
|
12
13
|
var _props$pushNotificati;
|
|
@@ -23,7 +24,10 @@ export function withCIOAndroid(config, sdkConfig, props) {
|
|
|
23
24
|
|
|
24
25
|
// Add auto initialization if sdkConfig is provided
|
|
25
26
|
if (sdkConfig) {
|
|
26
|
-
config = withMainApplicationModifications(config,
|
|
27
|
+
config = withMainApplicationModifications(config, {
|
|
28
|
+
sdkConfig,
|
|
29
|
+
location
|
|
30
|
+
});
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
// Update project strings for user agent metadata
|
|
@@ -32,6 +36,13 @@ export function withCIOAndroid(config, sdkConfig, props) {
|
|
|
32
36
|
// Add dependency resolution strategy for Expo SDK 53 compatibility
|
|
33
37
|
// This prevents androidx versions that require API 36 from being pulled in
|
|
34
38
|
config = withProjectBuildGradle(config, props);
|
|
39
|
+
|
|
40
|
+
// Enable SDK location module when location.enabled is true
|
|
41
|
+
if ((location === null || location === void 0 ? void 0 : location.enabled) === true) {
|
|
42
|
+
config = withLocationGradleProperties(config, {
|
|
43
|
+
location
|
|
44
|
+
});
|
|
45
|
+
}
|
|
35
46
|
return config;
|
|
36
47
|
}
|
|
37
48
|
//# sourceMappingURL=withCIOAndroid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAndroidManifestUpdates","withAppGoogleServices","withGoogleServicesJSON","withMainApplicationModifications","withNotificationChannelMetadata","withProjectBuildGradle","withProjectGoogleServices","withProjectStrings","withCIOAndroid","config","sdkConfig","props","_props$pushNotificati","setHighPriorityPushHandler","undefined","pushNotification","channel"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type {
|
|
1
|
+
{"version":3,"names":["withAndroidManifestUpdates","withAppGoogleServices","withGoogleServicesJSON","withLocationGradleProperties","withMainApplicationModifications","withNotificationChannelMetadata","withProjectBuildGradle","withProjectGoogleServices","withProjectStrings","withCIOAndroid","config","sdkConfig","props","location","_props$pushNotificati","setHighPriorityPushHandler","undefined","pushNotification","channel","enabled"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type {\n CustomerIOPluginOptionsAndroid,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { withAndroidManifestUpdates } from './withAndroidManifestUpdates';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withLocationGradleProperties } from './withLocationGradleProperties';\nimport { withMainApplicationModifications } from './withMainApplicationModifications';\nimport { withNotificationChannelMetadata } from './withNotificationChannelMetadata';\nimport { withProjectBuildGradle } from './withProjectBuildGradle';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\nimport { withProjectStrings } from './withProjectStrings';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsAndroid,\n location?: CustomerIOPluginLocationOptions,\n): ExpoConfig {\n // Only run notification setup if props are provided\n if (props) {\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n if (props.setHighPriorityPushHandler !== undefined) {\n config = withAndroidManifestUpdates(config, props);\n }\n if (props.pushNotification?.channel) {\n config = withNotificationChannelMetadata(config, props);\n }\n }\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n config = withMainApplicationModifications(config, { sdkConfig, location });\n }\n\n // Update project strings for user agent metadata\n config = withProjectStrings(config);\n\n // Add dependency resolution strategy for Expo SDK 53 compatibility\n // This prevents androidx versions that require API 36 from being pulled in\n config = withProjectBuildGradle(config, props);\n\n // Enable SDK location module when location.enabled is true\n if (location?.enabled === true) {\n config = withLocationGradleProperties(config, { location });\n }\n\n return config;\n}\n"],"mappings":"AAOA,SAASA,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,gCAAgC,QAAQ,oCAAoC;AACrF,SAASC,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,kBAAkB,QAAQ,sBAAsB;AAEzD,OAAO,SAASC,cAAcA,CAC5BC,MAAkB,EAClBC,SAA2B,EAC3BC,KAAsC,EACtCC,QAA0C,EAC9B;EACZ;EACA,IAAID,KAAK,EAAE;IAAA,IAAAE,qBAAA;IACTJ,MAAM,GAAGH,yBAAyB,CAACG,MAAM,EAAEE,KAAK,CAAC;IACjDF,MAAM,GAAGT,qBAAqB,CAACS,MAAM,EAAEE,KAAK,CAAC;IAC7CF,MAAM,GAAGR,sBAAsB,CAACQ,MAAM,EAAEE,KAAK,CAAC;IAC9C,IAAIA,KAAK,CAACG,0BAA0B,KAAKC,SAAS,EAAE;MAClDN,MAAM,GAAGV,0BAA0B,CAACU,MAAM,EAAEE,KAAK,CAAC;IACpD;IACA,KAAAE,qBAAA,GAAIF,KAAK,CAACK,gBAAgB,cAAAH,qBAAA,eAAtBA,qBAAA,CAAwBI,OAAO,EAAE;MACnCR,MAAM,GAAGL,+BAA+B,CAACK,MAAM,EAAEE,KAAK,CAAC;IACzD;EACF;;EAEA;EACA,IAAID,SAAS,EAAE;IACbD,MAAM,GAAGN,gCAAgC,CAACM,MAAM,EAAE;MAAEC,SAAS;MAAEE;IAAS,CAAC,CAAC;EAC5E;;EAEA;EACAH,MAAM,GAAGF,kBAAkB,CAACE,MAAM,CAAC;;EAEnC;EACA;EACAA,MAAM,GAAGJ,sBAAsB,CAACI,MAAM,EAAEE,KAAK,CAAC;;EAE9C;EACA,IAAI,CAAAC,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM,OAAO,MAAK,IAAI,EAAE;IAC9BT,MAAM,GAAGP,4BAA4B,CAACO,MAAM,EAAE;MAAEG;IAAS,CAAC,CAAC;EAC7D;EAEA,OAAOH,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { withGradleProperties } from '@expo/config-plugins';
|
|
2
|
+
const CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.
|
|
6
|
+
* The Customer.io React Native SDK reads this to enable the location native module.
|
|
7
|
+
*/
|
|
8
|
+
export const withLocationGradleProperties = (config, props) => {
|
|
9
|
+
var _props$location;
|
|
10
|
+
if ((props === null || props === void 0 || (_props$location = props.location) === null || _props$location === void 0 ? void 0 : _props$location.enabled) !== true) {
|
|
11
|
+
return config;
|
|
12
|
+
}
|
|
13
|
+
return withGradleProperties(config, config => {
|
|
14
|
+
const items = config.modResults;
|
|
15
|
+
const existingIndex = items.findIndex(item => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY);
|
|
16
|
+
const newItem = {
|
|
17
|
+
type: 'property',
|
|
18
|
+
key: CUSTOMERIO_LOCATION_ENABLED_KEY,
|
|
19
|
+
value: 'true'
|
|
20
|
+
};
|
|
21
|
+
if (existingIndex >= 0) {
|
|
22
|
+
items[existingIndex] = newItem;
|
|
23
|
+
} else {
|
|
24
|
+
items.push(newItem);
|
|
25
|
+
}
|
|
26
|
+
config.modResults = items;
|
|
27
|
+
return config;
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=withLocationGradleProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withGradleProperties","CUSTOMERIO_LOCATION_ENABLED_KEY","withLocationGradleProperties","config","props","_props$location","location","enabled","items","modResults","existingIndex","findIndex","item","type","key","newItem","value","push"],"sources":["withLocationGradleProperties.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withGradleProperties } from '@expo/config-plugins';\nimport type { PropertiesItem } from '@expo/config-plugins/build/android/Properties';\n\nimport type { CustomerIOPluginLocationOptions } from '../types/cio-types';\n\nconst CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';\n\n/**\n * Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.\n * The Customer.io React Native SDK reads this to enable the location native module.\n */\nexport const withLocationGradleProperties: ConfigPlugin<{\n location?: CustomerIOPluginLocationOptions;\n}> = (config, props) => {\n if (props?.location?.enabled !== true) {\n return config;\n }\n\n return withGradleProperties(config, (config) => {\n const items = config.modResults as PropertiesItem[];\n const existingIndex = items.findIndex(\n (item) => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY\n );\n\n const newItem: PropertiesItem = {\n type: 'property',\n key: CUSTOMERIO_LOCATION_ENABLED_KEY,\n value: 'true',\n };\n\n if (existingIndex >= 0) {\n items[existingIndex] = newItem;\n } else {\n items.push(newItem);\n }\n\n config.modResults = items;\n return config;\n });\n};\n"],"mappings":"AACA,SAASA,oBAAoB,QAAQ,sBAAsB;AAK3D,MAAMC,+BAA+B,GAAG,6BAA6B;;AAErE;AACA;AACA;AACA;AACA,OAAO,MAAMC,4BAEX,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EAAA,IAAAC,eAAA;EACtB,IAAI,CAAAD,KAAK,aAALA,KAAK,gBAAAC,eAAA,GAALD,KAAK,CAAEE,QAAQ,cAAAD,eAAA,uBAAfA,eAAA,CAAiBE,OAAO,MAAK,IAAI,EAAE;IACrC,OAAOJ,MAAM;EACf;EAEA,OAAOH,oBAAoB,CAACG,MAAM,EAAGA,MAAM,IAAK;IAC9C,MAAMK,KAAK,GAAGL,MAAM,CAACM,UAA8B;IACnD,MAAMC,aAAa,GAAGF,KAAK,CAACG,SAAS,CAClCC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,UAAU,IAAID,IAAI,CAACE,GAAG,KAAKb,+BACrD,CAAC;IAED,MAAMc,OAAuB,GAAG;MAC9BF,IAAI,EAAE,UAAU;MAChBC,GAAG,EAAEb,+BAA+B;MACpCe,KAAK,EAAE;IACT,CAAC;IAED,IAAIN,aAAa,IAAI,CAAC,EAAE;MACtBF,KAAK,CAACE,aAAa,CAAC,GAAGK,OAAO;IAChC,CAAC,MAAM;MACLP,KAAK,CAACS,IAAI,CAACF,OAAO,CAAC;IACrB;IAEAZ,MAAM,CAACM,UAAU,GAAGD,KAAK;IACzB,OAAOL,MAAM;EACf,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -4,26 +4,42 @@ import { PLATFORM } from '../helpers/constants/common';
|
|
|
4
4
|
import { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';
|
|
5
5
|
import { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';
|
|
6
6
|
import { logger } from '../utils/logger';
|
|
7
|
-
export const withMainApplicationModifications = (configOuter,
|
|
7
|
+
export const withMainApplicationModifications = (configOuter, {
|
|
8
|
+
sdkConfig,
|
|
9
|
+
location
|
|
10
|
+
}) => {
|
|
8
11
|
return withMainApplication(configOuter, async config => {
|
|
9
|
-
const content = setupCustomerIOSDKInitializer(config, sdkConfig);
|
|
12
|
+
const content = setupCustomerIOSDKInitializer(config, sdkConfig, location);
|
|
10
13
|
config.modResults.contents = content;
|
|
11
14
|
return config;
|
|
12
15
|
});
|
|
13
16
|
};
|
|
14
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Build location options for native initializer from plugin config.
|
|
20
|
+
* trackingMode comes from config.location.trackingMode (only used when location.enabled is true).
|
|
21
|
+
*/
|
|
22
|
+
const getLocationInitOptions = (location, sdkConfig) => {
|
|
23
|
+
var _sdkConfig$location;
|
|
24
|
+
return {
|
|
25
|
+
enabled: (location === null || location === void 0 ? void 0 : location.enabled) === true,
|
|
26
|
+
trackingMode: sdkConfig === null || sdkConfig === void 0 || (_sdkConfig$location = sdkConfig.location) === null || _sdkConfig$location === void 0 ? void 0 : _sdkConfig$location.trackingMode
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
15
30
|
/**
|
|
16
31
|
* Setup CustomerIOSDKInitializer for Android auto initialization
|
|
17
32
|
*/
|
|
18
|
-
const setupCustomerIOSDKInitializer = (config, sdkConfig) => {
|
|
33
|
+
const setupCustomerIOSDKInitializer = (config, sdkConfig, location) => {
|
|
19
34
|
const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
|
|
20
35
|
const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
|
|
21
36
|
const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
|
|
22
37
|
const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
|
|
38
|
+
const locationOptions = getLocationInitOptions(location, sdkConfig);
|
|
23
39
|
let content = config.modResults.contents;
|
|
24
40
|
try {
|
|
25
41
|
// Always regenerate the CustomerIOSDKInitializer file to reflect config changes
|
|
26
|
-
copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig));
|
|
42
|
+
copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig, locationOptions));
|
|
27
43
|
// Add import if not already present
|
|
28
44
|
content = addImportToFile(content, SDK_INITIALIZER_IMPORT);
|
|
29
45
|
// Add initialization code to onCreate if not already present
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withMainApplication","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","PLATFORM","patchNativeSDKInitializer","addCodeToMethod","addImportToFile","copyTemplateFile","logger","withMainApplicationModifications","configOuter","sdkConfig","config","content","setupCustomerIOSDKInitializer","modResults","contents","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","ANDROID","includes","error","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {
|
|
1
|
+
{"version":3,"names":["withMainApplication","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","PLATFORM","patchNativeSDKInitializer","addCodeToMethod","addImportToFile","copyTemplateFile","logger","withMainApplicationModifications","configOuter","sdkConfig","location","config","content","setupCustomerIOSDKInitializer","modResults","contents","getLocationInitOptions","_sdkConfig$location","enabled","trackingMode","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","locationOptions","ANDROID","includes","error","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';\nimport { logger } from '../utils/logger';\n\ntype MainApplicationModParams = {\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n};\n\nexport const withMainApplicationModifications: ConfigPlugin<MainApplicationModParams> = (configOuter, { sdkConfig, location }) => {\n return withMainApplication(configOuter, async (config) => {\n const content = setupCustomerIOSDKInitializer(config, sdkConfig, location);\n config.modResults.contents = content;\n return config;\n });\n};\n\n/**\n * Build location options for native initializer from plugin config.\n * trackingMode comes from config.location.trackingMode (only used when location.enabled is true).\n */\nconst getLocationInitOptions = (\n location?: CustomerIOPluginLocationOptions,\n sdkConfig?: NativeSDKConfig\n) => ({\n enabled: location?.enabled === true,\n trackingMode: sdkConfig?.location?.trackingMode,\n});\n\n/**\n * Setup CustomerIOSDKInitializer for Android auto initialization\n */\nconst setupCustomerIOSDKInitializer = (\n config: ExportedConfigWithProps<ApplicationProjectFile>,\n sdkConfig: NativeSDKConfig,\n location?: CustomerIOPluginLocationOptions,\n): string => {\n const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';\n const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';\n\n const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;\n const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;\n\n const locationOptions = getLocationInitOptions(location, sdkConfig);\n let content = config.modResults.contents;\n\n try {\n // Always regenerate the CustomerIOSDKInitializer file to reflect config changes\n copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>\n patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig, locationOptions)\n );\n // Add import if not already present\n content = addImportToFile(content, SDK_INITIALIZER_IMPORT);\n // Add initialization code to onCreate if not already present\n if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);\n }\n } catch (error) {\n logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);\n return config.modResults.contents;\n }\n\n return content;\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAE1D,SAASC,kCAAkC,EAAEC,8BAA8B,EAAEC,iCAAiC,QAAQ,8BAA8B;AACpJ,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SAASC,yBAAyB,QAAQ,wCAAwC;AAKlF,SAASC,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,QAAQ,kBAAkB;AACrF,SAASC,MAAM,QAAQ,iBAAiB;AAOxC,OAAO,MAAMC,gCAAwE,GAAGA,CAACC,WAAW,EAAE;EAAEC,SAAS;EAAEC;AAAS,CAAC,KAAK;EAChI,OAAOb,mBAAmB,CAACW,WAAW,EAAE,MAAOG,MAAM,IAAK;IACxD,MAAMC,OAAO,GAAGC,6BAA6B,CAACF,MAAM,EAAEF,SAAS,EAAEC,QAAQ,CAAC;IAC1EC,MAA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,CAAC;IAC3G;EACF,CAAC,CAAC,OAAO2B,KAAK,EAAE;IACdrB,MAAM,CAACsB,IAAI,CAAC,mBAAmBR,qBAAqB,GAAG,EAAEO,KAAK,CAAC;IAC/D,OAAOhB,MAAM,CAACG,UAAU,CAACC,QAAQ;EACnC;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ import io.customer.messaginginapp.ModuleMessagingInApp
|
|
|
7
7
|
import io.customer.messagingpush.MessagingPushModuleConfig
|
|
8
8
|
import io.customer.messagingpush.ModuleMessagingPushFCM
|
|
9
9
|
import io.customer.reactnative.sdk.messaginginapp.ReactInAppEventListener
|
|
10
|
+
{{LOCATION_MODULE_IMPORT}}
|
|
10
11
|
import io.customer.sdk.CustomerIOBuilder
|
|
11
12
|
import io.customer.sdk.core.util.CioLogLevel
|
|
12
13
|
import io.customer.sdk.data.model.Region
|
|
@@ -41,6 +42,7 @@ object CustomerIOSDKInitializer {
|
|
|
41
42
|
MessagingPushModuleConfig.Builder().build()
|
|
42
43
|
)
|
|
43
44
|
)
|
|
45
|
+
{{LOCATION_MODULE_INIT}}
|
|
44
46
|
|
|
45
47
|
build()
|
|
46
48
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import CioDataPipelines
|
|
2
2
|
import CioInternalCommon
|
|
3
3
|
import CioMessagingInApp
|
|
4
|
+
{{LOCATION_MODULE_IMPORT}}
|
|
4
5
|
|
|
5
6
|
class CustomerIOSDKInitializer {
|
|
6
7
|
static func initialize() {
|
|
@@ -23,6 +24,7 @@ class CustomerIOSDKInitializer {
|
|
|
23
24
|
setIfDefined(value: {{SCREEN_VIEW_USE}}, thenPassItTo: builder.screenViewUse) { ScreenView.getScreenView($0) }
|
|
24
25
|
setIfDefined(value: {{MIGRATION_SITE_ID}}, thenPassItTo: builder.migrationSiteId)
|
|
25
26
|
|
|
27
|
+
{{LOCATION_MODULE_INIT}}
|
|
26
28
|
CustomerIO.initialize(withConfig: builder.build())
|
|
27
29
|
|
|
28
30
|
if let siteId = siteId {
|
|
@@ -2,7 +2,22 @@ import { logger } from '../../utils/logger';
|
|
|
2
2
|
import { getRelativePathToRNSDK } from '../constants/ios';
|
|
3
3
|
import { injectCodeByRegex } from './codeInjection';
|
|
4
4
|
import { FileManagement } from './fileManagement';
|
|
5
|
-
|
|
5
|
+
/** Builds the host app pod line for the Podfile (single subspec or :subspecs with location). Exported for tests. */
|
|
6
|
+
export function buildHostAppPodSnippet(iosPath, isFcmPushProvider, options) {
|
|
7
|
+
const path = getRelativePathToRNSDK(iosPath);
|
|
8
|
+
const locationEnabled = (options === null || options === void 0 ? void 0 : options.locationEnabled) === true;
|
|
9
|
+
const hasPush = (options === null || options === void 0 ? void 0 : options.hasPush) !== false;
|
|
10
|
+
if (!locationEnabled) {
|
|
11
|
+
const subspec = isFcmPushProvider ? 'fcm' : 'apn';
|
|
12
|
+
return `pod 'customerio-reactnative/${subspec}', :path => '${path}'`;
|
|
13
|
+
}
|
|
14
|
+
if (!hasPush) {
|
|
15
|
+
return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${path}'`;
|
|
16
|
+
}
|
|
17
|
+
const pushSubspec = isFcmPushProvider ? 'fcm' : 'apn';
|
|
18
|
+
return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${path}'`;
|
|
19
|
+
}
|
|
20
|
+
export async function injectCIOPodfileCode(iosPath, isFcmPushProvider, options) {
|
|
6
21
|
const blockStart = '# --- CustomerIO Host App START ---';
|
|
7
22
|
const blockEnd = '# --- CustomerIO Host App END ---';
|
|
8
23
|
const filename = `${iosPath}/Podfile`;
|
|
@@ -13,9 +28,10 @@ export async function injectCIOPodfileCode(iosPath, isFcmPushProvider) {
|
|
|
13
28
|
// The "post_install" line is always present in an Expo project Podfile so it's reliable.
|
|
14
29
|
// Find that line in the Podfile and then we will insert our code above that line.
|
|
15
30
|
const lineInPodfileToInjectSnippetBefore = /post_install do \|installer\|/;
|
|
31
|
+
const podLine = buildHostAppPodSnippet(iosPath, isFcmPushProvider, options);
|
|
16
32
|
const snippetToInjectInPodfile = `
|
|
17
33
|
${blockStart}
|
|
18
|
-
|
|
34
|
+
${podLine}
|
|
19
35
|
${blockEnd}
|
|
20
36
|
`.trim();
|
|
21
37
|
FileManagement.write(filename, injectCodeByRegex(podfile, lineInPodfileToInjectSnippetBefore, snippetToInjectInPodfile).join('\n'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["logger","getRelativePathToRNSDK","injectCodeByRegex","FileManagement","
|
|
1
|
+
{"version":3,"names":["logger","getRelativePathToRNSDK","injectCodeByRegex","FileManagement","buildHostAppPodSnippet","iosPath","isFcmPushProvider","options","path","locationEnabled","hasPush","subspec","pushSubspec","injectCIOPodfileCode","blockStart","blockEnd","filename","podfile","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","podLine","snippetToInjectInPodfile","trim","write","join","info","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { logger } from '../../utils/logger';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport type InjectCIOPodfileOptions = {\n /** When true, add the location subspec. When false/omit, use single push subspec only. */\n locationEnabled?: boolean;\n /** When false and locationEnabled, inject only :subspecs => ['location']. When true, use push + location. */\n hasPush?: boolean;\n};\n\n/** Builds the host app pod line for the Podfile (single subspec or :subspecs with location). Exported for tests. */\nexport function buildHostAppPodSnippet(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n): string {\n const path = getRelativePathToRNSDK(iosPath);\n const locationEnabled = options?.locationEnabled === true;\n const hasPush = options?.hasPush !== false;\n\n if (!locationEnabled) {\n const subspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative/${subspec}', :path => '${path}'`;\n }\n\n if (!hasPush) {\n return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${path}'`;\n }\n\n const pushSubspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${path}'`;\n}\n\nexport async function injectCIOPodfileCode(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const podLine = buildHostAppPodSnippet(iosPath, isFcmPushProvider, options);\n\n const snippetToInjectInPodfile = `\n${blockStart}\n ${podLine}\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n logger.info('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],\n isFcmPushProvider: boolean\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/${isFcmPushProvider ? 'fcm' : 'apn'\n }', :path => '${getRelativePathToRNSDK(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