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
@@ -6,9 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.withCIOIosSwift = void 0;
7
7
  var _configPlugins = require("@expo/config-plugins");
8
8
  var _path = _interopRequireDefault(require("path"));
9
- var _fileManagement = require("../helpers/utils/fileManagement");
9
+ var _common = require("../helpers/constants/common");
10
10
  var _ios = require("../helpers/constants/ios");
11
11
  var _codeInjection = require("../helpers/utils/codeInjection");
12
+ var _fileManagement = require("../helpers/utils/fileManagement");
13
+ var _patchPluginNativeCode = require("../helpers/utils/patchPluginNativeCode");
14
+ var _plugin = require("../utils/plugin");
15
+ var _xcode = require("../utils/xcode");
12
16
  var _utils = require("./utils");
13
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
18
  // Constants
@@ -18,39 +22,56 @@ const CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CL
18
22
  /**
19
23
  * Copy and configure the CioSdkAppDelegateHandler.swift file
20
24
  */
21
- const copyAndConfigureAppDelegateHandler = (config, props) => {
22
- var _props$pushNotificati, _props$pushNotificati2, _props$pushNotificati3, _props$pushNotificati4;
23
- const projectRoot = config.modRequest.projectRoot;
24
- const iosProjectRoot = _path.default.join(projectRoot, 'ios');
25
- const useFcm = (0, _utils.isFcmPushProvider)(props);
26
-
27
- // Source path for the handler file
28
- const handlerSourcePath = _path.default.join(_ios.LOCAL_PATH_TO_CIO_NSE_FILES, useFcm ? 'fcm' : 'apn', CIO_SDK_APP_DELEGATE_HANDLER_FILENAME);
29
-
25
+ const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props) => {
30
26
  // Destination path in the iOS project
31
27
  const projectName = config.modRequest.projectName || '';
32
28
  if (!projectName) {
33
- console.warn('Project name is undefined, cannot copy CioSdkAppDelegateHandler.swift');
29
+ console.warn('Project name is undefined, cannot copy CustomerIO files');
34
30
  return config;
35
31
  }
36
- const handlerDestPath = _path.default.join(iosProjectRoot, projectName, CIO_SDK_APP_DELEGATE_HANDLER_FILENAME);
37
- _fileManagement.FileManagement.copyFile(handlerSourcePath, handlerDestPath);
38
32
 
39
- // Add the file to the Xcode project
33
+ // Add files to the Xcode project
40
34
  const xcodeProject = config.modResults;
41
-
42
- // Create a group for CustomerIO files if it doesn't exist
43
- let group;
44
- const existingGroup = xcodeProject.pbxGroupByName('CustomerIO');
45
- if (existingGroup) {
46
- group = existingGroup;
47
- } else {
48
- group = xcodeProject.pbxCreateGroup('CustomerIO');
49
- const classesKey = xcodeProject.findPBXGroupKey({
50
- name: projectName
35
+ const projectRoot = config.modRequest.projectRoot;
36
+ const iosProjectRoot = _path.default.join(projectRoot, 'ios');
37
+ const group = (0, _xcode.getOrCreateCustomerIOGroup)(xcodeProject, projectName);
38
+ if (props.pushNotification) {
39
+ // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support
40
+ copyAndConfigurePushAppDelegateHandler({
41
+ xcodeProject,
42
+ group,
43
+ iosProjectRoot,
44
+ projectName,
45
+ sdkConfig,
46
+ props
47
+ });
48
+ } else if (sdkConfig) {
49
+ // Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications
50
+ copyAndConfigureNativeSDKInitializer({
51
+ xcodeProject,
52
+ group,
53
+ iosProjectRoot,
54
+ projectName,
55
+ sdkConfig
51
56
  });
52
- xcodeProject.addToPbxGroup(group, classesKey);
53
57
  }
58
+ return config;
59
+ };
60
+ const copyAndConfigurePushAppDelegateHandler = ({
61
+ xcodeProject,
62
+ group,
63
+ iosProjectRoot,
64
+ projectName,
65
+ sdkConfig,
66
+ props
67
+ }) => {
68
+ var _props$pushNotificati, _props$pushNotificati2, _props$pushNotificati3, _props$pushNotificati4;
69
+ const useFcm = (0, _utils.isFcmPushProvider)(props);
70
+
71
+ // Source path for the handler file
72
+ const handlerSourcePath = _path.default.join((0, _plugin.getIosNativeFilesPath)(), useFcm ? 'fcm' : 'apn', CIO_SDK_APP_DELEGATE_HANDLER_FILENAME);
73
+ const handlerDestPath = _path.default.join(iosProjectRoot, projectName, CIO_SDK_APP_DELEGATE_HANDLER_FILENAME);
74
+ _fileManagement.FileManagement.copyFile(handlerSourcePath, handlerDestPath);
54
75
 
55
76
  // Add the file to the Xcode project
56
77
  xcodeProject.addSourceFile(`${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`, null, group);
@@ -69,26 +90,70 @@ const copyAndConfigureAppDelegateHandler = (config, props) => {
69
90
  handlerFileContent = (0, _codeInjection.replaceCodeByRegex)(handlerFileContent, /\{\{AUTO_FETCH_DEVICE_TOKEN\}\}/, autoFetchDeviceToken.toString());
70
91
  const showPushAppInForeground = ((_props$pushNotificati4 = props.pushNotification) === null || _props$pushNotificati4 === void 0 ? void 0 : _props$pushNotificati4.showPushAppInForeground) !== false;
71
92
  handlerFileContent = (0, _codeInjection.replaceCodeByRegex)(handlerFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
93
+
94
+ // Add auto initialization if sdkConfig is provided
95
+ if (sdkConfig) {
96
+ // Also copy CustomerIOSDKInitializer.swift for auto-initialization
97
+ copyAndConfigureNativeSDKInitializer({
98
+ xcodeProject,
99
+ group,
100
+ iosProjectRoot,
101
+ projectName,
102
+ sdkConfig
103
+ });
104
+
105
+ // Inject auto initialization call before MessagingPush initialization
106
+ handlerFileContent = handlerFileContent.replace(_ios.CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, _ios.CIO_NATIVE_SDK_INITIALIZE_SNIPPET + '$1');
107
+ }
72
108
  _fileManagement.FileManagement.writeFile(handlerDestPath, handlerFileContent);
73
- return config;
74
109
  };
75
- const withCIOIosSwift = (configOuter, props) => {
76
- // First, copy the CioSdkAppDelegateHandler.swift file to the iOS project and add it to Xcode project
110
+ const copyAndConfigureNativeSDKInitializer = ({
111
+ xcodeProject,
112
+ group,
113
+ iosProjectRoot,
114
+ projectName,
115
+ sdkConfig
116
+ }) => {
117
+ const filename = 'CustomerIOSDKInitializer.swift';
118
+ const sourcePath = _path.default.join((0, _plugin.getIosNativeFilesPath)(), filename);
119
+ // Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler
120
+ (0, _xcode.copyFileToXcode)({
121
+ xcodeProject,
122
+ iosProjectRoot,
123
+ projectName,
124
+ sourceFilePath: sourcePath,
125
+ targetFileName: filename,
126
+ transform: content => (0, _patchPluginNativeCode.patchNativeSDKInitializer)(content, _common.PLATFORM.IOS, sdkConfig),
127
+ customerIOGroup: group
128
+ });
129
+ };
130
+ const withCIOIosSwift = (configOuter, sdkConfig, props) => {
131
+ // First, copy required swift files to iOS folder and add it to Xcode project
77
132
  configOuter = (0, _configPlugins.withXcodeProject)(configOuter, async config => {
78
- return copyAndConfigureAppDelegateHandler(config, props);
133
+ return copyAndConfigureAppDelegateHandler(config, sdkConfig, props);
79
134
  });
80
135
 
81
- // Then modify the AppDelegate
82
- return (0, _configPlugins.withAppDelegate)(configOuter, async config => {
83
- return modifyAppDelegate(config, props);
84
- });
136
+ // Modify the AppDelegate based on configuration
137
+ if (props.pushNotification) {
138
+ // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init
139
+ return (0, _configPlugins.withAppDelegate)(configOuter, async config => {
140
+ return modifyAppDelegateWithPushAppDelegateHandler(config, props);
141
+ });
142
+ } else if (sdkConfig) {
143
+ // Without push notifications: directly inject auto initialization into AppDelegate
144
+ return (0, _configPlugins.withAppDelegate)(configOuter, async config => {
145
+ return modifyAppDelegateWithNativeSDKInitializer(config);
146
+ });
147
+ } else {
148
+ return configOuter;
149
+ }
85
150
  };
86
151
 
87
152
  /**
88
153
  * Modify the AppDelegate to integrate with Customer.io SDK
89
154
  */
90
155
  exports.withCIOIosSwift = withCIOIosSwift;
91
- const modifyAppDelegate = (config, props) => {
156
+ const modifyAppDelegateWithPushAppDelegateHandler = (config, props) => {
92
157
  var _props$pushNotificati5;
93
158
  const appDelegateContent = config.modResults.contents;
94
159
 
@@ -102,7 +167,7 @@ const modifyAppDelegate = (config, props) => {
102
167
  let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);
103
168
 
104
169
  // Modify didFinishLaunchingWithOptions to initialize and call the handler
105
- modifiedContent = modifyDidFinishLaunchingWithOptions(modifiedContent);
170
+ modifiedContent = modifyDidFinishLaunchingWithOptions(modifiedContent, ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\n\n `);
106
171
 
107
172
  // Add didRegisterForRemoteNotificationsWithDeviceToken implementation
108
173
  modifiedContent = addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);
@@ -118,6 +183,26 @@ const modifyAppDelegate = (config, props) => {
118
183
  return config;
119
184
  };
120
185
 
186
+ /**
187
+ * Modify the AppDelegate to integrate with Customer.io SDK
188
+ */
189
+ const modifyAppDelegateWithNativeSDKInitializer = (config
190
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
191
+ ) => {
192
+ const appDelegateContent = config.modResults.contents;
193
+
194
+ // Check if modifications have already been applied
195
+ if (appDelegateContent.includes(_ios.CIO_NATIVE_SDK_INITIALIZE_CALL)) {
196
+ console.log('CustomerIO Swift AppDelegate changes already exist. Skipping...');
197
+ return config;
198
+ }
199
+
200
+ // Modify didFinishLaunchingWithOptions to initialize and call the handler
201
+ const modifiedContent = modifyDidFinishLaunchingWithOptions(appDelegateContent, _ios.CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
202
+ config.modResults.contents = modifiedContent;
203
+ return config;
204
+ };
205
+
121
206
  /**
122
207
  * Check if a method exists in the AppDelegate content
123
208
  * @param content The AppDelegate content
@@ -141,15 +226,15 @@ const addHandlerPropertyDeclaration = content => {
141
226
  console.warn('Could not find AppDelegate class declaration');
142
227
  return content;
143
228
  }
144
- const position = match.index + match[0].length;
229
+ const position = (match.index ?? 0) + match[0].length;
145
230
  return content.substring(0, position) + `\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\n` + content.substring(position);
146
231
  };
147
232
 
148
233
  /**
149
- * Modify didFinishLaunchingWithOptions to call the handler
150
- * This adds the handler call before the return statement in didFinishLaunchingWithOptions
234
+ * Modify didFinishLaunchingWithOptions to inject Customer.io code
235
+ * Injects the provided code (either handler call or auto initialization) before the return statement
151
236
  */
152
- const modifyDidFinishLaunchingWithOptions = content => {
237
+ const modifyDidFinishLaunchingWithOptions = (content, codeToInject) => {
153
238
  // Find the return statement in didFinishLaunchingWithOptions
154
239
  // Always look for launchOptions since modifiedLaunchOptions is only set later
155
240
  const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
@@ -159,10 +244,9 @@ const modifyDidFinishLaunchingWithOptions = content => {
159
244
  return content;
160
245
  }
161
246
 
162
- // Add handler call before the return statement
163
- const insertPosition = returnStatementMatch.index;
164
- const handlerCallCode = ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\n\n `;
165
- return content.substring(0, insertPosition) + handlerCallCode + content.substring(insertPosition);
247
+ // Inject Customer.io code before the return statement
248
+ const insertPosition = returnStatementMatch.index ?? 0;
249
+ return content.substring(0, insertPosition) + codeToInject + content.substring(insertPosition);
166
250
  };
167
251
 
168
252
  /**
@@ -197,7 +281,7 @@ const addDidRegisterForRemoteNotificationsWithDeviceToken = content => {
197
281
  }
198
282
 
199
283
  // Insert the method inside the class
200
- const position = classEndMatch.index;
284
+ const position = classEndMatch.index ?? 0;
201
285
  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);
202
286
  }
203
287
  };
@@ -234,7 +318,7 @@ const addDidFailToRegisterForRemoteNotificationsWithError = content => {
234
318
  }
235
319
 
236
320
  // Insert the method inside the class
237
- const position = classEndMatch.index;
321
+ const position = classEndMatch.index ?? 0;
238
322
  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);
239
323
  }
240
324
  };
@@ -246,7 +330,7 @@ const addDidFailToRegisterForRemoteNotificationsWithError = content => {
246
330
  */
247
331
  const addHandleDeeplinkInKilledState = content => {
248
332
  // Check if deep link code snippet is already present
249
- const deepLinkMarker = "Deep link workaround for app killed state start";
333
+ const deepLinkMarker = 'Deep link workaround for app killed state start';
250
334
  if (content.includes(deepLinkMarker)) {
251
335
  return content;
252
336
  }
@@ -255,13 +339,13 @@ const addHandleDeeplinkInKilledState = content => {
255
339
  const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
256
340
  const returnStatementMatch = content.match(returnStatementRegex);
257
341
  if (!returnStatementMatch) {
258
- console.warn("Could not find return statement with launchOptions");
342
+ console.warn('Could not find return statement with launchOptions');
259
343
  return content;
260
344
  }
261
345
 
262
346
  // Create the replacement code with deep link handling and modified return statement
263
- const modifiedReturnStatement = "return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)";
264
- const replacementCode = _ios.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET + "\n\n " + modifiedReturnStatement;
347
+ const modifiedReturnStatement = 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';
348
+ const replacementCode = _ios.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET + '\n\n ' + modifiedReturnStatement;
265
349
 
266
350
  // Replace the return statement with deep link handling code and modified return statement
267
351
  return content.replace(returnStatementRegex, replacementCode);
@@ -1 +1 @@
1
- {"version":3,"names":["_configPlugins","require","_path","_interopRequireDefault","_fileManagement","_ios","_codeInjection","_utils","e","__esModule","default","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","path","join","useFcm","isFcmPushProvider","handlerSourcePath","LOCAL_PATH_TO_CIO_NSE_FILES","projectName","console","warn","handlerDestPath","FileManagement","copyFile","xcodeProject","modResults","group","existingGroup","pbxGroupByName","pbxCreateGroup","classesKey","findPBXGroupKey","name","addToPbxGroup","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","pushNotification","snippet","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","replaceCodeByRegex","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","writeFile","withCIOIosSwift","configOuter","withXcodeProject","withAppDelegate","modifyAppDelegate","exports","_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","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET"],"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,IAAAA,cAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAMA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAA4C,SAAAE,uBAAAK,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,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,GAAGC,aAAI,CAACC,IAAI,CAACJ,WAAW,EAAE,KAAK,CAAC;EACpD,MAAMK,MA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EAC7H,MAAMC,eAAe,GAAGC,oDAA+C,GAAG,UAAU,GAAGF,uBAAuB;;EAE9G;EACA,OAAOrB,OAAO,CAACiB,OAAO,CAACT,oBAAoB,EAAEc,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_configPlugins","require","_path","_interopRequireDefault","_common","_ios","_codeInjection","_fileManagement","_patchPluginNativeCode","_plugin","_xcode","_utils","e","__esModule","default","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","projectName","modRequest","console","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","log","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 { 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,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,MAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAA4C,SAAAE,uBAAAS,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,SAAsC,EACtCC,KAAiC,KACS;EAC1C;EACA,MAAMC,WAAW,GAAGH,MAAM,CAACI,UAAU,CAACD,WAAW,IAAI,EAAE;EACvD,IAAI,CAACA,WAAW,EAAE;IAChBE,OAAO,CAACC,IAAI,CACV,yDACF,CAAC;IACD,OAAON,MAAM;EACf;;EAEA;EACA,MAAMO,YAAY,GAAGP,MAAM,CAACQ,UAAU;EACtC,MAAMC,WAAW,GAAGT,MAAM,CAACI,UAAU,CAACK,WAAW;EACjD,MAAMC,cAAc,GAAGC,aAAI,CAACC,IAAI,CAACH,WAAW,EAAE,KAAK,CAAC;EAEpD,MAAMI,KAAK,GAAG,IAAAC,iCAA0B,EAACP,YAAY,EAAEJ,WAAW,CAAC;EACnE,IAAID,KAAK,CAACa,gBAAgB,EAAE;IAC1B;IACAC,sCAAsC,CAAC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ACxB,6GAA6G;EAC/G,MAAMC,oBAAoB,GAAGnC,OAAO,CAAC4B,KAAK,CAACM,oBAAoB,CAAC;EAEhE,IAAI,CAACC,oBAAoB,EAAE;IACzBjF,OAAO,CAACC,IAAI,CAAC,oDAAoD,CAAC;IAClE,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":[]}
@@ -39,7 +39,7 @@ const withGoogleServicesJsonFile = (config, cioProps) => {
39
39
  try {
40
40
  _fileManagement.FileManagement.copyFile(googleServicesFile, `${iosPath}/GoogleService-Info.plist`);
41
41
  addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');
42
- } catch (e) {
42
+ } catch {
43
43
  console.error(`There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`);
44
44
  }
45
45
  } else {
@@ -1 +1 @@
1
- {"version":3,"names":["_configPlugins","require","_fileManagement","_utils","withGoogleServicesJsonFile","config","cioProps","withXcodeProject","props","_cioProps$pushNotific","useFcm","isFcmPushProvider","console","log","iosPath","modRequest","platformProjectRoot","googleServicesFile","pushNotification","appName","projectName","FileManagement","exists","_config$ios","ios","warn","copyFile","addFileToXcodeProject","modResults","e","error","exports","project","fileName","groupName","filepath","IOSConfig","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,IAAAA,cAAA,GAAAC,OAAA;AAMA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAEO,MAAMG,0BAEZ,GAAGA,CAACC,MAAM,EAAEC,QAAQ,KAAK;EACxB,OAAO,IAAAC,+BAAgB,EAACF,MAAM,EAAE,MAAOG,KAAK,IAAK;IAAA,IAAAC,qBAAA;IAC/C,MAAMC,MAAM,GAAG,IAAAC,wBAAiB,EAACL,QAAQ,CAAC;IAC1C,IAAI,CAACI,MAAM,EAAE;MACX;MACA,OAAOF,KAAK;IACd;IAEAI,OAAO,CAACC,GAAG,CACT,0GAA0G,GACxG,2DACJ,CAAC;;IAED;IACA,MAAMC,OAAO,GAAGN,KAAK,CAACO,UAAU,CAACC,mBAAmB;IACpD,MAAMC,kBAAkB,IAAAR,qBAAA,GAAGH,QAAQ,CAACY,gBAAgB,cAAAT,qBAAA,uBAAzBA,qBAAA,CAA2BQ,kBAAkB;IACxE,MAAME,OAAO,GAAGX,KAAK,CAACO,UAAU,CAACK,WAAW;IAE5C,IAAIC,8BAAc,CAACC,MAAM,CAAC,GAAGR,OAAO,2BAA2B,CAAC,EAAE;MAChEF,OAAO,CAACC,GAAG,CACT,wBAAwBC,OAAO,wCACjC,CAAC;MACD,OAAON,KAAK;IACd;IAEA,IACEa,8BAAc,CAACC,MAAM,CAAC,GAAGR,OAAO,IAAIK,OAAO,2BAA2B,CAAC,EACvE;MACA;MACA;MACAP,OAAO,CAACC,GAAG,CACT,wBAAwBC,OAAO,IAAIK,OAAO,wCAC5C,CAAC;MACD,OAAOX,KAAK;IACd;IAEA,IAAIS,kBAAkB,IAAII,8BAAc,CAACC,MAAM,CAACL,kBAAkB,CAAC,EAAE;MAAA,IAAAM,WAAA;MACnE,KAAAA,WAAA,GAAIlB,MAAM,CAACmB,GAAG,cAAAD,WAAA,eAAVA,WAAA,CAAYN,kBAAkB,EAAE;QAClCL,OAAO,CAACa,IAAI,CACV,0HAA0H,GACxH,uIACJ,CAAC;MACH;MAEA,IAAI;QACFJ,8BAAc,CAACK,QAAQ,CACrBT,kBAAkB,EAClB,GAAGH,OAAO,2BACZ,CAAC;QAEDa,qBAAqB,CAACnB,KAAK,CAACoB,UAAU,EAAE,0BAA0B,CAAC;MACrE,CAAC,CAAC,OAAOC,CAAC,EAAE;QACVjB,OAAO,CAACkB,KAAK,CACX,gGAAgGhB,OAAO,2BACzG,CAAC;MACH;IACF,CAAC,MAAM;MACLF,OAAO,CAACkB,KAAK,CACX,wCAAwCb,kBAAkB,yDAAyDH,OAAO,2BAC5H,CAAC;IACH;IAEA,OAAON,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACuB,OAAA,CAAA3B,0BAAA,GAAAA,0BAAA;AAEF,SAASuB,qBAAqBA,CAACK,OAAY,EAAEC,QAAgB,EAAE;EAC7D,MAAMC,SAAS,GAAG,WAAW;EAC7B,MAAMC,QAAQ,GAAGF,QAAQ;EAEzB,IAAI,CAACG,wBAAS,CAACC,UAAU,CAACC,sBAAsB,CAACN,OAAO,EAAEE,SAAS,CAAC,EAAE;IACpEtB,OAAO,CAACkB,KAAK,CACX,qEAAqEI,SAAS,mBAChF,CAAC;IACD;EACF;;EAEA;EACAE,wBAAS,CAACC,UAAU,CAACE,sBAAsB,CAAC;IAC1CP,OAAO;IACPG,QAAQ;IACRD,SAAS;IACTM,WAAW,EAAE;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_configPlugins","require","_fileManagement","_utils","withGoogleServicesJsonFile","config","cioProps","withXcodeProject","props","_cioProps$pushNotific","useFcm","isFcmPushProvider","console","log","iosPath","modRequest","platformProjectRoot","googleServicesFile","pushNotification","appName","projectName","FileManagement","exists","_config$ios","ios","warn","copyFile","addFileToXcodeProject","modResults","error","exports","project","fileName","groupName","filepath","IOSConfig","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,IAAAA,cAAA,GAAAC,OAAA;AAGA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,MAAMG,0BAEZ,GAAGA,CAACC,MAAM,EAAEC,QAAQ,KAAK;EACxB,OAAO,IAAAC,+BAAgB,EAACF,MAAM,EAAE,MAAOG,KAAK,IAAK;IAAA,IAAAC,qBAAA;IAC/C,MAAMC,MAAM,GAAG,IAAAC,wBAAiB,EAACL,QAAQ,CAAC;IAC1C,IAAI,CAACI,MAAM,EAAE;MACX;MACA,OAAOF,KAAK;IACd;IAEAI,OAAO,CAACC,GAAG,CACT,0GAA0G,GAC1G,2DACF,CAAC;;IAED;IACA,MAAMC,OAAO,GAAGN,KAAK,CAACO,UAAU,CAACC,mBAAmB;IACpD,MAAMC,kBAAkB,IAAAR,qBAAA,GAAGH,QAAQ,CAACY,gBAAgB,cAAAT,qBAAA,uBAAzBA,qBAAA,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I,CAACG,wBAAS,CAACC,UAAU,CAACC,sBAAsB,CAACN,OAAO,EAAEE,SAAS,CAAC,EAAE;IACpErB,OAAO,CAACiB,KAAK,CACX,qEAAqEI,SAAS,mBAChF,CAAC;IACD;EACF;;EAEA;EACAE,wBAAS,CAACC,UAAU,CAACE,sBAAsB,CAAC;IAC1CP,OAAO;IACPG,QAAQ;IACRD,SAAS;IACTM,WAAW,EAAE;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -8,16 +8,17 @@ var _configPlugins = require("@expo/config-plugins");
8
8
  var _ios = require("../helpers/constants/ios");
9
9
  var _codeInjection = require("../helpers/utils/codeInjection");
10
10
  var _injectCIOPodfileCode = require("../helpers/utils/injectCIOPodfileCode");
11
+ var _plugin = require("../utils/plugin");
11
12
  var _fileManagement = require("./../helpers/utils/fileManagement");
12
13
  var _utils = require("./utils");
13
14
  const PLIST_FILENAME = `${_ios.CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
14
15
  const ENV_FILENAME = 'Env.swift';
15
16
  const TARGETED_DEVICE_FAMILY = `"1,2"`;
16
- const addNotificationServiceExtension = async (options, xcodeProject, isExpoVersion53OrHigher) => {
17
+ const addNotificationServiceExtension = async (options, xcodeProject, isExpo53OrHigher) => {
17
18
  try {
18
19
  var _options$pushNotifica;
19
20
  // PushService file is only needed for pre-Expo 53 code generation
20
- if (options.pushNotification && !isExpoVersion53OrHigher) {
21
+ if (options.pushNotification && !isExpo53OrHigher) {
21
22
  await addPushNotificationFile(options, xcodeProject);
22
23
  }
23
24
  if (((_options$pushNotifica = options.pushNotification) === null || _options$pushNotifica === void 0 ? void 0 : _options$pushNotifica.useRichPush) === true) {
@@ -81,6 +82,7 @@ const withCioNotificationsXcodeProject = (configOuter, props) => {
81
82
  };
82
83
  exports.withCioNotificationsXcodeProject = withCioNotificationsXcodeProject;
83
84
  const addRichPushXcodeProj = async (options, xcodeProject) => {
85
+ var _options$pushNotifica2;
84
86
  const {
85
87
  appleTeamId,
86
88
  bundleIdentifier,
@@ -109,13 +111,13 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
109
111
  // Copy platform-specific files
110
112
  platformSpecificFiles.forEach(filename => {
111
113
  const targetFile = getTargetFile(filename);
112
- _fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${isFcmProvider ? 'fcm' : 'apn'}/${filename}`, targetFile);
114
+ _fileManagement.FileManagement.copyFile(`${(0, _plugin.getIosNativeFilesPath)()}/${isFcmProvider ? 'fcm' : 'apn'}/${filename}`, targetFile);
113
115
  });
114
116
 
115
117
  // Copy common files
116
118
  commonFiles.forEach(filename => {
117
119
  const targetFile = getTargetFile(filename);
118
- _fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/common/${filename}`, targetFile);
120
+ _fileManagement.FileManagement.copyFile(`${(0, _plugin.getIosNativeFilesPath)()}/common/${filename}`, targetFile);
119
121
  });
120
122
 
121
123
  /* MODIFY COPIED EXTENSION FILES */
@@ -125,7 +127,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
125
127
  bundleShortVersion,
126
128
  infoPlistTargetFile
127
129
  });
128
- updateNseEnv(options, getTargetFile(ENV_FILENAME));
130
+ updateNseEnv(getTargetFile(ENV_FILENAME), (_options$pushNotifica2 = options.pushNotification) === null || _options$pushNotifica2 === void 0 ? void 0 : _options$pushNotifica2.env);
129
131
 
130
132
  // Create new PBXGroup for the extension
131
133
  const extGroup = xcodeProject.addPbxGroup([...platformSpecificFiles, ...commonFiles],
@@ -134,7 +136,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
134
136
 
135
137
  // Add the new PBXGroup to the top level group. This makes the
136
138
  // files / folder appear in the file explorer in Xcode.
137
- const groups = xcodeProject.hash.project.objects['PBXGroup'];
139
+ const groups = xcodeProject.hash.project.objects.PBXGroup;
138
140
  Object.keys(groups).forEach(key => {
139
141
  if (groups[key].name === undefined && groups[key].path === undefined) {
140
142
  xcodeProject.addToPbxGroup(extGroup.uuid, key);
@@ -146,8 +148,8 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
146
148
  // An upstream fix should be made to the code referenced in this link:
147
149
  // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
148
150
  const projObjects = xcodeProject.hash.project.objects;
149
- projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
150
- projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
151
+ projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};
152
+ projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};
151
153
  if (xcodeProject.pbxTargetByName(_ios.CIO_NOTIFICATION_TARGET_NAME)) {
152
154
  console.warn(`${_ios.CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
153
155
  return;
@@ -191,20 +193,16 @@ const updateNseInfoPlist = payload => {
191
193
  }
192
194
  _fileManagement.FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
193
195
  };
194
- const updateNseEnv = (options, envFileName) => {
195
- var _options$pushNotifica2;
196
+ const updateNseEnv = (envFileName, richPushConfig) => {
196
197
  const CDP_API_KEY_RE = /\{\{CDP_API_KEY\}\}/;
197
198
  const REGION_RE = /\{\{REGION\}\}/;
198
199
  let envFileContent = _fileManagement.FileManagement.readFile(envFileName);
199
- const {
200
- cdpApiKey,
201
- region
202
- } = ((_options$pushNotifica2 = options.pushNotification) === null || _options$pushNotifica2 === void 0 ? void 0 : _options$pushNotifica2.env) || {
203
- cdpApiKey: undefined,
204
- region: undefined
205
- };
200
+
201
+ // Use merged config values (config takes precedence over env)
202
+ const cdpApiKey = richPushConfig === null || richPushConfig === void 0 ? void 0 : richPushConfig.cdpApiKey;
203
+ const region = richPushConfig === null || richPushConfig === void 0 ? void 0 : richPushConfig.region;
206
204
  if (!cdpApiKey) {
207
- throw new Error('Adding NotificationServiceExtension failed: ios.pushNotification.env.cdpApiKey is missing from app.config.js or app.json.');
205
+ throw new Error('NotificationServiceExtension failed: cdpApiKey missing. Provide in config.cdpApiKey or ios.pushNotification.env.cdpApiKey.');
208
206
  }
209
207
  envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, CDP_API_KEY_RE, cdpApiKey);
210
208
  if (region) {
@@ -241,7 +239,7 @@ async function addPushNotificationFile(options, xcodeProject) {
241
239
  _fileManagement.FileManagement.mkdir(appPath, {
242
240
  recursive: true
243
241
  });
244
- _fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${sourceFile}`, targetFile);
242
+ _fileManagement.FileManagement.copyFile(`${(0, _plugin.getIosNativeFilesPath)()}/${sourceFile}`, targetFile);
245
243
  } else {
246
244
  console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);
247
245
  return;