customerio-expo-plugin 2.5.0 → 2.7.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.
Files changed (162) hide show
  1. package/package.json +13 -31
  2. package/plugin/app.plugin.js +1 -1
  3. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +56 -15
  4. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
  5. package/plugin/lib/commonjs/android/withCIOAndroid.js +7 -2
  6. package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
  7. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +1 -1
  8. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  9. package/plugin/lib/commonjs/android/withMainApplicationModifications.js +45 -0
  10. package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -0
  11. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +1 -1
  12. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
  13. package/plugin/lib/commonjs/android/withProjectStrings.js +14 -7
  14. package/plugin/lib/commonjs/android/withProjectStrings.js.map +1 -1
  15. package/plugin/lib/commonjs/helpers/constants/android.js +7 -1
  16. package/plugin/lib/commonjs/helpers/constants/android.js.map +1 -1
  17. package/plugin/lib/commonjs/helpers/constants/common.js +18 -0
  18. package/plugin/lib/commonjs/helpers/constants/common.js.map +1 -0
  19. package/plugin/lib/commonjs/helpers/constants/ios.js +7 -7
  20. package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
  21. package/plugin/lib/commonjs/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
  22. package/plugin/lib/commonjs/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
  23. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +2 -2
  24. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  25. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +62 -0
  26. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -0
  27. package/plugin/lib/commonjs/index.js +13 -2
  28. package/plugin/lib/commonjs/index.js.map +1 -1
  29. package/plugin/lib/commonjs/ios/utils.js +1 -1
  30. package/plugin/lib/commonjs/ios/utils.js.map +1 -1
  31. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +1 -1
  32. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  33. package/plugin/lib/commonjs/ios/withCIOIos.js +17 -11
  34. package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
  35. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +133 -49
  36. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  37. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +1 -1
  38. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
  39. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +17 -19
  40. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  41. package/plugin/lib/commonjs/ios/withXcodeProject.js +1 -1
  42. package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
  43. package/plugin/lib/commonjs/postInstallHelper.js.map +1 -1
  44. package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
  45. package/plugin/lib/commonjs/utils/android.js +109 -0
  46. package/plugin/lib/commonjs/utils/android.js.map +1 -0
  47. package/plugin/lib/commonjs/utils/config.js +43 -0
  48. package/plugin/lib/commonjs/utils/config.js.map +1 -0
  49. package/plugin/lib/commonjs/utils/plugin.js +49 -0
  50. package/plugin/lib/commonjs/utils/plugin.js.map +1 -0
  51. package/plugin/lib/commonjs/utils/validation.js +44 -0
  52. package/plugin/lib/commonjs/utils/validation.js.map +1 -0
  53. package/plugin/lib/commonjs/utils/xcode.js +67 -0
  54. package/plugin/lib/commonjs/utils/xcode.js.map +1 -0
  55. package/plugin/lib/module/android/withAndroidManifestUpdates.js +55 -14
  56. package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
  57. package/plugin/lib/module/android/withCIOAndroid.js +7 -2
  58. package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
  59. package/plugin/lib/module/android/withGoogleServicesJSON.js +1 -1
  60. package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  61. package/plugin/lib/module/android/withMainApplicationModifications.js +38 -0
  62. package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -0
  63. package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
  64. package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
  65. package/plugin/lib/module/android/withProjectStrings.js +13 -6
  66. package/plugin/lib/module/android/withProjectStrings.js.map +1 -1
  67. package/plugin/lib/module/helpers/constants/android.js +6 -0
  68. package/plugin/lib/module/helpers/constants/android.js.map +1 -1
  69. package/plugin/lib/module/helpers/constants/common.js +12 -0
  70. package/plugin/lib/module/helpers/constants/common.js.map +1 -0
  71. package/plugin/lib/module/helpers/constants/ios.js +6 -6
  72. package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
  73. package/plugin/lib/module/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
  74. package/plugin/lib/module/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
  75. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -2
  76. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  77. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +57 -0
  78. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -0
  79. package/plugin/lib/module/index.js +14 -2
  80. package/plugin/lib/module/index.js.map +1 -1
  81. package/plugin/lib/module/ios/utils.js +1 -2
  82. package/plugin/lib/module/ios/utils.js.map +1 -1
  83. package/plugin/lib/module/ios/withAppDelegateModifications.js +3 -3
  84. package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  85. package/plugin/lib/module/ios/withCIOIos.js +17 -11
  86. package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
  87. package/plugin/lib/module/ios/withCIOIosSwift.js +134 -50
  88. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  89. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +2 -2
  90. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
  91. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +18 -20
  92. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  93. package/plugin/lib/module/ios/withXcodeProject.js +1 -1
  94. package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
  95. package/plugin/lib/module/postInstallHelper.js.map +1 -1
  96. package/plugin/lib/module/types/cio-types.js.map +1 -1
  97. package/plugin/lib/module/utils/android.js +100 -0
  98. package/plugin/lib/module/utils/android.js.map +1 -0
  99. package/plugin/lib/module/utils/config.js +38 -0
  100. package/plugin/lib/module/utils/config.js.map +1 -0
  101. package/plugin/lib/module/utils/plugin.js +38 -0
  102. package/plugin/lib/module/utils/plugin.js.map +1 -0
  103. package/plugin/lib/module/utils/validation.js +39 -0
  104. package/plugin/lib/module/utils/validation.js.map +1 -0
  105. package/plugin/lib/module/utils/xcode.js +60 -0
  106. package/plugin/lib/module/utils/xcode.js.map +1 -0
  107. package/plugin/lib/typescript/android/withAndroidManifestUpdates.d.ts +1 -0
  108. package/plugin/lib/typescript/android/withCIOAndroid.d.ts +2 -2
  109. package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +3 -0
  110. package/plugin/lib/typescript/android/withProjectStrings.d.ts +2 -1
  111. package/plugin/lib/typescript/helpers/constants/android.d.ts +3 -0
  112. package/plugin/lib/typescript/helpers/constants/common.d.ts +11 -0
  113. package/plugin/lib/typescript/helpers/constants/ios.d.ts +3 -1
  114. package/plugin/lib/typescript/helpers/utils/patchPluginNativeCode.d.ts +7 -0
  115. package/plugin/lib/typescript/ios/utils.d.ts +2 -2
  116. package/plugin/lib/typescript/ios/withCIOIos.d.ts +2 -2
  117. package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +3 -3
  118. package/plugin/lib/typescript/types/cio-types.d.ts +46 -6
  119. package/plugin/lib/typescript/utils/android.d.ts +5 -0
  120. package/plugin/lib/typescript/utils/config.d.ts +8 -0
  121. package/plugin/lib/typescript/utils/plugin.d.ts +4 -0
  122. package/plugin/lib/typescript/utils/validation.d.ts +3 -0
  123. package/plugin/lib/typescript/utils/xcode.d.ts +28 -0
  124. package/plugin/src/android/withAndroidManifestUpdates.ts +70 -21
  125. package/plugin/src/android/withCIOAndroid.ts +8 -2
  126. package/plugin/src/android/withGoogleServicesJSON.ts +2 -2
  127. package/plugin/src/android/withMainApplicationModifications.ts +50 -0
  128. package/plugin/src/android/withNotificationChannelMetadata.ts +7 -3
  129. package/plugin/src/android/withProjectStrings.ts +20 -10
  130. package/plugin/src/helpers/constants/android.ts +7 -0
  131. package/plugin/src/helpers/constants/common.ts +12 -0
  132. package/plugin/src/helpers/constants/ios.ts +11 -13
  133. package/plugin/src/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
  134. package/plugin/src/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
  135. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +8 -7
  136. package/plugin/src/helpers/utils/patchPluginNativeCode.ts +97 -0
  137. package/plugin/src/index.ts +18 -2
  138. package/plugin/src/ios/utils.ts +5 -5
  139. package/plugin/src/ios/withAppDelegateModifications.ts +11 -8
  140. package/plugin/src/ios/withCIOIos.ts +19 -11
  141. package/plugin/src/ios/withCIOIosSwift.ts +195 -73
  142. package/plugin/src/ios/withGoogleServicesJsonFile.ts +7 -10
  143. package/plugin/src/ios/withNotificationsXcodeProject.ts +25 -26
  144. package/plugin/src/ios/withXcodeProject.ts +1 -1
  145. package/plugin/src/postInstallHelper.js +1 -1
  146. package/plugin/src/types/cio-types.ts +48 -8
  147. package/plugin/src/utils/android.ts +112 -0
  148. package/plugin/src/utils/config.ts +53 -0
  149. package/plugin/src/utils/plugin.ts +46 -0
  150. package/plugin/src/utils/validation.ts +54 -0
  151. package/plugin/src/utils/xcode.ts +74 -0
  152. package/plugin/lib/commonjs/helpers/constants/globals.d.js +0 -2
  153. package/plugin/lib/commonjs/helpers/constants/globals.d.js.map +0 -1
  154. package/plugin/lib/commonjs/helpers/utils/pluginUtils.js +0 -26
  155. package/plugin/lib/commonjs/helpers/utils/pluginUtils.js.map +0 -1
  156. package/plugin/lib/module/helpers/constants/globals.d.js +0 -2
  157. package/plugin/lib/module/helpers/constants/globals.d.js.map +0 -1
  158. package/plugin/lib/module/helpers/utils/pluginUtils.js +0 -19
  159. package/plugin/lib/module/helpers/utils/pluginUtils.js.map +0 -1
  160. package/plugin/lib/typescript/helpers/utils/pluginUtils.d.ts +0 -4
  161. package/plugin/src/helpers/constants/globals.d.ts +0 -8
  162. package/plugin/src/helpers/utils/pluginUtils.ts +0 -22
