customerio-expo-plugin 3.2.0 → 3.4.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 (78) hide show
  1. package/package.json +8 -2
  2. package/plugin/lib/commonjs/helpers/constants/ios.js +76 -8
  3. package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
  4. package/plugin/lib/commonjs/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
  5. package/plugin/lib/commonjs/helpers/native-files/ios/apn/NotificationService.swift +1 -1
  6. package/plugin/lib/commonjs/helpers/native-files/ios/apn/PushService.swift +1 -1
  7. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
  8. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
  9. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/PushService.swift +1 -1
  10. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +20 -7
  11. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  12. package/plugin/lib/commonjs/index.js +7 -0
  13. package/plugin/lib/commonjs/index.js.map +1 -1
  14. package/plugin/lib/commonjs/ios/withCIOIos.js +17 -0
  15. package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
  16. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +24 -15
  17. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  18. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +45 -11
  19. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  20. package/plugin/lib/commonjs/postInstallHelper.js +58 -11
  21. package/plugin/lib/commonjs/postInstallHelper.js.map +1 -1
  22. package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
  23. package/plugin/lib/commonjs/utils/resolveRNSDK.js +97 -0
  24. package/plugin/lib/commonjs/utils/resolveRNSDK.js.map +1 -0
  25. package/plugin/lib/commonjs/utils/validation.js +13 -0
  26. package/plugin/lib/commonjs/utils/validation.js.map +1 -1
  27. package/plugin/lib/commonjs/utils/writeExpoVersion.js +56 -0
  28. package/plugin/lib/commonjs/utils/writeExpoVersion.js.map +1 -0
  29. package/plugin/lib/module/helpers/constants/ios.js +75 -8
  30. package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
  31. package/plugin/lib/module/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
  32. package/plugin/lib/module/helpers/native-files/ios/apn/NotificationService.swift +1 -1
  33. package/plugin/lib/module/helpers/native-files/ios/apn/PushService.swift +1 -1
  34. package/plugin/lib/module/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
  35. package/plugin/lib/module/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
  36. package/plugin/lib/module/helpers/native-files/ios/fcm/PushService.swift +1 -1
  37. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +20 -7
  38. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  39. package/plugin/lib/module/index.js +7 -0
  40. package/plugin/lib/module/index.js.map +1 -1
  41. package/plugin/lib/module/ios/withCIOIos.js +17 -0
  42. package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
  43. package/plugin/lib/module/ios/withCIOIosSwift.js +24 -15
  44. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  45. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +45 -11
  46. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  47. package/plugin/lib/module/postInstallHelper.js +58 -11
  48. package/plugin/lib/module/postInstallHelper.js.map +1 -1
  49. package/plugin/lib/module/types/cio-types.js.map +1 -1
  50. package/plugin/lib/module/utils/resolveRNSDK.js +88 -0
  51. package/plugin/lib/module/utils/resolveRNSDK.js.map +1 -0
  52. package/plugin/lib/module/utils/validation.js +13 -1
  53. package/plugin/lib/module/utils/validation.js.map +1 -1
  54. package/plugin/lib/module/utils/writeExpoVersion.js +48 -0
  55. package/plugin/lib/module/utils/writeExpoVersion.js.map +1 -0
  56. package/plugin/lib/typescript/helpers/constants/ios.d.ts +18 -0
  57. package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +11 -1
  58. package/plugin/lib/typescript/types/cio-types.d.ts +7 -0
  59. package/plugin/lib/typescript/utils/resolveRNSDK.d.ts +7 -0
  60. package/plugin/lib/typescript/utils/validation.d.ts +3 -2
  61. package/plugin/lib/typescript/utils/writeExpoVersion.d.ts +3 -0
  62. package/plugin/src/helpers/constants/ios.ts +87 -8
  63. package/plugin/src/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
  64. package/plugin/src/helpers/native-files/ios/apn/NotificationService.swift +1 -1
  65. package/plugin/src/helpers/native-files/ios/apn/PushService.swift +1 -1
  66. package/plugin/src/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
  67. package/plugin/src/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
  68. package/plugin/src/helpers/native-files/ios/fcm/PushService.swift +1 -1
  69. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +22 -10
  70. package/plugin/src/index.ts +7 -0
  71. package/plugin/src/ios/withCIOIos.ts +16 -0
  72. package/plugin/src/ios/withCIOIosSwift.ts +35 -12
  73. package/plugin/src/ios/withNotificationsXcodeProject.ts +56 -1
  74. package/plugin/src/postInstallHelper.js +75 -17
  75. package/plugin/src/types/cio-types.ts +8 -0
  76. package/plugin/src/utils/resolveRNSDK.ts +118 -0
  77. package/plugin/src/utils/validation.ts +18 -1
  78. package/plugin/src/utils/writeExpoVersion.ts +62 -0
@@ -1,5 +1,7 @@
1
+ import { withEntitlementsPlist } from '@expo/config-plugins';
1
2
  import { mergeConfigWithEnvValues } from '../utils/config';
2
3
  import { logger } from '../utils/logger';
4
+ import { validatePushNotificationOptions } from '../utils/validation';
3
5
  import { isExpoVersion53OrHigher } from './utils';
4
6
  import { withAppDelegateModifications } from './withAppDelegateModifications';
5
7
  import { withCIOIosSwift } from './withCIOIosSwift';
@@ -11,6 +13,8 @@ export function withCIOIos(config, sdkConfig, props, location) {
11
13
  const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);
12
14
  const locationEnabled = (location === null || location === void 0 ? void 0 : location.enabled) === true;
13
15
  if (platformConfig !== null && platformConfig !== void 0 && platformConfig.pushNotification) {
16
+ var _platformConfig$pushN;
17
+ validatePushNotificationOptions(platformConfig.pushNotification);
14
18
  if (isSwiftProject) {
15
19
  config = withCIOIosSwift(config, sdkConfig, platformConfig, location);
16
20
  } else {
@@ -28,6 +32,19 @@ export function withCIOIos(config, sdkConfig, props, location) {
28
32
  }
29
33
  });
30
34
  config = withGoogleServicesJsonFile(config, platformConfig);
35
+
36
+ // Merge App Group entitlements on host only when appGroupId is explicitly set
37
+ const appGroupId = (_platformConfig$pushN = platformConfig.pushNotification) === null || _platformConfig$pushN === void 0 ? void 0 : _platformConfig$pushN.appGroupId;
38
+ if (appGroupId) {
39
+ config = withEntitlementsPlist(config, entitlementsConfig => {
40
+ const entitlements = entitlementsConfig.modResults;
41
+ const existing = entitlements['com.apple.security.application-groups'] ?? [];
42
+ if (!existing.includes(appGroupId)) {
43
+ entitlements['com.apple.security.application-groups'] = [...existing, appGroupId];
44
+ }
45
+ return entitlementsConfig;
46
+ });
47
+ }
31
48
  } else if (sdkConfig && isSwiftProject) {
32
49
  config = withCIOIosSwift(config, sdkConfig, platformConfig, location);
33
50
  if (locationEnabled) {
@@ -1 +1 @@
1
- {"version":3,"names":["mergeConfigWithEnvValues","logger","isExpoVersion53OrHigher","withAppDelegateModifications","withCIOIosSwift","withGoogleServicesJsonFile","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","sdkConfig","props","location","isSwiftProject","platformConfig","mergeDeprecatedPropertiesAndLogWarnings","locationEnabled","enabled","pushNotification","env","podfileOptions","hasPush","deprecatedTopLevelProperties","showPushAppInForeground","autoTrackPushEvents","handleDeeplinkInKilledState","disableNotificationRegistration","autoFetchDeviceToken","Object","entries","forEach","key","value","undefined","warn","propKey"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginPushNotificationOptions,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { mergeConfigWithEnvValues } from '../utils/config';\nimport { logger } from '../utils/logger';\nimport { isExpoVersion53OrHigher } from './utils';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCIOIosSwift } from './withCIOIosSwift';\nimport { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n) {\n const isSwiftProject = isExpoVersion53OrHigher(config);\n const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);\n const locationEnabled = location?.enabled === true;\n\n if (platformConfig?.pushNotification) {\n if (isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig, location);\n } else {\n // Auto initialization is only supported in Swift projects (Expo SDK 53+)\n // Legacy Objective-C projects only support push notifications\n config = withAppDelegateModifications(config, platformConfig);\n }\n\n platformConfig.pushNotification.env = platformConfig.pushNotification.env\n || mergeConfigWithEnvValues(platformConfig, sdkConfig);\n config = withCioNotificationsXcodeProject(config, platformConfig);\n config = withCioXcodeProject(config, {\n ...platformConfig,\n podfileOptions: {\n locationEnabled,\n hasPush: true,\n },\n });\n config = withGoogleServicesJsonFile(config, platformConfig);\n } else if (sdkConfig && isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig, location);\n if (locationEnabled) {\n config = withCioXcodeProject(config, {\n ...platformConfig,\n podfileOptions: { locationEnabled: true, hasPush: false },\n });\n }\n } else if (locationEnabled) {\n // Location-only: no push, no config. Still add Podfile location subspec so CIO_LOCATION_ENABLED is set and native location code is included.\n config = withCioXcodeProject(config, {\n ...platformConfig,\n podfileOptions: { locationEnabled: true, hasPush: false },\n });\n }\n\n return config;\n}\n\n/** The basic purpose of this function is to centralize where we handle the deprecation\n by merging the deprecated properties into the new ios.pushNotification.* properties\n and logging a warning if they are set. This way, we can remove the deprecated properties\n from the top level of the ios object in the future, and update this function\n while the rest of the plugin code remains unchanged.\n*/\nconst mergeDeprecatedPropertiesAndLogWarnings = (\n props?: CustomerIOPluginOptionsIOS,\n): CustomerIOPluginOptionsIOS | undefined => {\n // The deprecatedTopLevelProperties maps the top level properties\n // that are deprecated to the new ios.pushNotification.* properties\n // that should be used instead. The deprecated properties are\n // still available for backwards compatibility, but they will\n // be removed in the future.\n\n if (!props) {\n return props\n }\n\n const deprecatedTopLevelProperties = {\n showPushAppInForeground: props.showPushAppInForeground,\n autoTrackPushEvents: props.autoTrackPushEvents,\n handleDeeplinkInKilledState: props.handleDeeplinkInKilledState,\n disableNotificationRegistration: props.disableNotificationRegistration,\n autoFetchDeviceToken: props.autoFetchDeviceToken,\n };\n\n // loop over all the deprecated properties and log a warning if they are set\n Object.entries(deprecatedTopLevelProperties).forEach(([key, value]) => {\n if (value !== undefined) {\n logger.warn(\n `The ios.${key} property is deprecated. Please use ios.pushNotification.${key} instead.`\n );\n\n if (props.pushNotification === undefined) {\n props.pushNotification = {} as CustomerIOPluginPushNotificationOptions;\n }\n const propKey = key as keyof CustomerIOPluginPushNotificationOptions;\n if (props.pushNotification[propKey] === undefined) {\n props.pushNotification = {\n ...props.pushNotification,\n [propKey]: value,\n };\n } else {\n logger.warn(\n `The ios.${key} property is deprecated. Since the value of ios.pushNotification.${key} is set, it will be used.`\n );\n }\n }\n });\n\n return props;\n};\n"],"mappings":"AAOA,SAASA,wBAAwB,QAAQ,iBAAiB;AAC1D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,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,OAAO,GAAGJ,GAAoD;MACpE,IAAIpB,KAAK,CAACO,gBAAgB,CAACiB,OAAO,CAAC,KAAKF,SAAS,EAAE;QACjDtB,KAAK,CAACO,gBAAgB,GAAG;UACvB,GAAGP,KAAK,CAACO,gBAAgB;UACzB,CAACiB,OAAO,GAAGH;QACb,CAAC;MACH,CAAC,MAAM;QACL/B,MAAM,CAACiC,IAAI,CACT,WAAWH,GAAG,oEAAoEA,GAAG,2BACvF,CAAC;MACH;IACF;EACF,CAAC,CAAC;EAEF,OAAOpB,KAAK;AACd,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withEntitlementsPlist","mergeConfigWithEnvValues","logger","validatePushNotificationOptions","isExpoVersion53OrHigher","withAppDelegateModifications","withCIOIosSwift","withGoogleServicesJsonFile","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","sdkConfig","props","location","isSwiftProject","platformConfig","mergeDeprecatedPropertiesAndLogWarnings","locationEnabled","enabled","pushNotification","_platformConfig$pushN","env","podfileOptions","hasPush","appGroupId","entitlementsConfig","entitlements","modResults","existing","includes","deprecatedTopLevelProperties","showPushAppInForeground","autoTrackPushEvents","handleDeeplinkInKilledState","disableNotificationRegistration","autoFetchDeviceToken","Object","entries","forEach","key","value","undefined","warn","propKey"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\nimport { withEntitlementsPlist } from '@expo/config-plugins';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginPushNotificationOptions,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { mergeConfigWithEnvValues } from '../utils/config';\nimport { logger } from '../utils/logger';\nimport { validatePushNotificationOptions } from '../utils/validation';\nimport { isExpoVersion53OrHigher } from './utils';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCIOIosSwift } from './withCIOIosSwift';\nimport { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n) {\n const isSwiftProject = isExpoVersion53OrHigher(config);\n const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);\n const locationEnabled = location?.enabled === true;\n\n if (platformConfig?.pushNotification) {\n validatePushNotificationOptions(platformConfig.pushNotification);\n if (isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig, location);\n } else {\n // Auto initialization is only supported in Swift projects (Expo SDK 53+)\n // Legacy Objective-C projects only support push notifications\n config = withAppDelegateModifications(config, platformConfig);\n }\n\n platformConfig.pushNotification.env = platformConfig.pushNotification.env\n || mergeConfigWithEnvValues(platformConfig, sdkConfig);\n config = withCioNotificationsXcodeProject(config, platformConfig);\n config = withCioXcodeProject(config, {\n ...platformConfig,\n podfileOptions: {\n locationEnabled,\n hasPush: true,\n },\n });\n config = withGoogleServicesJsonFile(config, platformConfig);\n\n // Merge App Group entitlements on host only when appGroupId is explicitly set\n const appGroupId = platformConfig.pushNotification?.appGroupId;\n if (appGroupId) {\n config = withEntitlementsPlist(config, (entitlementsConfig) => {\n const entitlements = entitlementsConfig.modResults as Record<string, unknown>;\n const existing = (entitlements['com.apple.security.application-groups'] as string[] | undefined) ?? [];\n if (!existing.includes(appGroupId)) {\n entitlements['com.apple.security.application-groups'] = [...existing, appGroupId];\n }\n return entitlementsConfig;\n });\n }\n } else if (sdkConfig && isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig, location);\n if (locationEnabled) {\n config = withCioXcodeProject(config, {\n ...platformConfig,\n podfileOptions: { locationEnabled: true, hasPush: false },\n });\n }\n } else if (locationEnabled) {\n // Location-only: no push, no config. Still add Podfile location subspec so CIO_LOCATION_ENABLED is set and native location code is included.\n config = withCioXcodeProject(config, {\n ...platformConfig,\n podfileOptions: { locationEnabled: true, hasPush: false },\n });\n }\n\n return config;\n}\n\n/** The basic purpose of this function is to centralize where we handle the deprecation\n by merging the deprecated properties into the new ios.pushNotification.* properties\n and logging a warning if they are set. This way, we can remove the deprecated properties\n from the top level of the ios object in the future, and update this function\n while the rest of the plugin code remains unchanged.\n*/\nconst mergeDeprecatedPropertiesAndLogWarnings = (\n props?: CustomerIOPluginOptionsIOS,\n): CustomerIOPluginOptionsIOS | undefined => {\n // The deprecatedTopLevelProperties maps the top level properties\n // that are deprecated to the new ios.pushNotification.* properties\n // that should be used instead. The deprecated properties are\n // still available for backwards compatibility, but they will\n // be removed in the future.\n\n if (!props) {\n return props\n }\n\n const deprecatedTopLevelProperties = {\n showPushAppInForeground: props.showPushAppInForeground,\n autoTrackPushEvents: props.autoTrackPushEvents,\n handleDeeplinkInKilledState: props.handleDeeplinkInKilledState,\n disableNotificationRegistration: props.disableNotificationRegistration,\n autoFetchDeviceToken: props.autoFetchDeviceToken,\n };\n\n // loop over all the deprecated properties and log a warning if they are set\n Object.entries(deprecatedTopLevelProperties).forEach(([key, value]) => {\n if (value !== undefined) {\n logger.warn(\n `The ios.${key} property is deprecated. Please use ios.pushNotification.${key} instead.`\n );\n\n if (props.pushNotification === undefined) {\n props.pushNotification = {} as CustomerIOPluginPushNotificationOptions;\n }\n const propKey = key as keyof CustomerIOPluginPushNotificationOptions;\n if (props.pushNotification[propKey] === undefined) {\n props.pushNotification = {\n ...props.pushNotification,\n [propKey]: value,\n };\n } else {\n logger.warn(\n `The ios.${key} property is deprecated. Since the value of ios.pushNotification.${key} is set, it will be used.`\n );\n }\n }\n });\n\n return props;\n};\n"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,sBAAsB;AAO5D,SAASC,wBAAwB,QAAQ,iBAAiB;AAC1D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,+BAA+B,QAAQ,qBAAqB;AACrE,SAASC,uBAAuB,QAAQ,SAAS;AACjD,SAASC,4BAA4B,QAAQ,gCAA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mBAAmB,EAAEpB,KAAK,CAACoB,mBAAmB;IAC9CC,2BAA2B,EAAErB,KAAK,CAACqB,2BAA2B;IAC9DC,+BAA+B,EAAEtB,KAAK,CAACsB,+BAA+B;IACtEC,oBAAoB,EAAEvB,KAAK,CAACuB;EAC9B,CAAC;;EAED;EACAC,MAAM,CAACC,OAAO,CAACP,4BAA4B,CAAC,CAACQ,OAAO,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IACrE,IAAIA,KAAK,KAAKC,SAAS,EAAE;MACvBxC,MAAM,CAACyC,IAAI,CACT,WAAWH,GAAG,4DAA4DA,GAAG,WAC/E,CAAC;MAED,IAAI3B,KAAK,CAACO,gBAAgB,KAAKsB,SAAS,EAAE;QACxC7B,KAAK,CAACO,gBAAgB,GAAG,CAAC,CAA4C;MACxE;MACA,MAAMwB,OAAO,GAAGJ,GAAoD;MACpE,IAAI3B,KAAK,CAACO,gBAAgB,CAACwB,OAAO,CAAC,KAAKF,SAAS,EAAE;QACjD7B,KAAK,CAACO,gBAAgB,GAAG;UACvB,GAAGP,KAAK,CAACO,gBAAgB;UACzB,CAACwB,OAAO,GAAGH;QACb,CAAC;MACH,CAAC,MAAM;QACLvC,MAAM,CAACyC,IAAI,CACT,WAAWH,GAAG,oEAAoEA,GAAG,2BACvF,CAAC;MACH;IACF;EACF,CAAC,CAAC;EAEF,OAAO3B,KAAK;AACd,CAAC","ignoreList":[]}
@@ -63,7 +63,7 @@ const copyAndConfigurePushAppDelegateHandler = ({
63
63
  props,
64
64
  location
65
65
  }) => {
66
- var _props$pushNotificati, _props$pushNotificati2, _props$pushNotificati3, _props$pushNotificati4;
66
+ var _props$pushNotificati, _props$pushNotificati2, _props$pushNotificati3, _props$pushNotificati4, _props$pushNotificati5;
67
67
  const useFcm = isFcmPushProvider(props);
68
68
 
69
69
  // Source path for the handler file
@@ -88,6 +88,9 @@ const copyAndConfigurePushAppDelegateHandler = ({
88
88
  handlerFileContent = replaceCodeByRegex(handlerFileContent, /\{\{AUTO_FETCH_DEVICE_TOKEN\}\}/, autoFetchDeviceToken.toString());
89
89
  const showPushAppInForeground = ((_props$pushNotificati4 = props.pushNotification) === null || _props$pushNotificati4 === void 0 ? void 0 : _props$pushNotificati4.showPushAppInForeground) !== false;
90
90
  handlerFileContent = replaceCodeByRegex(handlerFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
91
+ const appGroupId = (_props$pushNotificati5 = props.pushNotification) === null || _props$pushNotificati5 === void 0 ? void 0 : _props$pushNotificati5.appGroupId;
92
+ const appGroupIdBuilderLine = appGroupId ? ` .appGroupId(${JSON.stringify(appGroupId)})\n` : '';
93
+ handlerFileContent = replaceCodeByRegex(handlerFileContent, /\{\{APP_GROUP_ID_BUILDER_LINE\}\}/, appGroupIdBuilderLine);
91
94
 
92
95
  // Add auto initialization if sdkConfig is provided
93
96
  if (sdkConfig) {
@@ -158,7 +161,7 @@ export const withCIOIosSwift = (configOuter, sdkConfig, props, location) => {
158
161
  * Modify the AppDelegate to integrate with Customer.io SDK
159
162
  */
160
163
  const modifyAppDelegateWithPushAppDelegateHandler = (config, props) => {
161
- var _props$pushNotificati5;
164
+ var _props$pushNotificati6;
162
165
  const appDelegateContent = config.modResults.contents;
163
166
 
164
167
  // Check if modifications have already been applied
@@ -180,7 +183,7 @@ const modifyAppDelegateWithPushAppDelegateHandler = (config, props) => {
180
183
  modifiedContent = addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);
181
184
 
182
185
  // Add deep link handling for killed state if enabled
183
- if (((_props$pushNotificati5 = props.pushNotification) === null || _props$pushNotificati5 === void 0 ? void 0 : _props$pushNotificati5.handleDeeplinkInKilledState) === true) {
186
+ if (((_props$pushNotificati6 = props.pushNotification) === null || _props$pushNotificati6 === void 0 ? void 0 : _props$pushNotificati6.handleDeeplinkInKilledState) === true) {
184
187
  modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);
185
188
  }
186
189
  config.modResults.contents = modifiedContent;
@@ -329,29 +332,35 @@ const addDidFailToRegisterForRemoteNotificationsWithError = content => {
329
332
 
330
333
  /**
331
334
  * Add deep link handling for killed state
332
- * This replaces the return statement with deep link handling code
333
- * and a modified return statement that uses modifiedLaunchOptions
335
+ *
336
+ * On modern Expo Swift templates, RN is bootstrapped by `factory.startReactNative(...)`
337
+ * inside an `#if os(iOS) || os(tvOS)` guard, *before* the trailing `return super.application(...)`.
338
+ * The deep-link block must run before that call so `modifiedLaunchOptions` flows into RN's
339
+ * initial launchOptions; otherwise the workaround is a no-op.
340
+ *
341
+ * For older templates (no `factory.startReactNative` — `super.application(...)` is what
342
+ * starts RN), the snippet is injected before the return statement as before.
334
343
  */
335
344
  const addHandleDeeplinkInKilledState = content => {
336
- // Check if deep link code snippet is already present
337
345
  const deepLinkMarker = 'Deep link workaround for app killed state start';
338
346
  if (content.includes(deepLinkMarker)) {
339
347
  return content;
340
348
  }
341
-
342
- // Find the return statement with launchOptions
343
349
  const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
344
- const returnStatementMatch = content.match(returnStatementRegex);
345
- if (!returnStatementMatch) {
350
+ const modifiedReturnStatement = 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';
351
+ const factoryStartRegex = /(\s*)#if\s+os\(iOS\)\s*\|\|\s*os\(tvOS\)([\s\S]*?factory\.startReactNative\s*\([\s\S]*?launchOptions:\s*)launchOptions(\s*\)[\s\S]*?#endif)/;
352
+ if (factoryStartRegex.test(content)) {
353
+ let result = content.replace(factoryStartRegex, `\n${CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET}\n#if os(iOS) || os(tvOS)$2modifiedLaunchOptions$3`);
354
+ if (returnStatementRegex.test(result)) {
355
+ result = result.replace(returnStatementRegex, modifiedReturnStatement);
356
+ }
357
+ return result;
358
+ }
359
+ if (!returnStatementRegex.test(content)) {
346
360
  logger.warn('Could not find return statement with launchOptions');
347
361
  return content;
348
362
  }
349
-
350
- // Create the replacement code with deep link handling and modified return statement
351
- const modifiedReturnStatement = 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';
352
363
  const replacementCode = CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET + '\n\n ' + modifiedReturnStatement;
353
-
354
- // Replace the return statement with deep link handling code and modified return statement
355
364
  return content.replace(returnStatementRegex, replacementCode);
356
365
  };
357
366
  //# sourceMappingURL=withCIOIosSwift.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withAppDelegate","withXcodeProject","path","PLATFORM","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","replaceCodeByRegex","FileManagement","patchNativeSDKInitializer","logger","getIosNativeFilesPath","copyFileToXcode","getOrCreateCustomerIOGroup","isFcmPushProvider","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","location","projectName","modRequest","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","join","group","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","useFcm","handlerSourcePath","handlerDestPath","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","replace","writeFile","_sdkConfig$location","locationOptions","enabled","trackingMode","undefined","filename","sourcePath","sourceFilePath","targetFileName","transform","content","IOS","customerIOGroup","withCIOIosSwift","configOuter","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","_props$pushNotificati5","appDelegateContent","contents","includes","info","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type {\n ExportedConfigWithProps,\n XcodeProject,\n} from '@expo/config-plugins';\nimport { withAppDelegate, withXcodeProject } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\nimport { PLATFORM } from '../helpers/constants/common';\nimport {\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_CALL,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { copyFileToXcode, getOrCreateCustomerIOGroup } from '../utils/xcode';\nimport { isFcmPushProvider } from './utils';\n\n// Constants\nconst CIO_SDK_APP_DELEGATE_HANDLER_CLASS = 'CioSdkAppDelegateHandler';\nconst CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}.swift`;\n\n/**\n * Copy and configure the CioSdkAppDelegateHandler.swift file\n */\nconst copyAndConfigureAppDelegateHandler = (\n config: ExportedConfigWithProps<XcodeProject>,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n): ExportedConfigWithProps<XcodeProject> => {\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n logger.warn(\n 'Project name is undefined, cannot copy CustomerIO files'\n );\n return config;\n }\n\n // Add files to the Xcode project\n const xcodeProject = config.modResults;\n const projectRoot = config.modRequest.projectRoot;\n const iosProjectRoot = path.join(projectRoot, 'ios');\n\n const group = getOrCreateCustomerIOGroup(xcodeProject, projectName);\n if (props?.pushNotification) {\n // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support\n copyAndConfigurePushAppDelegateHandler({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n location,\n });\n } else if (sdkConfig) {\n // Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications\n copyAndConfigureNativeSDKInitializer({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n location,\n });\n }\n\n return config;\n};\n\nconst copyAndConfigurePushAppDelegateHandler = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n location,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig | undefined;\n props: CustomerIOPluginOptionsIOS;\n location?: CustomerIOPluginLocationOptions;\n}) => {\n const useFcm = isFcmPushProvider(props);\n\n // Source path for the handler file\n const handlerSourcePath = path.join(\n getIosNativeFilesPath(),\n useFcm ? 'fcm' : 'apn',\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n const handlerDestPath = path.join(\n iosProjectRoot,\n projectName,\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n FileManagement.copyFile(handlerSourcePath, handlerDestPath);\n\n // Add the file to the Xcode project\n xcodeProject.addSourceFile(\n `${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`,\n null,\n group\n );\n\n let handlerFileContent = FileManagement.readFile(handlerDestPath);\n\n const disableNotificationRegistration =\n props.pushNotification?.disableNotificationRegistration;\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2;\n }\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n snippet\n );\n\n const autoTrackPushEvents =\n props.pushNotification?.autoTrackPushEvents !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n props.pushNotification?.autoFetchDeviceToken !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n props.pushNotification?.showPushAppInForeground !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n // Also copy CustomerIOSDKInitializer.swift for auto-initialization\n copyAndConfigureNativeSDKInitializer({ xcodeProject, group, iosProjectRoot, projectName, sdkConfig, location });\n\n // Inject auto initialization call before MessagingPush initialization\n handlerFileContent = handlerFileContent.replace(CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET + '$1');\n }\n\n FileManagement.writeFile(handlerDestPath, handlerFileContent);\n};\n\nconst copyAndConfigureNativeSDKInitializer = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n location,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n}) => {\n const locationOptions = location\n ? { enabled: location.enabled === true, trackingMode: sdkConfig?.location?.trackingMode }\n : undefined;\n const filename = 'CustomerIOSDKInitializer.swift';\n const sourcePath = path.join(getIosNativeFilesPath(), filename);\n // Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler\n copyFileToXcode({\n xcodeProject,\n iosProjectRoot,\n projectName,\n sourceFilePath: sourcePath,\n targetFileName: filename,\n transform: (content) =>\n patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig, locationOptions),\n customerIOGroup: group,\n });\n};\n\nexport const withCIOIosSwift = (\n configOuter: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n) => {\n // First, copy required swift files to iOS folder and add it to Xcode project\n configOuter = withXcodeProject(configOuter, async (config) => {\n return copyAndConfigureAppDelegateHandler(config, sdkConfig, props, location);\n });\n\n // Modify the AppDelegate based on configuration\n if (props?.pushNotification) {\n // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithPushAppDelegateHandler(config, props);\n });\n } else if (sdkConfig) {\n // Without push notifications: directly inject auto initialization into AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithNativeSDKInitializer(config);\n });\n } else {\n return configOuter;\n }\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithPushAppDelegateHandler = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n props: CustomerIOPluginOptionsIOS\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Add the handler property declaration\n let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n modifiedContent = modifyDidFinishLaunchingWithOptions(\n modifiedContent,\n ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `\n );\n\n // Add didRegisterForRemoteNotificationsWithDeviceToken implementation\n modifiedContent =\n addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);\n\n // Add didFailToRegisterForRemoteNotificationsWithError implementation\n modifiedContent =\n addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);\n\n // Add deep link handling for killed state if enabled\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);\n }\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithNativeSDKInitializer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n const modifiedContent = modifyDidFinishLaunchingWithOptions(\n appDelegateContent,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n );\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Check if a method exists in the AppDelegate content\n * @param content The AppDelegate content\n * @param methodSignature The method signature to check for\n * @returns true if the method exists, false otherwise\n */\nconst methodExistsInAppDelegate = (\n content: string,\n methodSignature: string\n): boolean => {\n return content.includes(methodSignature);\n};\n\n/**\n * Add handler property declaration to the AppDelegate class\n * This adds the line: let cioSdkHandler = CioSdkAppDelegateHandler()\n * to the AppDelegate class\n */\nconst addHandlerPropertyDeclaration = (content: string): string => {\n // Look for the AppDelegate class declaration\n const classDeclarationRegex = /class\\s+AppDelegate\\s*:\\s*.*\\s*{/;\n const match = content.match(classDeclarationRegex);\n\n if (!match) {\n logger.warn('Could not find AppDelegate class declaration');\n return content;\n }\n\n const position = (match.index ?? 0) + match[0].length;\n return (\n content.substring(0, position) +\n `\\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\\n` +\n content.substring(position)\n );\n};\n\n/**\n * Modify didFinishLaunchingWithOptions to inject Customer.io code\n * Injects the provided code (either handler call or auto initialization) before the return statement\n */\nconst modifyDidFinishLaunchingWithOptions = (content: string, codeToInject: string): string => {\n // Find the return statement in didFinishLaunchingWithOptions\n // Always look for launchOptions since modifiedLaunchOptions is only set later\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn(\n 'Could not find return statement with super.application in didFinishLaunchingWithOptions'\n );\n return content;\n }\n\n // Inject Customer.io code before the return statement\n const insertPosition = returnStatementMatch.index ?? 0;\n\n return (\n content.substring(0, insertPosition) +\n codeToInject +\n content.substring(insertPosition)\n );\n};\n\n/**\n * Add or modify didRegisterForRemoteNotificationsWithDeviceToken implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didRegisterForRemoteNotificationsWithDeviceToken\\s+deviceToken\\s*:\\s*Data\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle device token registration\\n' +\n ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add or modify didFailToRegisterForRemoteNotificationsWithError implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didFailToRegisterForRemoteNotificationsWithError\\s+error\\s*:\\s*Error\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle remote notification registration errors\\n' +\n ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add deep link handling for killed state\n * This replaces the return statement with deep link handling code\n * and a modified return statement that uses modifiedLaunchOptions\n */\nconst addHandleDeeplinkInKilledState = (content: string): string => {\n // Check if deep link code snippet is already present\n const deepLinkMarker = 'Deep link workaround for app killed state start';\n if (content.includes(deepLinkMarker)) {\n return content;\n }\n\n // Find the return statement with launchOptions\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn('Could not find return statement with launchOptions');\n return content;\n }\n\n // Create the replacement code with deep link handling and modified return statement\n const modifiedReturnStatement =\n 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';\n const replacementCode =\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET +\n '\\n\\n ' +\n modifiedReturnStatement;\n\n // Replace the return statement with deep link handling code and modified return statement\n return content.replace(returnStatementRegex, replacementCode);\n};\n"],"mappings":"AAIA,SAASA,eAAe,EAAEC,gBAAgB,QAAQ,sBAAsB;AAExE,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SACEC,+CAA+C,EAC/CC,0CAA0C,EAC1CC,8BAA8B,EAC9BC,iCAAiC,EACjCC,wCAAwC,EACxCC,0CAA0C,QACrC,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,yBAAyB,QAAQ,wCAAwC;AAMlF,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,eAAe,EAAEC,0BAA0B,QAAQ,gBAAgB;AAC5E,SAASC,iBAAiB,QAAQ,SAAS;;AAE3C;AACA,MAAMC,kCAAkC,GAAG,0BAA0B;AACrE,MAAMC,qCAAqC,GAAG,GAAGD,kCAAkC,QAAQ;;AAE3F;AACA;AACA;AACA,MAAME,kCAAkC,GAAGA,CACzCC,MAA6C,EAC7CC,SAA2B,EAC3BC,KAAkC,EAClCC,QAA0C,KACA;EAC1C;EACA,MAAMC,WAAW,GAAGJ,MAAM,CAACK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UREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","replaceCodeByRegex","FileManagement","patchNativeSDKInitializer","logger","getIosNativeFilesPath","copyFileToXcode","getOrCreateCustomerIOGroup","isFcmPushProvider","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","location","projectName","modRequest","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","join","group","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","_props$pushNotificati5","useFcm","handlerSourcePath","handlerDestPath","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","appGroupId","appGroupIdBuilderLine","JSON","stringify","replace","writeFile","_sdkConfig$location","locationOptions","enabled","trackingMode","undefined","filename","sourcePath","sourceFilePath","targetFileName","transform","content","IOS","customerIOGroup","withCIOIosSwift","configOuter","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","_props$pushNotificati6","appDelegateContent","contents","includes","info","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","factoryStartRegex","test","result","replacementCode"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type {\n ExportedConfigWithProps,\n XcodeProject,\n} from '@expo/config-plugins';\nimport { withAppDelegate, withXcodeProject } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\nimport { PLATFORM } from '../helpers/constants/common';\nimport {\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_CALL,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { copyFileToXcode, getOrCreateCustomerIOGroup } from '../utils/xcode';\nimport { isFcmPushProvider } from './utils';\n\n// Constants\nconst CIO_SDK_APP_DELEGATE_HANDLER_CLASS = 'CioSdkAppDelegateHandler';\nconst CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}.swift`;\n\n/**\n * Copy and configure the CioSdkAppDelegateHandler.swift file\n */\nconst copyAndConfigureAppDelegateHandler = (\n config: ExportedConfigWithProps<XcodeProject>,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n): ExportedConfigWithProps<XcodeProject> => {\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n logger.warn(\n 'Project name is undefined, cannot copy CustomerIO files'\n );\n return config;\n }\n\n // Add files to the Xcode project\n const xcodeProject = config.modResults;\n const projectRoot = config.modRequest.projectRoot;\n const iosProjectRoot = path.join(projectRoot, 'ios');\n\n const group = getOrCreateCustomerIOGroup(xcodeProject, projectName);\n if (props?.pushNotification) {\n // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support\n copyAndConfigurePushAppDelegateHandler({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n location,\n });\n } else if (sdkConfig) {\n // Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications\n copyAndConfigureNativeSDKInitializer({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n location,\n });\n }\n\n return config;\n};\n\nconst copyAndConfigurePushAppDelegateHandler = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n location,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig | undefined;\n props: CustomerIOPluginOptionsIOS;\n location?: CustomerIOPluginLocationOptions;\n}) => {\n const useFcm = isFcmPushProvider(props);\n\n // Source path for the handler file\n const handlerSourcePath = path.join(\n getIosNativeFilesPath(),\n useFcm ? 'fcm' : 'apn',\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n const handlerDestPath = path.join(\n iosProjectRoot,\n projectName,\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n FileManagement.copyFile(handlerSourcePath, handlerDestPath);\n\n // Add the file to the Xcode project\n xcodeProject.addSourceFile(\n `${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`,\n null,\n group\n );\n\n let handlerFileContent = FileManagement.readFile(handlerDestPath);\n\n const disableNotificationRegistration =\n props.pushNotification?.disableNotificationRegistration;\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2;\n }\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n snippet\n );\n\n const autoTrackPushEvents =\n props.pushNotification?.autoTrackPushEvents !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n props.pushNotification?.autoFetchDeviceToken !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n props.pushNotification?.showPushAppInForeground !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n const appGroupId = props.pushNotification?.appGroupId;\n const appGroupIdBuilderLine = appGroupId\n ? ` .appGroupId(${JSON.stringify(appGroupId)})\\n`\n : '';\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{APP_GROUP_ID_BUILDER_LINE\\}\\}/,\n appGroupIdBuilderLine\n );\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n // Also copy CustomerIOSDKInitializer.swift for auto-initialization\n copyAndConfigureNativeSDKInitializer({ xcodeProject, group, iosProjectRoot, projectName, sdkConfig, location });\n\n // Inject auto initialization call before MessagingPush initialization\n handlerFileContent = handlerFileContent.replace(CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET + '$1');\n }\n\n FileManagement.writeFile(handlerDestPath, handlerFileContent);\n};\n\nconst copyAndConfigureNativeSDKInitializer = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n location,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n}) => {\n const locationOptions = location\n ? { enabled: location.enabled === true, trackingMode: sdkConfig?.location?.trackingMode }\n : undefined;\n const filename = 'CustomerIOSDKInitializer.swift';\n const sourcePath = path.join(getIosNativeFilesPath(), filename);\n // Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler\n copyFileToXcode({\n xcodeProject,\n iosProjectRoot,\n projectName,\n sourceFilePath: sourcePath,\n targetFileName: filename,\n transform: (content) =>\n patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig, locationOptions),\n customerIOGroup: group,\n });\n};\n\nexport const withCIOIosSwift = (\n configOuter: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n) => {\n // First, copy required swift files to iOS folder and add it to Xcode project\n configOuter = withXcodeProject(configOuter, async (config) => {\n return copyAndConfigureAppDelegateHandler(config, sdkConfig, props, location);\n });\n\n // Modify the AppDelegate based on configuration\n if (props?.pushNotification) {\n // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithPushAppDelegateHandler(config, props);\n });\n } else if (sdkConfig) {\n // Without push notifications: directly inject auto initialization into AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithNativeSDKInitializer(config);\n });\n } else {\n return configOuter;\n }\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithPushAppDelegateHandler = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n props: CustomerIOPluginOptionsIOS\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Add the handler property declaration\n let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n modifiedContent = modifyDidFinishLaunchingWithOptions(\n modifiedContent,\n ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `\n );\n\n // Add didRegisterForRemoteNotificationsWithDeviceToken implementation\n modifiedContent =\n addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);\n\n // Add didFailToRegisterForRemoteNotificationsWithError implementation\n modifiedContent =\n addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);\n\n // Add deep link handling for killed state if enabled\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);\n }\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithNativeSDKInitializer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n const modifiedContent = modifyDidFinishLaunchingWithOptions(\n appDelegateContent,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n );\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Check if a method exists in the AppDelegate content\n * @param content The AppDelegate content\n * @param methodSignature The method signature to check for\n * @returns true if the method exists, false otherwise\n */\nconst methodExistsInAppDelegate = (\n content: string,\n methodSignature: string\n): boolean => {\n return content.includes(methodSignature);\n};\n\n/**\n * Add handler property declaration to the AppDelegate class\n * This adds the line: let cioSdkHandler = CioSdkAppDelegateHandler()\n * to the AppDelegate class\n */\nconst addHandlerPropertyDeclaration = (content: string): string => {\n // Look for the AppDelegate class declaration\n const classDeclarationRegex = /class\\s+AppDelegate\\s*:\\s*.*\\s*{/;\n const match = content.match(classDeclarationRegex);\n\n if (!match) {\n logger.warn('Could not find AppDelegate class declaration');\n return content;\n }\n\n const position = (match.index ?? 0) + match[0].length;\n return (\n content.substring(0, position) +\n `\\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\\n` +\n content.substring(position)\n );\n};\n\n/**\n * Modify didFinishLaunchingWithOptions to inject Customer.io code\n * Injects the provided code (either handler call or auto initialization) before the return statement\n */\nconst modifyDidFinishLaunchingWithOptions = (content: string, codeToInject: string): string => {\n // Find the return statement in didFinishLaunchingWithOptions\n // Always look for launchOptions since modifiedLaunchOptions is only set later\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn(\n 'Could not find return statement with super.application in didFinishLaunchingWithOptions'\n );\n return content;\n }\n\n // Inject Customer.io code before the return statement\n const insertPosition = returnStatementMatch.index ?? 0;\n\n return (\n content.substring(0, insertPosition) +\n codeToInject +\n content.substring(insertPosition)\n );\n};\n\n/**\n * Add or modify didRegisterForRemoteNotificationsWithDeviceToken implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didRegisterForRemoteNotificationsWithDeviceToken\\s+deviceToken\\s*:\\s*Data\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle device token registration\\n' +\n ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add or modify didFailToRegisterForRemoteNotificationsWithError implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didFailToRegisterForRemoteNotificationsWithError\\s+error\\s*:\\s*Error\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle remote notification registration errors\\n' +\n ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add deep link handling for killed state\n *\n * On modern Expo Swift templates, RN is bootstrapped by `factory.startReactNative(...)`\n * inside an `#if os(iOS) || os(tvOS)` guard, *before* the trailing `return super.application(...)`.\n * The deep-link block must run before that call so `modifiedLaunchOptions` flows into RN's\n * initial launchOptions; otherwise the workaround is a no-op.\n *\n * For older templates (no `factory.startReactNative` — `super.application(...)` is what\n * starts RN), the snippet is injected before the return statement as before.\n */\nconst addHandleDeeplinkInKilledState = (content: string): string => {\n const deepLinkMarker = 'Deep link workaround for app killed state start';\n if (content.includes(deepLinkMarker)) {\n return content;\n }\n\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n const modifiedReturnStatement =\n 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';\n\n const factoryStartRegex =\n /(\\s*)#if\\s+os\\(iOS\\)\\s*\\|\\|\\s*os\\(tvOS\\)([\\s\\S]*?factory\\.startReactNative\\s*\\([\\s\\S]*?launchOptions:\\s*)launchOptions(\\s*\\)[\\s\\S]*?#endif)/;\n\n if (factoryStartRegex.test(content)) {\n let result = content.replace(\n factoryStartRegex,\n `\\n${CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET}\\n#if os(iOS) || os(tvOS)$2modifiedLaunchOptions$3`\n );\n if (returnStatementRegex.test(result)) {\n result = result.replace(returnStatementRegex, modifiedReturnStatement);\n }\n return result;\n }\n\n if (!returnStatementRegex.test(content)) {\n logger.warn('Could not find return statement with launchOptions');\n return content;\n }\n const replacementCode =\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET +\n '\\n\\n ' +\n modifiedReturnStatement;\n return content.replace(returnStatementRegex, replacementCode);\n};\n"],"mappings":"AAIA,SAASA,eAAe,EAAEC,gBAAgB,QAAQ,sBAAsB;AAExE,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SACEC,+CAA+C,EAC/CC,0CAA0C,EAC1CC,8BAA8B,EAC9BC,iCAAiC,EACjCC,wCAAwC,EACxCC,0CAA0C,QACrC,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,yBAAyB,QAAQ,wCAAwC;AAMlF,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD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ACA;AACA;AACA,MAAML,8BAA8B,GAAIlB,OAAe,IAAa;EAClE,MAAMsC,cAAc,GAAG,iDAAiD;EACxE,IAAItC,OAAO,CAACU,QAAQ,CAAC4B,cAAc,CAAC,EAAE;IACpC,OAAOtC,OAAO;EAChB;EAEA,MAAM4B,oBAAoB,GACxB,6GAA6G;EAC/G,MAAMW,uBAAuB,GAC3B,6FAA6F;EAE/F,MAAMC,iBAAiB,GACrB,6IAA6I;EAE/I,IAAIA,iBAAiB,CAACC,IAAI,CAACzC,OAAO,CAAC,EAAE;IACnC,IAAI0C,MAAM,GAAG1C,OAAO,CAACZ,OAAO,CAC1BoD,iBAAiB,EACjB,KAAK3G,+CAA+C,oDACtD,CAAC;IACD,IAAI+F,oBAAoB,CAACa,IAAI,CAACC,MAAM,CAAC,EAAE;MACrCA,MAAM,GAAGA,MAAM,CAACtD,OAAO,CAACwC,oBAAoB,EAAEW,uBAAuB,CAAC;IACxE;IACA,OAAOG,MAAM;EACf;EAEA,IAAI,CAACd,oBAAoB,CAACa,IAAI,CAACzC,OAAO,CAAC,EAAE;IACvC1D,MAAM,CAACc,IAAI,CAAC,oDAAoD,CAAC;IACjE,OAAO4C,OAAO;EAChB;EACA,MAAM2C,eAAe,GACnB9G,+CAA+C,GAC/C,UAAU,GACV0G,uBAAuB;EACzB,OAAOvC,OAAO,CAACZ,OAAO,CAACwC,oBAAoB,EAAEe,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
@@ -77,7 +77,7 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
77
77
  });
78
78
  };
79
79
  const addRichPushXcodeProj = async (options, xcodeProject) => {
80
- var _options$pushNotifica2;
80
+ var _options$pushNotifica2, _options$pushNotifica3, _options$pushNotifica4;
81
81
  const {
82
82
  appleTeamId,
83
83
  bundleIdentifier,
@@ -101,6 +101,24 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
101
101
  recursive: true
102
102
  });
103
103
  const platformSpecificFiles = ['NotificationService.swift'];
104
+ const nseEntitlementsFilename = 'NotificationService.entitlements';
105
+ const appGroupId = (_options$pushNotifica2 = options.pushNotification) === null || _options$pushNotifica2 === void 0 ? void 0 : _options$pushNotifica2.appGroupId;
106
+
107
+ // Write NSE entitlements file only when appGroupId is explicitly configured
108
+ if (appGroupId) {
109
+ const nseEntitlementsContent = `<?xml version="1.0" encoding="UTF-8"?>
110
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
111
+ <plist version="1.0">
112
+ <dict>
113
+ <key>com.apple.security.application-groups</key>
114
+ <array>
115
+ <string>${appGroupId}</string>
116
+ </array>
117
+ </dict>
118
+ </plist>
119
+ `;
120
+ FileManagement.writeFile(`${nsePath}/${nseEntitlementsFilename}`, nseEntitlementsContent);
121
+ }
104
122
  const commonFiles = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.m', ENV_FILENAME];
105
123
  const getTargetFile = filename => `${nsePath}/${filename}`;
106
124
  // Copy platform-specific files
@@ -122,12 +140,15 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
122
140
  bundleShortVersion,
123
141
  infoPlistTargetFile
124
142
  });
125
- updateNseEnv(getTargetFile(ENV_FILENAME), (_options$pushNotifica2 = options.pushNotification) === null || _options$pushNotifica2 === void 0 ? void 0 : _options$pushNotifica2.env);
143
+ updateNseEnv(getTargetFile(ENV_FILENAME), (_options$pushNotifica3 = options.pushNotification) === null || _options$pushNotifica3 === void 0 ? void 0 : _options$pushNotifica3.env);
144
+ updateNseNotificationService(getTargetFile('NotificationService.swift'), (_options$pushNotifica4 = options.pushNotification) === null || _options$pushNotifica4 === void 0 ? void 0 : _options$pushNotifica4.appGroupId);
145
+
146
+ // The entitlements file is generated (not copied from source), so it's listed separately
147
+ // for the Xcode group so it appears in the file navigator
148
+ const allGroupFiles = [...platformSpecificFiles, ...commonFiles, ...(appGroupId ? [nseEntitlementsFilename] : [])];
126
149
 
127
150
  // Create new PBXGroup for the extension
128
- const extGroup = xcodeProject.addPbxGroup([...platformSpecificFiles, ...commonFiles],
129
- // Combine platform-specific and common files,
130
- CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
151
+ const extGroup = xcodeProject.addPbxGroup(allGroupFiles, CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
131
152
 
132
153
  // Add the new PBXGroup to the top level group. This makes the
133
154
  // files / folder appear in the file explorer in Xcode.
@@ -169,6 +190,9 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
169
190
  buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
170
191
  buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
171
192
  buildSettingsObj.SWIFT_VERSION = 4.2;
193
+ if (appGroupId) {
194
+ buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${CIO_NOTIFICATION_TARGET_NAME}/${nseEntitlementsFilename}`;
195
+ }
172
196
  }
173
197
  }
174
198
 
@@ -188,6 +212,13 @@ const updateNseInfoPlist = payload => {
188
212
  }
189
213
  FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
190
214
  };
215
+ const updateNseNotificationService = (notificationServiceFile, appGroupId) => {
216
+ const APP_GROUP_ID_BUILDER_LINE_RE = /\{\{APP_GROUP_ID_BUILDER_LINE\}\}/;
217
+ let content = FileManagement.readFile(notificationServiceFile);
218
+ const builderLine = appGroupId ? ` .appGroupId(${JSON.stringify(appGroupId)})\n` : '';
219
+ content = replaceCodeByRegex(content, APP_GROUP_ID_BUILDER_LINE_RE, builderLine);
220
+ FileManagement.writeFile(notificationServiceFile, content);
221
+ };
191
222
  const updateNseEnv = (envFileName, richPushConfig) => {
192
223
  const CDP_API_KEY_RE = /\{\{CDP_API_KEY\}\}/;
193
224
  const REGION_RE = /\{\{REGION\}\}/;
@@ -251,11 +282,11 @@ async function addPushNotificationFile(options, xcodeProject) {
251
282
  xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);
252
283
  }
253
284
  const updatePushFile = (options, envFileName) => {
254
- var _options$pushNotifica3, _options$pushNotifica4, _options$pushNotifica5, _options$pushNotifica6, _options$pushNotifica7;
285
+ var _options$pushNotifica5, _options$pushNotifica6, _options$pushNotifica7, _options$pushNotifica8, _options$pushNotifica9, _options$pushNotifica0;
255
286
  const REGISTER_RE = /\{\{REGISTER_SNIPPET\}\}/;
256
287
  let envFileContent = FileManagement.readFile(envFileName);
257
- const disableNotificationRegistration = (_options$pushNotifica3 = options.pushNotification) === null || _options$pushNotifica3 === void 0 ? void 0 : _options$pushNotifica3.disableNotificationRegistration;
258
- const richPushConfig = (_options$pushNotifica4 = options.pushNotification) === null || _options$pushNotifica4 === void 0 ? void 0 : _options$pushNotifica4.env;
288
+ const disableNotificationRegistration = (_options$pushNotifica5 = options.pushNotification) === null || _options$pushNotifica5 === void 0 ? void 0 : _options$pushNotifica5.disableNotificationRegistration;
289
+ const richPushConfig = (_options$pushNotifica6 = options.pushNotification) === null || _options$pushNotifica6 === void 0 ? void 0 : _options$pushNotifica6.env;
259
290
  const {
260
291
  cdpApiKey,
261
292
  region
@@ -277,12 +308,15 @@ const updatePushFile = (options, envFileName) => {
277
308
  if (region) {
278
309
  envFileContent = replaceCodeByRegex(envFileContent, /\{\{REGION\}\}/, region.toUpperCase());
279
310
  }
280
- const autoTrackPushEvents = ((_options$pushNotifica5 = options.pushNotification) === null || _options$pushNotifica5 === void 0 ? void 0 : _options$pushNotifica5.autoTrackPushEvents) !== false;
311
+ const autoTrackPushEvents = ((_options$pushNotifica7 = options.pushNotification) === null || _options$pushNotifica7 === void 0 ? void 0 : _options$pushNotifica7.autoTrackPushEvents) !== false;
281
312
  envFileContent = replaceCodeByRegex(envFileContent, /\{\{AUTO_TRACK_PUSH_EVENTS\}\}/, autoTrackPushEvents.toString());
282
- const autoFetchDeviceToken = ((_options$pushNotifica6 = options.pushNotification) === null || _options$pushNotifica6 === void 0 ? void 0 : _options$pushNotifica6.autoFetchDeviceToken) !== false;
313
+ const autoFetchDeviceToken = ((_options$pushNotifica8 = options.pushNotification) === null || _options$pushNotifica8 === void 0 ? void 0 : _options$pushNotifica8.autoFetchDeviceToken) !== false;
283
314
  envFileContent = replaceCodeByRegex(envFileContent, /\{\{AUTO_FETCH_DEVICE_TOKEN\}\}/, autoFetchDeviceToken.toString());
284
- const showPushAppInForeground = ((_options$pushNotifica7 = options.pushNotification) === null || _options$pushNotifica7 === void 0 ? void 0 : _options$pushNotifica7.showPushAppInForeground) !== false;
315
+ const showPushAppInForeground = ((_options$pushNotifica9 = options.pushNotification) === null || _options$pushNotifica9 === void 0 ? void 0 : _options$pushNotifica9.showPushAppInForeground) !== false;
285
316
  envFileContent = replaceCodeByRegex(envFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
317
+ const appGroupId = (_options$pushNotifica0 = options.pushNotification) === null || _options$pushNotifica0 === void 0 ? void 0 : _options$pushNotifica0.appGroupId;
318
+ const appGroupIdBuilderLine = appGroupId ? ` .appGroupId(${JSON.stringify(appGroupId)})\n` : '';
319
+ envFileContent = replaceCodeByRegex(envFileContent, /\{\{APP_GROUP_ID_BUILDER_LINE\}\}/, appGroupIdBuilderLine);
286
320
  FileManagement.writeFile(envFileName, envFileContent);
287
321
  };
288
322
  //# sourceMappingURL=withNotificationsXcodeProject.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","replaceCodeByRegex","injectCIONotificationPodfileCode","logger","getIosNativeFilesPath","validateRichPushConfig","FileManagement","isExpoVersion53OrHigher","isFcmPushProvider","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","isExpo53OrHigher","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","String","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","_options$pushNotifica2","isFcmProvider","pbxTargetByName","warn","nsePath","mkdir","recursive","platformSpecificFiles","commonFiles","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","env","extGroup","addPbxGroup","groups","hash","project","objects","PBXGroup","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","PBXTargetDependency","PBXContainerItemProxy","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","writeFile","envFileName","richPushConfig","CDP_API_KEY_RE","REGION_RE","envFileContent","cdpApiKey","region","regionKey","toLowerCase","regionMap","us","eu","mappedRegion","sourceFile","targetFileName","appPath","exists","info","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","_options$pushNotifica3","_options$pushNotifica4","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","REGISTER_RE","disableNotificationRegistration","snippet","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS, RichPushConfig } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { validateRichPushConfig } from '../utils/validation';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n isExpo53OrHigher: boolean,\n) => {\n try {\n // PushService file is only needed for pre-Expo 53 code generation\n if (options.pushNotification && !isExpo53OrHigher) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush === true) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: unknown) {\n logger.error(String(error));\n return null;\n }\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget, useFrameworks } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n } satisfies CustomerIOPluginOptionsIOS;\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults,\n isExpoVersion53OrHigher(configOuter),\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const platformSpecificFiles = ['NotificationService.swift'];\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${isFcmProvider ? 'fcm' : 'apn'\n }/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/common/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(getTargetFile(ENV_FILENAME), options.pushNotification?.env);\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects.PBXGroup;\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};\n projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n envFileName: string,\n richPushConfig?: RichPushConfig\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n // Use merged config values (config takes precedence over env)\n const cdpApiKey = richPushConfig?.cdpApiKey;\n const region = richPushConfig?.region;\n\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n cdpApiKey || 'MISSING_API_KEY',\n );\n\n // Simplify region mapping with case insensitive keys and fallback for invalid regions\n const regionKey = region?.toLowerCase() ?? '';\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n } as const;\n const mappedRegion = regionMap[regionKey as keyof typeof regionMap];\n if (!mappedRegion) {\n logger.warn(\n `${regionKey} is an invalid region. Please use the values from the docs: https://docs.customer.io/integrations/sdk/expo/getting-started/packages-options/#configuring-the-expo-plugin`\n );\n // Fallback to US if invalid region provided\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, regionMap.us);\n } else {\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) {\n // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${sourceFile}`,\n targetFile\n );\n } else {\n logger.info(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n const richPushConfig = options.pushNotification?.env;\n const { cdpApiKey, region } = richPushConfig || {\n cdpApiKey: 'MISSING_API_KEY',\n region: undefined,\n };\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n\n let snippet = '';\n // unless this property is explicitly set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey,\n );\n\n if (region) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,sBAAsB;AAEvD,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,QACjB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,sBAAsB,QAAQ,qBAAqB;AAC5D,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,SAAS;AAEpE,MAAMC,cAAc,GAAG,GAAGX,4BAA4B,aAAa;AACnE,MAAMY,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAG,OAAO;AAEtC,MAAMC,+BAA+B,GAAG,MAAAA,CACtCC,OAAmC,EACnCC,YAA0B,EAC1BC,gBAAyB,KACtB;EACH,IAAI;IAAA,IAAAC,qBAAA;IACF;IACA,IAAIH,OAAO,CAACI,gBAAgB,IAAI,CAACF,gBAAgB,EAAE;MACjD,MAAMG,uBAAuB,CAACL,OAAO,EAAEC,YAAY,CAAC;IACtD;IAEA,IAAI,EAAAE,qBAAA,GAAAH,OAAO,CAACI,gBAAgB,cAAAD,qBAAA,uBAAxBA,qBAAA,CAA0BG,WAAW,MAAK,IAAI,EAAE;MAClD,MAAMC,oBAAoB,CAACP,OAAO,EAAEC,YAAY,CAAC;IACnD;IACA,OAAOA,YAAY;EACrB,CAAC,CAAC,OAAOO,KAAc,EAAE;IACvBlB,MAAM,CAACkB,KAAK,CAACC,MAAM,CAACD,KAAK,CAAC,CAAC;IAC3B,OAAO,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TIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","replaceCodeByRegex","injectCIONotificationPodfileCode","logger","getIosNativeFilesPath","validateRichPushConfig","FileManagement","isExpoVersion53OrHigher","isFcmPushProvider","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","isExpo53OrHigher","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","String","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","_options$pushNotifica2","_options$pushNotifica3","_options$pushNotifica4","isFcmProvider","pbxTargetByName","warn","nsePath","mkdir","recursive","platformSpecificFiles","nseEntitlementsFilename","appGroupId","nseEntitlementsContent","writeFile","commonFiles","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","env","updateNseNotificationService","allGroupFiles","extGroup","addPbxGroup","groups","hash","project","objects","PBXGroup","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","PBXTargetDependency","PBXContainerItemProxy","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","CODE_SIGN_ENTITLEMENTS","addTargetAttribute","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","notificationServiceFile","APP_GROUP_ID_BUILDER_LINE_RE","content","builderLine","JSON","stringify","envFileName","richPushConfig","CDP_API_KEY_RE","REGION_RE","envFileContent","cdpApiKey","region","regionKey","toLowerCase","regionMap","us","eu","mappedRegion","sourceFile","targetFileName","appPath","exists","info","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","_options$pushNotifica8","_options$pushNotifica9","_options$pushNotifica0","REGISTER_RE","disableNotificationRegistration","snippet","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","appGroupIdBuilderLine"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS, RichPushConfig } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { validateRichPushConfig } from '../utils/validation';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n isExpo53OrHigher: boolean,\n) => {\n try {\n // PushService file is only needed for pre-Expo 53 code generation\n if (options.pushNotification && !isExpo53OrHigher) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush === true) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: unknown) {\n logger.error(String(error));\n return null;\n }\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget, useFrameworks } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n } satisfies CustomerIOPluginOptionsIOS;\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults,\n isExpoVersion53OrHigher(configOuter),\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const platformSpecificFiles = ['NotificationService.swift'];\n\n const nseEntitlementsFilename = 'NotificationService.entitlements';\n const appGroupId = options.pushNotification?.appGroupId;\n\n // Write NSE entitlements file only when appGroupId is explicitly configured\n if (appGroupId) {\n const nseEntitlementsContent = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n <key>com.apple.security.application-groups</key>\n <array>\n <string>${appGroupId}</string>\n </array>\n</dict>\n</plist>\n`;\n FileManagement.writeFile(`${nsePath}/${nseEntitlementsFilename}`, nseEntitlementsContent);\n }\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${isFcmProvider ? 'fcm' : 'apn'\n }/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/common/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(getTargetFile(ENV_FILENAME), options.pushNotification?.env);\n updateNseNotificationService(getTargetFile('NotificationService.swift'), options.pushNotification?.appGroupId);\n\n // The entitlements file is generated (not copied from source), so it's listed separately\n // for the Xcode group so it appears in the file navigator\n const allGroupFiles = [\n ...platformSpecificFiles,\n ...commonFiles,\n ...(appGroupId ? [nseEntitlementsFilename] : []),\n ];\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n allGroupFiles,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects.PBXGroup;\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};\n projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n if (appGroupId) {\n buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${CIO_NOTIFICATION_TARGET_NAME}/${nseEntitlementsFilename}`;\n }\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseNotificationService = (\n notificationServiceFile: string,\n appGroupId?: string,\n) => {\n const APP_GROUP_ID_BUILDER_LINE_RE = /\\{\\{APP_GROUP_ID_BUILDER_LINE\\}\\}/;\n\n let content = FileManagement.readFile(notificationServiceFile);\n const builderLine = appGroupId\n ? ` .appGroupId(${JSON.stringify(appGroupId)})\\n`\n : '';\n content = replaceCodeByRegex(content, APP_GROUP_ID_BUILDER_LINE_RE, builderLine);\n FileManagement.writeFile(notificationServiceFile, content);\n};\n\nconst updateNseEnv = (\n envFileName: string,\n richPushConfig?: RichPushConfig\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n // Use merged config values (config takes precedence over env)\n const cdpApiKey = richPushConfig?.cdpApiKey;\n const region = richPushConfig?.region;\n\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n cdpApiKey || 'MISSING_API_KEY',\n );\n\n // Simplify region mapping with case insensitive keys and fallback for invalid regions\n const regionKey = region?.toLowerCase() ?? '';\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n } as const;\n const mappedRegion = regionMap[regionKey as keyof typeof regionMap];\n if (!mappedRegion) {\n logger.warn(\n `${regionKey} is an invalid region. Please use the values from the docs: https://docs.customer.io/integrations/sdk/expo/getting-started/packages-options/#configuring-the-expo-plugin`\n );\n // Fallback to US if invalid region provided\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, regionMap.us);\n } else {\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) {\n // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${sourceFile}`,\n targetFile\n );\n } else {\n logger.info(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n const richPushConfig = options.pushNotification?.env;\n const { cdpApiKey, region } = richPushConfig || {\n cdpApiKey: 'MISSING_API_KEY',\n region: undefined,\n };\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n\n let snippet = '';\n // unless this property is explicitly set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey,\n );\n\n if (region) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n const appGroupId = options.pushNotification?.appGroupId;\n const appGroupIdBuilderLine = appGroupId\n ? ` .appGroupId(${JSON.stringify(appGroupId)})\\n`\n : '';\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{APP_GROUP_ID_BUILDER_LINE\\}\\}/,\n appGroupIdBuilderLine\n );\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,sBAAsB;AAEvD,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,QACjB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,sBAAsB,QAAQ,qBAAqB;AAC5D,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,SAAS;AAEpE,MAAMC,cAAc,GAAG,GAAGX,4BAA4B,aAAa;AACnE,MAAMY,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAG,OAAO;AAEtC,MAAMC,+BAA+B,GAAG,MAAAA,CACtCC,OAAmC,EACnCC,YAA0B,EAC1BC,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