@@ -1,8 +1,12 @@
1
1
  import { withAppDelegate, withXcodeProject } from '@expo/config-plugins';
2
2
  import path from 'path';
3
- import { FileManagement } from '../helpers/utils/fileManagement';
4
- import { LOCAL_PATH_TO_CIO_NSE_FILES, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2, CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER, CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET } from '../helpers/constants/ios';
3
+ import { PLATFORM } from '../helpers/constants/common';
4
+ import { CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET, CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2, CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER } from '../helpers/constants/ios';
5
5
  import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
6
+ import { FileManagement } from '../helpers/utils/fileManagement';
7
+ import { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';
8
+ import { getIosNativeFilesPath } from '../utils/plugin';
9
+ import { copyFileToXcode, getOrCreateCustomerIOGroup } from '../utils/xcode';
6
10
  import { isFcmPushProvider } from './utils';
7
11
 
8
12
  // Constants
@@ -12,39 +16,56 @@ const CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CL
12
16
  /**
13
17
  * Copy and configure the CioSdkAppDelegateHandler.swift file
14
18
  */
15
- const copyAndConfigureAppDelegateHandler = (config, props) => {
16
- var _props$pushNotificati, _props$pushNotificati2, _props$pushNotificati3, _props$pushNotificati4;
17
- const projectRoot = config.modRequest.projectRoot;
18
- const iosProjectRoot = path.join(projectRoot, 'ios');
19
- const useFcm = isFcmPushProvider(props);
20
-
21
- // Source path for the handler file
22
- const handlerSourcePath = path.join(LOCAL_PATH_TO_CIO_NSE_FILES, useFcm ? 'fcm' : 'apn', CIO_SDK_APP_DELEGATE_HANDLER_FILENAME);
23
-
19
+ const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props) => {
24
20
  // Destination path in the iOS project
25
21
  const projectName = config.modRequest.projectName || '';
26
22
  if (!projectName) {
27
- console.warn('Project name is undefined, cannot copy CioSdkAppDelegateHandler.swift');
23
+ console.warn('Project name is undefined, cannot copy CustomerIO files');
28
24
  return config;
29
25
  }
30
- const handlerDestPath = path.join(iosProjectRoot, projectName, CIO_SDK_APP_DELEGATE_HANDLER_FILENAME);
31
- FileManagement.copyFile(handlerSourcePath, handlerDestPath);
32
26
 
33
- // Add the file to the Xcode project
27
+ // Add files to the Xcode project
34
28
  const xcodeProject = config.modResults;
35
-
36
- // Create a group for CustomerIO files if it doesn't exist
37
- let group;
38
- const existingGroup = xcodeProject.pbxGroupByName('CustomerIO');
39
- if (existingGroup) {
40
- group = existingGroup;
41
- } else {
42
- group = xcodeProject.pbxCreateGroup('CustomerIO');
43
- const classesKey = xcodeProject.findPBXGroupKey({
44
- name: projectName
29
+ const projectRoot = config.modRequest.projectRoot;
30
+ const iosProjectRoot = path.join(projectRoot, 'ios');
31
+ const group = getOrCreateCustomerIOGroup(xcodeProject, projectName);
32
+ if (props.pushNotification) {
33
+ // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support
34
+ copyAndConfigurePushAppDelegateHandler({
35
+ xcodeProject,
36
+ group,
37
+ iosProjectRoot,
38
+ projectName,
39
+ sdkConfig,
40
+ props
41
+ });
42
+ } else if (sdkConfig) {
43
+ // Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications
44
+ copyAndConfigureNativeSDKInitializer({
45
+ xcodeProject,
46
+ group,
47
+ iosProjectRoot,
48
+ projectName,
49
+ sdkConfig
45
50
  });
46
- xcodeProject.addToPbxGroup(group, classesKey);
47
51
  }
52
+ return config;
53
+ };
54
+ const copyAndConfigurePushAppDelegateHandler = ({
55
+ xcodeProject,
56
+ group,
57
+ iosProjectRoot,
58
+ projectName,
59
+ sdkConfig,
60
+ props
61
+ }) => {
62
+ var _props$pushNotificati, _props$pushNotificati2, _props$pushNotificati3, _props$pushNotificati4;
63
+ const useFcm = isFcmPushProvider(props);
64
+
65
+ // Source path for the handler file
66
+ const handlerSourcePath = path.join(getIosNativeFilesPath(), useFcm ? 'fcm' : 'apn', CIO_SDK_APP_DELEGATE_HANDLER_FILENAME);
67
+ const handlerDestPath = path.join(iosProjectRoot, projectName, CIO_SDK_APP_DELEGATE_HANDLER_FILENAME);
68
+ FileManagement.copyFile(handlerSourcePath, handlerDestPath);
48
69
 
49
70
  // Add the file to the Xcode project
50
71
  xcodeProject.addSourceFile(`${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`, null, group);
@@ -63,25 +84,69 @@ const copyAndConfigureAppDelegateHandler = (config, props) => {
63
84
  handlerFileContent = replaceCodeByRegex(handlerFileContent, /\{\{AUTO_FETCH_DEVICE_TOKEN\}\}/, autoFetchDeviceToken.toString());
64
85
  const showPushAppInForeground = ((_props$pushNotificati4 = props.pushNotification) === null || _props$pushNotificati4 === void 0 ? void 0 : _props$pushNotificati4.showPushAppInForeground) !== false;
65
86
  handlerFileContent = replaceCodeByRegex(handlerFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
87
+
88
+ // Add auto initialization if sdkConfig is provided
89
+ if (sdkConfig) {
90
+ // Also copy CustomerIOSDKInitializer.swift for auto-initialization
91
+ copyAndConfigureNativeSDKInitializer({
92
+ xcodeProject,
93
+ group,
94
+ iosProjectRoot,
95
+ projectName,
96
+ sdkConfig
97
+ });
98
+
99
+ // Inject auto initialization call before MessagingPush initialization
100
+ handlerFileContent = handlerFileContent.replace(CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET + '$1');
101
+ }
66
102
  FileManagement.writeFile(handlerDestPath, handlerFileContent);
67
- return config;
68
103
  };
69
- export const withCIOIosSwift = (configOuter, props) => {
70
- // First, copy the CioSdkAppDelegateHandler.swift file to the iOS project and add it to Xcode project
104
+ const copyAndConfigureNativeSDKInitializer = ({
105
+ xcodeProject,
106
+ group,
107
+ iosProjectRoot,
108
+ projectName,
109
+ sdkConfig
110
+ }) => {
111
+ const filename = 'CustomerIOSDKInitializer.swift';
112
+ const sourcePath = path.join(getIosNativeFilesPath(), filename);
113
+ // Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler
114
+ copyFileToXcode({
115
+ xcodeProject,
116
+ iosProjectRoot,
117
+ projectName,
118
+ sourceFilePath: sourcePath,
119
+ targetFileName: filename,
120
+ transform: content => patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig),
121
+ customerIOGroup: group
122
+ });
123
+ };
124
+ export const withCIOIosSwift = (configOuter, sdkConfig, props) => {
125
+ // First, copy required swift files to iOS folder and add it to Xcode project
71
126
  configOuter = withXcodeProject(configOuter, async config => {
72
- return copyAndConfigureAppDelegateHandler(config, props);
127
+ return copyAndConfigureAppDelegateHandler(config, sdkConfig, props);
73
128
  });
74
129
 
75
- // Then modify the AppDelegate
76
- return withAppDelegate(configOuter, async config => {
77
- return modifyAppDelegate(config, props);
78
- });
130
+ // Modify the AppDelegate based on configuration
131
+ if (props.pushNotification) {
132
+ // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init
133
+ return withAppDelegate(configOuter, async config => {
134
+ return modifyAppDelegateWithPushAppDelegateHandler(config, props);
135
+ });
136
+ } else if (sdkConfig) {
137
+ // Without push notifications: directly inject auto initialization into AppDelegate
138
+ return withAppDelegate(configOuter, async config => {
139
+ return modifyAppDelegateWithNativeSDKInitializer(config);
140
+ });
141
+ } else {
142
+ return configOuter;
143
+ }
79
144
  };
80
145
 
81
146
  /**
82
147
  * Modify the AppDelegate to integrate with Customer.io SDK
83
148
  */
84
- const modifyAppDelegate = (config, props) => {
149
+ const modifyAppDelegateWithPushAppDelegateHandler = (config, props) => {
85
150
  var _props$pushNotificati5;
86
151
  const appDelegateContent = config.modResults.contents;
87
152
 
@@ -95,7 +160,7 @@ const modifyAppDelegate = (config, props) => {
95
160
  let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);
96
161
 
97
162
  // Modify didFinishLaunchingWithOptions to initialize and call the handler
98
- modifiedContent = modifyDidFinishLaunchingWithOptions(modifiedContent);
163
+ modifiedContent = modifyDidFinishLaunchingWithOptions(modifiedContent, ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\n\n `);
99
164
 
100
165
  // Add didRegisterForRemoteNotificationsWithDeviceToken implementation
101
166
  modifiedContent = addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);
@@ -111,6 +176,26 @@ const modifyAppDelegate = (config, props) => {
111
176
  return config;
112
177
  };
113
178
 
179
+ /**
180
+ * Modify the AppDelegate to integrate with Customer.io SDK
181
+ */
182
+ const modifyAppDelegateWithNativeSDKInitializer = (config
183
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
184
+ ) => {
185
+ const appDelegateContent = config.modResults.contents;
186
+
187
+ // Check if modifications have already been applied
188
+ if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {
189
+ console.log('CustomerIO Swift AppDelegate changes already exist. Skipping...');
190
+ return config;
191
+ }
192
+
193
+ // Modify didFinishLaunchingWithOptions to initialize and call the handler
194
+ const modifiedContent = modifyDidFinishLaunchingWithOptions(appDelegateContent, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
195
+ config.modResults.contents = modifiedContent;
196
+ return config;
197
+ };
198
+
114
199
  /**
115
200
  * Check if a method exists in the AppDelegate content
116
201
  * @param content The AppDelegate content
@@ -134,15 +219,15 @@ const addHandlerPropertyDeclaration = content => {
134
219
  console.warn('Could not find AppDelegate class declaration');
135
220
  return content;
136
221
  }
137
- const position = match.index + match[0].length;
222
+ const position = (match.index ?? 0) + match[0].length;
138
223
  return content.substring(0, position) + `\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\n` + content.substring(position);
139
224
  };
140
225
 
141
226
  /**
142
- * Modify didFinishLaunchingWithOptions to call the handler
143
- * This adds the handler call before the return statement in didFinishLaunchingWithOptions
227
+ * Modify didFinishLaunchingWithOptions to inject Customer.io code
228
+ * Injects the provided code (either handler call or auto initialization) before the return statement
144
229
  */
145
- const modifyDidFinishLaunchingWithOptions = content => {
230
+ const modifyDidFinishLaunchingWithOptions = (content, codeToInject) => {
146
231
  // Find the return statement in didFinishLaunchingWithOptions
147
232
  // Always look for launchOptions since modifiedLaunchOptions is only set later
148
233
  const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
@@ -152,10 +237,9 @@ const modifyDidFinishLaunchingWithOptions = content => {
152
237
  return content;
153
238
  }
154
239
 
155
- // Add handler call before the return statement
156
- const insertPosition = returnStatementMatch.index;
157
- const handlerCallCode = ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\n\n `;
158
- return content.substring(0, insertPosition) + handlerCallCode + content.substring(insertPosition);
240
+ // Inject Customer.io code before the return statement
241
+ const insertPosition = returnStatementMatch.index ?? 0;
242
+ return content.substring(0, insertPosition) + codeToInject + content.substring(insertPosition);
159
243
  };
160
244
 
161
245
  /**
@@ -190,7 +274,7 @@ const addDidRegisterForRemoteNotificationsWithDeviceToken = content => {
190
274
  }
191
275
 
192
276
  // Insert the method inside the class
193
- const position = classEndMatch.index;
277
+ const position = classEndMatch.index ?? 0;
194
278
  return content.substring(0, position) + '\n // Handle device token registration\n' + ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\n' + ' // Call CustomerIO SDK handler\n' + ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\n' + ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\n' + ' }\n' + content.substring(position);
195
279
  }
196
280
  };
@@ -227,7 +311,7 @@ const addDidFailToRegisterForRemoteNotificationsWithError = content => {
227
311
  }
228
312
 
229
313
  // Insert the method inside the class
230
- const position = classEndMatch.index;
314
+ const position = classEndMatch.index ?? 0;
231
315
  return content.substring(0, position) + '\n // Handle remote notification registration errors\n' + ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\n' + ' // Call CustomerIO SDK handler\n' + ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\n' + ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\n' + ' }\n' + content.substring(position);
232
316
  }
233
317
  };
@@ -239,7 +323,7 @@ const addDidFailToRegisterForRemoteNotificationsWithError = content => {
239
323
  */
240
324
  const addHandleDeeplinkInKilledState = content => {
241
325
  // Check if deep link code snippet is already present
242
- const deepLinkMarker = "Deep link workaround for app killed state start";
326
+ const deepLinkMarker = 'Deep link workaround for app killed state start';
243
327
  if (content.includes(deepLinkMarker)) {
244
328
  return content;
245
329
  }
@@ -248,13 +332,13 @@ const addHandleDeeplinkInKilledState = content => {
248
332
  const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
249
333
  const returnStatementMatch = content.match(returnStatementRegex);
250
334
  if (!returnStatementMatch) {
251
- console.warn("Could not find return statement with launchOptions");
335
+ console.warn('Could not find return statement with launchOptions');
252
336
  return content;
253
337
  }
254
338
 
255
339
  // Create the replacement code with deep link handling and modified return statement
256
- const modifiedReturnStatement = "return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)";
257
- const replacementCode = CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET + "\n\n " + modifiedReturnStatement;
340
+ const modifiedReturnStatement = 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';
341
+ const replacementCode = CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET + '\n\n ' + modifiedReturnStatement;
258
342
 
259
343
  // Replace the return statement with deep link handling code and modified return statement
260
344
  return content.replace(returnStatementRegex, replacementCode);
@@ -1 +1 @@
1
- {"version":3,"names":["withAppDelegate","withXcodeProject","path","FileManagement","LOCAL_PATH_TO_CIO_NSE_FILES","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","replaceCodeByRegex","isFcmPushProvider","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","props","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","projectRoot","modRequest","iosProjectRoot","join","useFcm","handlerSourcePath","projectName","console","warn","handlerDestPath","copyFile","xcodeProject","modResults","group","existingGroup","pbxGroupByName","pbxCreateGroup","classesKey","findPBXGroupKey","name","addToPbxGroup","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","pushNotification","snippet","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","writeFile","withCIOIosSwift","configOuter","modifyAppDelegate","_props$pushNotificati5","appDelegateContent","contents","includes","log","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","methodExistsInAppDelegate","content","methodSignature","classDeclarationRegex","match","position","index","length","substring","returnStatementRegex","returnStatementMatch","insertPosition","handlerCallCode","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","replace","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport {\n withAppDelegate,\n withXcodeProject,\n} from '@expo/config-plugins';\nimport path from 'path';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport {\n LOCAL_PATH_TO_CIO_NSE_FILES,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\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: any,\n props: CustomerIOPluginOptionsIOS\n): any => {\n const projectRoot = config.modRequest.projectRoot;\n const iosProjectRoot = path.join(projectRoot, 'ios');\n const useFcm = isFcmPushProvider(props);\n\n // Source path for the handler file\n const handlerSourcePath = path.join(\n LOCAL_PATH_TO_CIO_NSE_FILES,\n useFcm ? 'fcm' : 'apn',\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n console.warn(\n 'Project name is undefined, cannot copy CioSdkAppDelegateHandler.swift'\n );\n return config;\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 const xcodeProject = config.modResults;\n\n // Create a group for CustomerIO files if it doesn't exist\n let group;\n const existingGroup = xcodeProject.pbxGroupByName('CustomerIO');\n if (existingGroup) {\n group = existingGroup;\n } else {\n group = xcodeProject.pbxCreateGroup('CustomerIO');\n const classesKey = xcodeProject.findPBXGroupKey({ name: projectName });\n xcodeProject.addToPbxGroup(group, classesKey);\n }\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 FileManagement.writeFile(handlerDestPath, handlerFileContent);\n\n return config;\n};\n\nexport const withCIOIosSwift: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n configOuter,\n props\n) => {\n // First, copy the CioSdkAppDelegateHandler.swift file to the iOS project and add it to Xcode project\n configOuter = withXcodeProject(configOuter, async (config) => {\n return copyAndConfigureAppDelegateHandler(config, props);\n });\n\n // Then modify the AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegate(config, props);\n });\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegate = (\n config: any,\n props: CustomerIOPluginOptionsIOS\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 console.log(\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(modifiedContent);\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 * 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 console.warn('Could not find AppDelegate class declaration');\n return content;\n }\n\n const position = match.index! + 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 call the handler\n * This adds the handler call before the return statement in didFinishLaunchingWithOptions\n */\nconst modifyDidFinishLaunchingWithOptions = (content: string): string => {\n // Find the return statement in didFinishLaunchingWithOptions\n // Always look for launchOptions since modifiedLaunchOptions is only set later\n const returnStatementRegex = /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 console.warn(\n 'Could not find return statement with super.application in didFinishLaunchingWithOptions'\n );\n return content;\n }\n\n // Add handler call before the return statement\n const insertPosition = returnStatementMatch.index!;\n const handlerCallCode = ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `;\n \n return (\n content.substring(0, insertPosition) +\n handlerCallCode +\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 = '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 console.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!;\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 = '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 console.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!;\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 = /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 console.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 = \"return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)\";\n const replacementCode = CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET + \"\\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":"AACA,SACEA,eAAe,EACfC,gBAAgB,QACX,sBAAsB;AAC7B,OAAOC,IAAI,MAAM,MAAM;AAEvB,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SACEC,2BAA2B,EAC3BC,wCAAwC,EACxCC,0CAA0C,EAC1CC,+CAA+C,QAC1C,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,iBAAiB,QAAQ,SAAS;;AAE3C;AACA,MAAMC,kCAAkC,GAAG,0BAA0B;AACrE,MAAMC,qCAAqC,GAAG,GAAGD,kCAAkC,QAAQ;;AAE3F;AACA;AACA;AACA,MAAME,kCAAkC,GAAGA,CACzCC,MAAW,EACXC,KAAiC,KACzB;EAAA,IAAAC,qBAAA,EAAAC,sBAAA,EAAAC,sBAAA,EAAAC,sBAAA;EACR,MAAMC,WAAW,GAAGN,MAAM,CAACO,UAAU,CAACD,WAAW;EACjD,MAAME,cAAc,GAAGnB,IAAI,CAACoB,IAAI,CAACH,WAAW,EAAE,KAAK,CAAC;EACpD,MAAMI,MAAM,GAAGd,iBAAiB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AOrB,OAAO,CAACiB,OAAO,CAACT,oBAAoB,EAAEc,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withAppDelegate","withXcodeProject","path","PLATFORM","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","replaceCodeByRegex","FileManagement","patchNativeSDKInitializer","getIosNativeFilesPath","copyFileToXcode","getOrCreateCustomerIOGroup","isFcmPushProvider","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","projectName","modRequest","console","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","join","group","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","useFcm","handlerSourcePath","handlerDestPath","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","replace","writeFile","filename","sourcePath","sourceFilePath","targetFileName","transform","content","IOS","customerIOGroup","withCIOIosSwift","configOuter","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","_props$pushNotificati5","appDelegateContent","contents","includes","log","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type {\n ExportedConfigWithProps,\n XcodeProject,\n} from '@expo/config-plugins';\nimport { withAppDelegate, withXcodeProject } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\nimport { PLATFORM } from '../helpers/constants/common';\nimport {\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_CALL,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type { CustomerIOPluginOptionsIOS, NativeSDKConfig } from '../types/cio-types';\nimport { 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 | undefined,\n props: CustomerIOPluginOptionsIOS,\n): ExportedConfigWithProps<XcodeProject> => {\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n console.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 | undefined,\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 console.log(\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 console.log(\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 console.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 console.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 console.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 console.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 console.warn('Could not find return statement with launchOptions');\n return content;\n }\n\n // Create the replacement code with deep link handling and modified return statement\n const modifiedReturnStatement =\n 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';\n const replacementCode =\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET +\n '\\n\\n ' +\n modifiedReturnStatement;\n\n // Replace the return statement with deep link handling code and modified return statement\n return content.replace(returnStatementRegex, replacementCode);\n};\n"],"mappings":"AAIA,SAASA,eAAe,EAAEC,gBAAgB,QAAQ,sBAAsB;AAExE,OAAOC,IAAI,MAA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+C,GAC/C,UAAU,GACV+F,uBAAuB;;EAEzB;EACA,OAAOvC,OAAO,CAACP,OAAO,CAACmC,oBAAoB,EAAEY,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { withXcodeProject, IOSConfig } from '@expo/config-plugins';
1
+ import { IOSConfig, withXcodeProject } from '@expo/config-plugins';
2
2
  import { FileManagement } from './../helpers/utils/fileManagement';
3
3
  import { isFcmPushProvider } from './utils';
4
4
  export const withGoogleServicesJsonFile = (config, cioProps) => {
@@ -33,7 +33,7 @@ export const withGoogleServicesJsonFile = (config, cioProps) => {
33
33
  try {
34
34
  FileManagement.copyFile(googleServicesFile, `${iosPath}/GoogleService-Info.plist`);
35
35
  addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');
36
- } catch (e) {
36
+ } catch {
37
37
  console.error(`There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`);
38
38
  }
39
39
  } else {
@@ -1 +1 @@
1
- {"version":3,"names":["withXcodeProject","IOSConfig","FileManagement","isFcmPushProvider","withGoogleServicesJsonFile","config","cioProps","props","_cioProps$pushNotific","useFcm","console","log","iosPath","modRequest","platformProjectRoot","googleServicesFile","pushNotification","appName","projectName","exists","_config$ios","ios","warn","copyFile","addFileToXcodeProject","modResults","e","error","project","fileName","groupName","filepath","XcodeUtils","ensureGroupRecursively","addResourceFileToGroup","isBuildFile"],"sources":["withGoogleServicesJsonFile.ts"],"sourcesContent":["import {\n withXcodeProject,\n IOSConfig,\n} from '@expo/config-plugins';\nimport type { ConfigPlugin } from '@expo/config-plugins';\n\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\n\nexport const withGoogleServicesJsonFile: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (config, cioProps) => {\n return withXcodeProject(config, async (props) => {\n const useFcm = isFcmPushProvider(cioProps);\n if (!useFcm) {\n // Nothing to do, for providers other than FCM, the Google services JSON file isn't needed\n return props;\n }\n\n console.log(\n 'Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' +\n ' GoogleService-Info.plist as part of Firebase integration'\n );\n\n // googleServicesFile\n const iosPath = props.modRequest.platformProjectRoot;\n const googleServicesFile = cioProps.pushNotification?.googleServicesFile;\n const appName = props.modRequest.projectName;\n\n if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {\n console.log(\n `File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (\n FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)\n ) {\n // This is where RN Firebase potentially copies GoogleService-Info.plist\n // Do not copy if it's already done by Firebase to avoid conflict in Resources\n console.log(\n `File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n if (config.ios?.googleServicesFile) {\n console.warn(\n 'Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' +\n ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile'\n );\n }\n\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${iosPath}/GoogleService-Info.plist`\n );\n\n addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');\n } catch (e) {\n console.error(\n `There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n } else {\n console.error(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n\n return props;\n });\n};\n\nfunction addFileToXcodeProject(project: any, fileName: string) {\n const groupName = 'Resources';\n const filepath = fileName;\n\n if (!IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {\n console.error(\n `Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`\n );\n return;\n }\n\n // Add GoogleService-Info.plist to the Xcode project\n IOSConfig.XcodeUtils.addResourceFileToGroup({\n project,\n filepath,\n groupName,\n isBuildFile: true,\n });\n}\n"],"mappings":"AAAA,SACEA,gBAAgB,EAChBC,SAAS,QACJ,sBAAsB;AAG7B,SAASC,cAAc,QAAQ,mCAAmC;AAElE,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,OAAO,MAAMC,0BAEZ,GAAGA,CAACC,MAAM,EAAEC,QAAQ,KAAK;EACxB,OAAON,gBAAgB,CAACK,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA,IAAAC,qBAAA;IAC/C,MAAMC,MAAM,GAAGN,iBAAiB,CAACG,QAAQ,CAAC;IAC1C,IAAI,CAACG,MAAM,EAAE;MACX;MACA,OAAOF,KAAK;IACd;IAEAG,OAAO,CAACC,GAAG,CACT,0GAA0G,GACxG,2DACJ,CAAC;;IAED;IACA,MAAMC,OAAO,GAAGL,KAAK,CAACM,UAAU,CAACC,mBAAmB;IACpD,MAAMC,kBAAkB,IAAAP,qBAAA,GAAGF,QAAQ,CAACU,gBAAgB,cAAAR,qBAAA,uBAAzBA,qBAAA,CAA2BO,kBAAkB;IACxE,MAAME,OAAO,GAAGV,KAAK,CAACM,UAAU,CAACK,WAAW;IAE5C,IAAIhB,cAAc,CAACiB,MAAM,CAAC,GAAGP,OAAO,2BAA2B,CAAC,EAAE;MAChEF,OAAO,CAACC,GAAG,CACT,wBAAwBC,OAAO,wCACjC,CAAC;MACD,OAAOL,KAAK;IACd;IAEA,IACEL,cAAc,CAACiB,MAAM,CAAC,GAAGP,OAAO,IAAIK,OAAO,2BAA2B,CAAC,EACvE;MACA;MACA;MACAP,OAAO,CAACC,GAAG,CACT,wBAAwBC,OAAO,IAAIK,OAAO,wCAC5C,CAAC;MACD,OAAOV,KAAK;IACd;IAEA,IAAIQ,kBAAkB,IAAIb,cAAc,CAACiB,MAAM,CAACJ,kBAAkB,CAAC,EAAE;MAAA,IAAAK,WAAA;MACnE,KAAAA,WAAA,GAAIf,MAAM,CAACgB,GAAG,cAAAD,WAAA,eAAVA,WAAA,CAAYL,kBAAkB,EAAE;QAClCL,OAAO,CAACY,IAAI,CACV,0HAA0H,GACxH,uIACJ,CAAC;MACH;MAEA,IAAI;QACFpB,cAAc,CAACqB,QAAQ,CACrBR,kBAAkB,EAClB,GAAGH,OAAO,2BACZ,CAAC;QAEDY,qBAAqB,CAACjB,KAAK,CAACkB,UAAU,EAAE,0BAA0B,CAAC;MACrE,CAAC,CAAC,OAAOC,CAAC,EAAE;QACVhB,OAAO,CAACiB,KAAK,CACX,gGAAgGf,OAAO,2BACzG,CAAC;MACH;IACF,CAAC,MAAM;MACLF,OAAO,CAACiB,KAAK,CACX,wCAAwCZ,kBAAkB,yDAAyDH,OAAO,2BAC5H,CAAC;IACH;IAEA,OAAOL,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAED,SAASiB,qBAAqBA,CAACI,OAAY,EAAEC,QAAgB,EAAE;EAC7D,MAAMC,SAAS,GAAG,WAAW;EAC7B,MAAMC,QAAQ,GAAGF,QAAQ;EAEzB,IAAI,CAAC5B,SAAS,CAAC+B,UAAU,CAACC,sBAAsB,CAACL,OAAO,EAAEE,SAAS,CAAC,EAAE;IACpEpB,OAAO,CAACiB,KAAK,CACX,qEAAqEG,SAAS,mBAChF,CAAC;IACD;EACF;;EAEA;EACA7B,SAAS,CAAC+B,UAAU,CAACE,sBAAsB,CAAC;IAC1CN,OAAO;IACPG,QAAQ;IACRD,SAAS;IACTK,WAAW,EAAE;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["IOSConfig","withXcodeProject","FileManagement","isFcmPushProvider","withGoogleServicesJsonFile","config","cioProps","props","_cioProps$pushNotific","useFcm","console","log","iosPath","modRequest","platformProjectRoot","googleServicesFile","pushNotification","appName","projectName","exists","_config$ios","ios","warn","copyFile","addFileToXcodeProject","modResults","error","project","fileName","groupName","filepath","XcodeUtils","ensureGroupRecursively","addResourceFileToGroup","isBuildFile"],"sources":["withGoogleServicesJsonFile.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { IOSConfig, withXcodeProject } from '@expo/config-plugins';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isFcmPushProvider } from './utils';\n\nexport const withGoogleServicesJsonFile: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (config, cioProps) => {\n return withXcodeProject(config, async (props) => {\n const useFcm = isFcmPushProvider(cioProps);\n if (!useFcm) {\n // Nothing to do, for providers other than FCM, the Google services JSON file isn't needed\n return props;\n }\n\n console.log(\n 'Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' +\n ' GoogleService-Info.plist as part of Firebase integration'\n );\n\n // googleServicesFile\n const iosPath = props.modRequest.platformProjectRoot;\n const googleServicesFile = cioProps.pushNotification?.googleServicesFile;\n const appName = props.modRequest.projectName;\n\n if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {\n console.log(\n `File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (\n FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)\n ) {\n // This is where RN Firebase potentially copies GoogleService-Info.plist\n // Do not copy if it's already done by Firebase to avoid conflict in Resources\n console.log(\n `File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n if (config.ios?.googleServicesFile) {\n console.warn(\n 'Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' +\n ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile'\n );\n }\n\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${iosPath}/GoogleService-Info.plist`\n );\n\n addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');\n } catch {\n console.error(\n `There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n } else {\n console.error(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n\n return props;\n });\n};\n\nfunction addFileToXcodeProject(project: XcodeProject, fileName: string) {\n const groupName = 'Resources';\n const filepath = fileName;\n\n if (!IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {\n console.error(\n `Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`\n );\n return;\n }\n\n // Add GoogleService-Info.plist to the Xcode project\n IOSConfig.XcodeUtils.addResourceFileToGroup({\n project,\n filepath,\n groupName,\n isBuildFile: true,\n });\n}\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,gBAAgB,QAAQ,sBAAsB;AAGlE,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,OAAO,MAAMC,0BAEZ,GAAGA,CAACC,MAAM,EAAEC,QAAQ,KAAK;EACxB,OAAOL,gBAAgB,CAACI,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA,IAAAC,qBAAA;IAC/C,MAAMC,MAAM,GAAGN,iBAAiB,CAACG,QAAQ,CAAC;IAC1C,IAAI,CAACG,MAAM,EAAE;MACX;MACA,OAAOF,KAAK;IACd;IAEAG,OAAO,CAACC,GAAG,CACT,0GAA0G,GAC1G,2DACF,CAAC;;IAED;IACA,MAAMC,OAAO,GAAGL,KAAK,CAACM,UAAU,CAACC,mBAAmB;IACpD,MAAMC,kBAAkB,IAAAP,qBAAA,GAAGF,QAAQ,CAACU,gBAAgB,cAAAR,qBAAA,uBAAzBA,qBAAA,CAA2BO,kBAAkB;IACxE,MAAME,OAAO,GAAGV,KAAK,CAACM,UAAU,CAACK,WAAW;IAE5C,IAAIhB,cAAc,CAACiB,MAAM,CAAC,GAAGP,OAAO,2BAA2B,CAAC,EAAE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,CAACE,sBAAsB,CAAC;IAC1CN,OAAO;IACPG,QAAQ;IACRD,SAAS;IACTK,WAAW,EAAE;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,17 +1,18 @@
1
1
  import { withXcodeProject } from '@expo/config-plugins';
2
- import { CIO_NOTIFICATION_TARGET_NAME, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET, DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
2
+ import { CIO_NOTIFICATION_TARGET_NAME, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET, DEFAULT_BUNDLE_VERSION } from '../helpers/constants/ios';
3
3
  import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
4
4
  import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
5
+ import { getIosNativeFilesPath } from '../utils/plugin';
5
6
  import { FileManagement } from './../helpers/utils/fileManagement';
6
7
  import { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';
7
8
  const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
8
9
  const ENV_FILENAME = 'Env.swift';
9
10
  const TARGETED_DEVICE_FAMILY = `"1,2"`;
10
- const addNotificationServiceExtension = async (options, xcodeProject, isExpoVersion53OrHigher) => {
11
+ const addNotificationServiceExtension = async (options, xcodeProject, isExpo53OrHigher) => {
11
12
  try {
12
13
  var _options$pushNotifica;
13
14
  // PushService file is only needed for pre-Expo 53 code generation
14
- if (options.pushNotification && !isExpoVersion53OrHigher) {
15
+ if (options.pushNotification && !isExpo53OrHigher) {
15
16
  await addPushNotificationFile(options, xcodeProject);
16
17
  }
17
18
  if (((_options$pushNotifica = options.pushNotification) === null || _options$pushNotifica === void 0 ? void 0 : _options$pushNotifica.useRichPush) === true) {
@@ -74,6 +75,7 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
74
75
  });
75
76
  };
76
77
  const addRichPushXcodeProj = async (options, xcodeProject) => {
78
+ var _options$pushNotifica2;
77
79
  const {
78
80
  appleTeamId,
79
81
  bundleIdentifier,
@@ -102,13 +104,13 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
102
104
  // Copy platform-specific files
103
105
  platformSpecificFiles.forEach(filename => {
104
106
  const targetFile = getTargetFile(filename);
105
- FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${isFcmProvider ? 'fcm' : 'apn'}/${filename}`, targetFile);
107
+ FileManagement.copyFile(`${getIosNativeFilesPath()}/${isFcmProvider ? 'fcm' : 'apn'}/${filename}`, targetFile);
106
108
  });
107
109
 
108
110
  // Copy common files
109
111
  commonFiles.forEach(filename => {
110
112
  const targetFile = getTargetFile(filename);
111
- FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/common/${filename}`, targetFile);
113
+ FileManagement.copyFile(`${getIosNativeFilesPath()}/common/${filename}`, targetFile);
112
114
  });
113
115
 
114
116
  /* MODIFY COPIED EXTENSION FILES */
@@ -118,7 +120,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
118
120
  bundleShortVersion,
119
121
  infoPlistTargetFile
120
122
  });
121
- updateNseEnv(options, getTargetFile(ENV_FILENAME));
123
+ updateNseEnv(getTargetFile(ENV_FILENAME), (_options$pushNotifica2 = options.pushNotification) === null || _options$pushNotifica2 === void 0 ? void 0 : _options$pushNotifica2.env);
122
124
 
123
125
  // Create new PBXGroup for the extension
124
126
  const extGroup = xcodeProject.addPbxGroup([...platformSpecificFiles, ...commonFiles],
@@ -127,7 +129,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
127
129
 
128
130
  // Add the new PBXGroup to the top level group. This makes the
129
131
  // files / folder appear in the file explorer in Xcode.
130
- const groups = xcodeProject.hash.project.objects['PBXGroup'];
132
+ const groups = xcodeProject.hash.project.objects.PBXGroup;
131
133
  Object.keys(groups).forEach(key => {
132
134
  if (groups[key].name === undefined && groups[key].path === undefined) {
133
135
  xcodeProject.addToPbxGroup(extGroup.uuid, key);
@@ -139,8 +141,8 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
139
141
  // An upstream fix should be made to the code referenced in this link:
140
142
  // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
141
143
  const projObjects = xcodeProject.hash.project.objects;
142
- projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
143
- projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
144
+ projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};
145
+ projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};
144
146
  if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
145
147
  console.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
146
148
  return;
@@ -184,20 +186,16 @@ const updateNseInfoPlist = payload => {
184
186
  }
185
187
  FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
186
188
  };
187
- const updateNseEnv = (options, envFileName) => {
188
- var _options$pushNotifica2;
189
+ const updateNseEnv = (envFileName, richPushConfig) => {
189
190
  const CDP_API_KEY_RE = /\{\{CDP_API_KEY\}\}/;
190
191
  const REGION_RE = /\{\{REGION\}\}/;
191
192
  let envFileContent = FileManagement.readFile(envFileName);
192
- const {
193
- cdpApiKey,
194
- region
195
- } = ((_options$pushNotifica2 = options.pushNotification) === null || _options$pushNotifica2 === void 0 ? void 0 : _options$pushNotifica2.env) || {
196
- cdpApiKey: undefined,
197
- region: undefined
198
- };
193
+
194
+ // Use merged config values (config takes precedence over env)
195
+ const cdpApiKey = richPushConfig === null || richPushConfig === void 0 ? void 0 : richPushConfig.cdpApiKey;
196
+ const region = richPushConfig === null || richPushConfig === void 0 ? void 0 : richPushConfig.region;
199
197
  if (!cdpApiKey) {
200
- throw new Error('Adding NotificationServiceExtension failed: ios.pushNotification.env.cdpApiKey is missing from app.config.js or app.json.');
198
+ throw new Error('NotificationServiceExtension failed: cdpApiKey missing. Provide in config.cdpApiKey or ios.pushNotification.env.cdpApiKey.');
201
199
  }
202
200
  envFileContent = replaceCodeByRegex(envFileContent, CDP_API_KEY_RE, cdpApiKey);
203
201
  if (region) {
@@ -234,7 +232,7 @@ async function addPushNotificationFile(options, xcodeProject) {
234
232
  FileManagement.mkdir(appPath, {
235
233
  recursive: true
236
234
  });
237
- FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${sourceFile}`, targetFile);
235
+ FileManagement.copyFile(`${getIosNativeFilesPath()}/${sourceFile}`, targetFile);
238
236
  } else {
239
237
  console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);
240
238
  return;