customerio-expo-plugin 2.7.1 → 2.7.2

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 (106) hide show
  1. package/package.json +3 -2
  2. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +5 -4
  3. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
  4. package/plugin/lib/commonjs/android/withAppGoogleServices.js +2 -1
  5. package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
  6. package/plugin/lib/commonjs/android/withCIOAndroid.js +17 -11
  7. package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
  8. package/plugin/lib/commonjs/android/withGistMavenRepository.js +2 -1
  9. package/plugin/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
  10. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +4 -3
  11. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  12. package/plugin/lib/commonjs/android/withMainApplicationModifications.js +2 -1
  13. package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
  14. package/plugin/lib/commonjs/helpers/utils/fileManagement.js +5 -4
  15. package/plugin/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
  16. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +2 -1
  17. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  18. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +5 -1
  19. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -1
  20. package/plugin/lib/commonjs/index.js +3 -11
  21. package/plugin/lib/commonjs/index.js.map +1 -1
  22. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +2 -1
  23. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  24. package/plugin/lib/commonjs/ios/withCIOIos.js +7 -3
  25. package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
  26. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +11 -10
  27. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  28. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +8 -7
  29. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
  30. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +29 -23
  31. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  32. package/plugin/lib/commonjs/utils/android.js +2 -1
  33. package/plugin/lib/commonjs/utils/android.js.map +1 -1
  34. package/plugin/lib/commonjs/utils/config.js +3 -2
  35. package/plugin/lib/commonjs/utils/config.js.map +1 -1
  36. package/plugin/lib/commonjs/utils/logger.js +35 -0
  37. package/plugin/lib/commonjs/utils/logger.js.map +1 -0
  38. package/plugin/lib/commonjs/utils/validation.js +68 -25
  39. package/plugin/lib/commonjs/utils/validation.js.map +1 -1
  40. package/plugin/lib/commonjs/utils/xcode.js +2 -1
  41. package/plugin/lib/commonjs/utils/xcode.js.map +1 -1
  42. package/plugin/lib/module/android/withAndroidManifestUpdates.js +6 -4
  43. package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
  44. package/plugin/lib/module/android/withAppGoogleServices.js +2 -1
  45. package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
  46. package/plugin/lib/module/android/withCIOAndroid.js +17 -11
  47. package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
  48. package/plugin/lib/module/android/withGistMavenRepository.js +2 -1
  49. package/plugin/lib/module/android/withGistMavenRepository.js.map +1 -1
  50. package/plugin/lib/module/android/withGoogleServicesJSON.js +4 -3
  51. package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  52. package/plugin/lib/module/android/withMainApplicationModifications.js +2 -1
  53. package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
  54. package/plugin/lib/module/helpers/utils/fileManagement.js +6 -5
  55. package/plugin/lib/module/helpers/utils/fileManagement.js.map +1 -1
  56. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -1
  57. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  58. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +5 -1
  59. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -1
  60. package/plugin/lib/module/index.js +3 -12
  61. package/plugin/lib/module/index.js.map +1 -1
  62. package/plugin/lib/module/ios/withAppDelegateModifications.js +2 -1
  63. package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  64. package/plugin/lib/module/ios/withCIOIos.js +7 -3
  65. package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
  66. package/plugin/lib/module/ios/withCIOIosSwift.js +11 -10
  67. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  68. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +8 -7
  69. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
  70. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +29 -23
  71. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  72. package/plugin/lib/module/utils/android.js +2 -1
  73. package/plugin/lib/module/utils/android.js.map +1 -1
  74. package/plugin/lib/module/utils/config.js +4 -2
  75. package/plugin/lib/module/utils/config.js.map +1 -1
  76. package/plugin/lib/module/utils/logger.js +29 -0
  77. package/plugin/lib/module/utils/logger.js.map +1 -0
  78. package/plugin/lib/module/utils/validation.js +68 -27
  79. package/plugin/lib/module/utils/validation.js.map +1 -1
  80. package/plugin/lib/module/utils/xcode.js +2 -1
  81. package/plugin/lib/module/utils/xcode.js.map +1 -1
  82. package/plugin/lib/typescript/android/withCIOAndroid.d.ts +1 -1
  83. package/plugin/lib/typescript/ios/withCIOIos.d.ts +1 -1
  84. package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +1 -1
  85. package/plugin/lib/typescript/utils/logger.d.ts +8 -0
  86. package/plugin/lib/typescript/utils/validation.d.ts +6 -3
  87. package/plugin/src/android/withAndroidManifestUpdates.ts +5 -4
  88. package/plugin/src/android/withAppGoogleServices.ts +2 -1
  89. package/plugin/src/android/withCIOAndroid.ts +18 -12
  90. package/plugin/src/android/withGistMavenRepository.ts +3 -2
  91. package/plugin/src/android/withGoogleServicesJSON.ts +4 -3
  92. package/plugin/src/android/withMainApplicationModifications.ts +2 -1
  93. package/plugin/src/helpers/utils/fileManagement.ts +10 -9
  94. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +2 -1
  95. package/plugin/src/helpers/utils/patchPluginNativeCode.ts +6 -1
  96. package/plugin/src/index.ts +3 -13
  97. package/plugin/src/ios/withAppDelegateModifications.ts +2 -1
  98. package/plugin/src/ios/withCIOIos.ts +12 -8
  99. package/plugin/src/ios/withCIOIosSwift.ts +15 -14
  100. package/plugin/src/ios/withGoogleServicesJsonFile.ts +8 -7
  101. package/plugin/src/ios/withNotificationsXcodeProject.ts +31 -35
  102. package/plugin/src/utils/android.ts +2 -1
  103. package/plugin/src/utils/config.ts +3 -2
  104. package/plugin/src/utils/logger.ts +37 -0
  105. package/plugin/src/utils/validation.ts +96 -32
  106. package/plugin/src/utils/xcode.ts +2 -1
@@ -1,4 +1,5 @@
1
1
  import { mergeConfigWithEnvValues } from '../utils/config';
2
+ import { logger } from '../utils/logger';
2
3
  import { isExpoVersion53OrHigher } from './utils';
3
4
  import { withAppDelegateModifications } from './withAppDelegateModifications';
4
5
  import { withCIOIosSwift } from './withCIOIosSwift';
@@ -8,7 +9,7 @@ import { withCioXcodeProject } from './withXcodeProject';
8
9
  export function withCIOIos(config, sdkConfig, props) {
9
10
  const isSwiftProject = isExpoVersion53OrHigher(config);
10
11
  const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);
11
- if (platformConfig.pushNotification) {
12
+ if (platformConfig !== null && platformConfig !== void 0 && platformConfig.pushNotification) {
12
13
  if (isSwiftProject) {
13
14
  config = withCIOIosSwift(config, sdkConfig, platformConfig);
14
15
  } else {
@@ -39,6 +40,9 @@ const mergeDeprecatedPropertiesAndLogWarnings = props => {
39
40
  // still available for backwards compatibility, but they will
40
41
  // be removed in the future.
41
42
 
43
+ if (!props) {
44
+ return props;
45
+ }
42
46
  const deprecatedTopLevelProperties = {
43
47
  showPushAppInForeground: props.showPushAppInForeground,
44
48
  autoTrackPushEvents: props.autoTrackPushEvents,
@@ -50,7 +54,7 @@ const mergeDeprecatedPropertiesAndLogWarnings = props => {
50
54
  // loop over all the deprecated properties and log a warning if they are set
51
55
  Object.entries(deprecatedTopLevelProperties).forEach(([key, value]) => {
52
56
  if (value !== undefined) {
53
- console.warn(`The ios.${key} property is deprecated. Please use ios.pushNotification.${key} instead.`);
57
+ logger.warn(`The ios.${key} property is deprecated. Please use ios.pushNotification.${key} instead.`);
54
58
  if (props.pushNotification === undefined) {
55
59
  props.pushNotification = {};
56
60
  }
@@ -61,7 +65,7 @@ const mergeDeprecatedPropertiesAndLogWarnings = props => {
61
65
  [propKey]: value
62
66
  };
63
67
  } else {
64
- console.warn(`The ios.${key} property is deprecated. Since the value of ios.pushNotification.${key} is set, it will be used.`);
68
+ logger.warn(`The ios.${key} property is deprecated. Since the value of ios.pushNotification.${key} is set, it will be used.`);
65
69
  }
66
70
  }
67
71
  });
@@ -1 +1 @@
1
- {"version":3,"names":["mergeConfigWithEnvValues","isExpoVersion53OrHigher","withAppDelegateModifications","withCIOIosSwift","withGoogleServicesJsonFile","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","sdkConfig","props","isSwiftProject","platformConfig","mergeDeprecatedPropertiesAndLogWarnings","pushNotification","env","deprecatedTopLevelProperties","showPushAppInForeground","autoTrackPushEvents","handleDeeplinkInKilledState","disableNotificationRegistration","autoFetchDeviceToken","Object","entries","forEach","key","value","undefined","console","warn","propKey"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginPushNotificationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { mergeConfigWithEnvValues } from '../utils/config';\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 | undefined,\n props: CustomerIOPluginOptionsIOS\n) {\n const isSwiftProject = isExpoVersion53OrHigher(config);\n const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);\n\n if (platformConfig.pushNotification) {\n if (isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig);\n } else {\n // Auto initialization is only supported in Swift projects (Expo SDK 53+)\n // Legacy Objective-C projects only support push notifications\n config = withAppDelegateModifications(config, platformConfig);\n }\n\n platformConfig.pushNotification.env = platformConfig.pushNotification.env\n || mergeConfigWithEnvValues(platformConfig, sdkConfig);\n config = withCioNotificationsXcodeProject(config, platformConfig);\n config = withCioXcodeProject(config, platformConfig);\n config = withGoogleServicesJsonFile(config, platformConfig);\n } else if (sdkConfig && isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig);\n }\n\n return config;\n}\n\n/** The basic purpose of this function is to centralize where we handle the deprecation\n by merging the deprecated properties into the new ios.pushNotification.* properties\n and logging a warning if they are set. This way, we can remove the deprecated properties\n from the top level of the ios object in the future, and update this function\n while the rest of the plugin code remains unchanged.\n*/\nconst mergeDeprecatedPropertiesAndLogWarnings = (\n props: CustomerIOPluginOptionsIOS\n) => {\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 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 console.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 console.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,uBAAuB,QAAQ,SAAS;AACjD,SAASC,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAUA,CACxBC,MAAkB,EAClBC,SAAsC,EACtCC,KAAiC,EACjC;EACA,MAAMC,cAAc,GAAGV,uBAAuB,CAACO,MAAM,CAAC;EACtD,MAAMI,cAAc,GAAGC,uCAAuC,CAACH,KAAK,CAAC;EAErE,IAAIE,cAAc,CAACE,gBAAgB,EAAE;IACnC,IAAIH,cAAc,EAAE;MAClBH,MAAM,GAAGL,eAAe,CAACK,MAAM,EAAEC,SAAS,EAAEG,cAAc,CAAC;IAC7D,CAAC,MAAM;MACL;MACA;MACAJ,MAAM,GAAGN,4BAA4B,CAACM,MAAM,EAAEI,cAAc,CAAC;IAC/D;IAEAA,cAAc,CAACE,gB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ACjDjB,KAAK,CAACI,gBAAgB,GAAG;UACvB,GAAGJ,KAAK,CAACI,gBAAgB;UACzB,CAACgB,OAAO,GAAGJ;QACb,CAAC;MACH,CAAC,MAAM;QACLE,OAAO,CAACC,IAAI,CACV,WAAWJ,GAAG,oEAAoEA,GAAG,2BACvF,CAAC;MACH;IACF;EACF,CAAC,CAAC;EAEF,OAAOf,KAAK;AACd,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["mergeConfigWithEnvValues","logger","isExpoVersion53OrHigher","withAppDelegateModifications","withCIOIosSwift","withGoogleServicesJsonFile","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","sdkConfig","props","isSwiftProject","platformConfig","mergeDeprecatedPropertiesAndLogWarnings","pushNotification","env","deprecatedTopLevelProperties","showPushAppInForeground","autoTrackPushEvents","handleDeeplinkInKilledState","disableNotificationRegistration","autoFetchDeviceToken","Object","entries","forEach","key","value","undefined","warn","propKey"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginPushNotificationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { mergeConfigWithEnvValues } from '../utils/config';\nimport { logger } from '../utils/logger';\nimport { isExpoVersion53OrHigher } from './utils';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCIOIosSwift } from './withCIOIosSwift';\nimport { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n) {\n const isSwiftProject = isExpoVersion53OrHigher(config);\n const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);\n\n if (platformConfig?.pushNotification) {\n if (isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig);\n } else {\n // Auto initialization is only supported in Swift projects (Expo SDK 53+)\n // Legacy Objective-C projects only support push notifications\n config = withAppDelegateModifications(config, platformConfig);\n }\n\n platformConfig.pushNotification.env = platformConfig.pushNotification.env\n || mergeConfigWithEnvValues(platformConfig, sdkConfig);\n config = withCioNotificationsXcodeProject(config, platformConfig);\n config = withCioXcodeProject(config, platformConfig);\n config = withGoogleServicesJsonFile(config, platformConfig);\n } else if (sdkConfig && isSwiftProject) {\n config = withCIOIosSwift(config, sdkConfig, platformConfig);\n }\n\n return config;\n}\n\n/** The basic purpose of this function is to centralize where we handle the deprecation\n by merging the deprecated properties into the new ios.pushNotification.* properties\n and logging a warning if they are set. This way, we can remove the deprecated properties\n from the top level of the ios object in the future, and update this function\n while the rest of the plugin code remains unchanged.\n*/\nconst mergeDeprecatedPropertiesAndLogWarnings = (\n props?: CustomerIOPluginOptionsIOS,\n): CustomerIOPluginOptionsIOS | undefined => {\n // The deprecatedTopLevelProperties maps the top level properties\n // that are deprecated to the new ios.pushNotification.* properties\n // that should be used instead. The deprecated properties are\n // still available for backwards compatibility, but they will\n // be removed in the future.\n\n if (!props) {\n return props\n }\n\n const deprecatedTopLevelProperties = {\n showPushAppInForeground: props.showPushAppInForeground,\n autoTrackPushEvents: props.autoTrackPushEvents,\n handleDeeplinkInKilledState: props.handleDeeplinkInKilledState,\n disableNotificationRegistration: props.disableNotificationRegistration,\n autoFetchDeviceToken: props.autoFetchDeviceToken,\n };\n\n // loop over all the deprecated properties and log a warning if they are set\n Object.entries(deprecatedTopLevelProperties).forEach(([key, value]) => {\n if (value !== undefined) {\n logger.warn(\n `The ios.${key} property is deprecated. Please use ios.pushNotification.${key} instead.`\n );\n\n if (props.pushNotification === undefined) {\n props.pushNotification = {} as CustomerIOPluginPushNotificationOptions;\n }\n const propKey = key as keyof CustomerIOPluginPushNotificationOptions;\n if (props.pushNotification[propKey] === undefined) {\n props.pushNotification = {\n ...props.pushNotification,\n [propKey]: value,\n };\n } else {\n logger.warn(\n `The ios.${key} property is deprecated. Since the value of ios.pushNotification.${key} is set, it will be used.`\n );\n }\n }\n });\n\n return props;\n};\n"],"mappings":"AAMA,SAASA,wBAAwB,QAAQ,iBAAiB;AAC1D,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,uBAAuB,QAAQ,SAAS;AACjD,SAASC,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAUA,CACxBC,MAAkB,EAClBC,SAA2B,EAC3BC,KAAkC,EAClC;EACA,MAAMC,cAAc,GAAGV,uBAAuB,CAACO,MAAM,CAAC;EACtD,MAAMI,cAAc,GAAGC,uCAAuC,CAACH,KAAK,CAAC;EAErE,IAAIE,cAAc,aAAdA,cAAc,eAAdA,cAAc,CAAEE,gBAAgB,EAAE;IACpC,IAAIH,cAAc,EAAE;MAClBH,MAAM,GAAGL,eAAe,CAACK,MAAM,EAAEC,SAAS,EAAEG,cAAc,CAAC;IAC7D,CAAC,MAAM;MACL;MACA;MACAJ,MAAM,GAAGN,4BAA4B,CAACM,MAAM,EAAEI,cAAc,CAAC;IAC/D;IAEAA,cAAc,CAACE,gBAAgB,CAACC,GAAG,GAAGH,cAAc,CAACE,gBAAgB,CAACC,GAAG,IACpEhB,wBAAwB,CAACa,cAAc,EAAEH,SAAS,CAAC;IACxDD,MAAM,GAAGH,gCAAgC,CAACG,MAAM,EAAEI,cAAc,CAAC;IACjEJ,MAAM,GAAGF,mBAAmB,CAACE,MAAM,EAAEI,cAAc,CAAC;IACpDJ,MAAM,GAAGJ,0BAA0B,CAACI,MAAM,EAAEI,cAAc,CAAC;EAC7D,CAAC,MAAM,IAAIH,SAAS,IAAIE,cAAc,EAAE;IACtCH,MAAM,GAAGL,eAAe,CAACK,MAAM,EAAEC,SAAS,EAAEG,cAA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_PUSH_APP
5
5
  import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
6
6
  import { FileManagement } from '../helpers/utils/fileManagement';
7
7
  import { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';
8
+ import { logger } from '../utils/logger';
8
9
  import { getIosNativeFilesPath } from '../utils/plugin';
9
10
  import { copyFileToXcode, getOrCreateCustomerIOGroup } from '../utils/xcode';
10
11
  import { isFcmPushProvider } from './utils';
@@ -20,7 +21,7 @@ const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props) => {
20
21
  // Destination path in the iOS project
21
22
  const projectName = config.modRequest.projectName || '';
22
23
  if (!projectName) {
23
- console.warn('Project name is undefined, cannot copy CustomerIO files');
24
+ logger.warn('Project name is undefined, cannot copy CustomerIO files');
24
25
  return config;
25
26
  }
26
27
 
@@ -29,7 +30,7 @@ const copyAndConfigureAppDelegateHandler = (config, sdkConfig, props) => {
29
30
  const projectRoot = config.modRequest.projectRoot;
30
31
  const iosProjectRoot = path.join(projectRoot, 'ios');
31
32
  const group = getOrCreateCustomerIOGroup(xcodeProject, projectName);
32
- if (props.pushNotification) {
33
+ if (props !== null && props !== void 0 && props.pushNotification) {
33
34
  // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support
34
35
  copyAndConfigurePushAppDelegateHandler({
35
36
  xcodeProject,
@@ -128,7 +129,7 @@ export const withCIOIosSwift = (configOuter, sdkConfig, props) => {
128
129
  });
129
130
 
130
131
  // Modify the AppDelegate based on configuration
131
- if (props.pushNotification) {
132
+ if (props !== null && props !== void 0 && props.pushNotification) {
132
133
  // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init
133
134
  return withAppDelegate(configOuter, async config => {
134
135
  return modifyAppDelegateWithPushAppDelegateHandler(config, props);
@@ -152,7 +153,7 @@ const modifyAppDelegateWithPushAppDelegateHandler = (config, props) => {
152
153
 
153
154
  // Check if modifications have already been applied
154
155
  if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {
155
- console.log('CustomerIO Swift AppDelegate changes already exist. Skipping...');
156
+ logger.info('CustomerIO Swift AppDelegate changes already exist. Skipping...');
156
157
  return config;
157
158
  }
158
159
 
@@ -186,7 +187,7 @@ const modifyAppDelegateWithNativeSDKInitializer = (config
186
187
 
187
188
  // Check if modifications have already been applied
188
189
  if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {
189
- console.log('CustomerIO Swift AppDelegate changes already exist. Skipping...');
190
+ logger.info('CustomerIO Swift AppDelegate changes already exist. Skipping...');
190
191
  return config;
191
192
  }
192
193
 
@@ -216,7 +217,7 @@ const addHandlerPropertyDeclaration = content => {
216
217
  const classDeclarationRegex = /class\s+AppDelegate\s*:\s*.*\s*{/;
217
218
  const match = content.match(classDeclarationRegex);
218
219
  if (!match) {
219
- console.warn('Could not find AppDelegate class declaration');
220
+ logger.warn('Could not find AppDelegate class declaration');
220
221
  return content;
221
222
  }
222
223
  const position = (match.index ?? 0) + match[0].length;
@@ -233,7 +234,7 @@ const modifyDidFinishLaunchingWithOptions = (content, codeToInject) => {
233
234
  const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
234
235
  const returnStatementMatch = content.match(returnStatementRegex);
235
236
  if (!returnStatementMatch) {
236
- console.warn('Could not find return statement with super.application in didFinishLaunchingWithOptions');
237
+ logger.warn('Could not find return statement with super.application in didFinishLaunchingWithOptions');
237
238
  return content;
238
239
  }
239
240
 
@@ -269,7 +270,7 @@ const addDidRegisterForRemoteNotificationsWithDeviceToken = content => {
269
270
  const classEndRegex = /^}(\s*$|\s*\/\/)/m;
270
271
  const classEndMatch = content.match(classEndRegex);
271
272
  if (!classEndMatch) {
272
- console.warn('Could not find end of AppDelegate class');
273
+ logger.warn('Could not find end of AppDelegate class');
273
274
  return content;
274
275
  }
275
276
 
@@ -306,7 +307,7 @@ const addDidFailToRegisterForRemoteNotificationsWithError = content => {
306
307
  const classEndRegex = /^}(\s*$|\s*\/\/)/m;
307
308
  const classEndMatch = content.match(classEndRegex);
308
309
  if (!classEndMatch) {
309
- console.warn('Could not find end of AppDelegate class');
310
+ logger.warn('Could not find end of AppDelegate class');
310
311
  return content;
311
312
  }
312
313
 
@@ -332,7 +333,7 @@ const addHandleDeeplinkInKilledState = content => {
332
333
  const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
333
334
  const returnStatementMatch = content.match(returnStatementRegex);
334
335
  if (!returnStatementMatch) {
335
- console.warn('Could not find return statement with launchOptions');
336
+ logger.warn('Could not find return statement with launchOptions');
336
337
  return content;
337
338
  }
338
339
 
@@ -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","getIosNativeFilesPath","copyFileToXcode","getOrCreateCustomerIOGroup","isFcmPushProvider","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","projectName","modRequest","console","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","join","group","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","useFcm","handlerSourcePath","handlerDestPath","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","replace","writeFile","filename","sourcePath","sourceFilePath","targetFileName","transform","content","IOS","customerIOGroup","withCIOIosSwift","configOuter","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","_props$pushNotificati5","appDelegateContent","contents","includes","log","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type {\n ExportedConfigWithProps,\n XcodeProject,\n} from '@expo/config-plugins';\nimport { withAppDelegate, withXcodeProject } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\nimport { PLATFORM } from '../helpers/constants/common';\nimport {\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_CALL,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type { CustomerIOPluginOptionsIOS, NativeSDKConfig } from '../types/cio-types';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { copyFileToXcode, getOrCreateCustomerIOGroup } from '../utils/xcode';\nimport { isFcmPushProvider } from './utils';\n\n// Constants\nconst CIO_SDK_APP_DELEGATE_HANDLER_CLASS = 'CioSdkAppDelegateHandler';\nconst CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}.swift`;\n\n/**\n * Copy and configure the CioSdkAppDelegateHandler.swift file\n */\nconst copyAndConfigureAppDelegateHandler = (\n config: ExportedConfigWithProps<XcodeProject>,\n sdkConfig: NativeSDKConfig | undefined,\n props: CustomerIOPluginOptionsIOS,\n): ExportedConfigWithProps<XcodeProject> => {\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n console.warn(\n 'Project name is undefined, cannot copy CustomerIO files'\n );\n return config;\n }\n\n // Add files to the Xcode project\n const xcodeProject = config.modResults;\n const projectRoot = config.modRequest.projectRoot;\n const iosProjectRoot = path.join(projectRoot, 'ios');\n\n const group = getOrCreateCustomerIOGroup(xcodeProject, projectName);\n if (props.pushNotification) {\n // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support\n copyAndConfigurePushAppDelegateHandler({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n });\n } else if (sdkConfig) {\n // Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications\n copyAndConfigureNativeSDKInitializer({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n });\n }\n\n return config;\n};\n\nconst copyAndConfigurePushAppDelegateHandler = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig | undefined;\n props: CustomerIOPluginOptionsIOS;\n}) => {\n const useFcm = isFcmPushProvider(props);\n\n // Source path for the handler file\n const handlerSourcePath = path.join(\n getIosNativeFilesPath(),\n useFcm ? 'fcm' : 'apn',\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n const handlerDestPath = path.join(\n iosProjectRoot,\n projectName,\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n FileManagement.copyFile(handlerSourcePath, handlerDestPath);\n\n // Add the file to the Xcode project\n xcodeProject.addSourceFile(\n `${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`,\n null,\n group\n );\n\n let handlerFileContent = FileManagement.readFile(handlerDestPath);\n\n const disableNotificationRegistration =\n props.pushNotification?.disableNotificationRegistration;\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2;\n }\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n snippet\n );\n\n const autoTrackPushEvents =\n props.pushNotification?.autoTrackPushEvents !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n props.pushNotification?.autoFetchDeviceToken !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n props.pushNotification?.showPushAppInForeground !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n // Also copy CustomerIOSDKInitializer.swift for auto-initialization\n copyAndConfigureNativeSDKInitializer({ xcodeProject, group, iosProjectRoot, projectName, sdkConfig });\n\n // Inject auto initialization call before MessagingPush initialization\n handlerFileContent = handlerFileContent.replace(CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET + '$1');\n }\n\n FileManagement.writeFile(handlerDestPath, handlerFileContent);\n};\n\nconst copyAndConfigureNativeSDKInitializer = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig;\n}) => {\n const filename = 'CustomerIOSDKInitializer.swift';\n const sourcePath = path.join(getIosNativeFilesPath(), filename);\n // Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler\n copyFileToXcode({\n xcodeProject,\n iosProjectRoot,\n projectName,\n sourceFilePath: sourcePath,\n targetFileName: filename,\n transform: (content) => patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig),\n customerIOGroup: group,\n });\n};\n\nexport const withCIOIosSwift = (\n configOuter: ExpoConfig,\n sdkConfig: NativeSDKConfig | undefined,\n props: CustomerIOPluginOptionsIOS,\n) => {\n // First, copy required swift files to iOS folder and add it to Xcode project\n configOuter = withXcodeProject(configOuter, async (config) => {\n return copyAndConfigureAppDelegateHandler(config, sdkConfig, props);\n });\n\n // Modify the AppDelegate based on configuration\n if (props.pushNotification) {\n // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithPushAppDelegateHandler(config, props);\n });\n } else if (sdkConfig) {\n // Without push notifications: directly inject auto initialization into AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithNativeSDKInitializer(config);\n });\n } else {\n return configOuter;\n }\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithPushAppDelegateHandler = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n props: CustomerIOPluginOptionsIOS\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {\n console.log(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Add the handler property declaration\n let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n modifiedContent = modifyDidFinishLaunchingWithOptions(\n modifiedContent,\n ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `\n );\n\n // Add didRegisterForRemoteNotificationsWithDeviceToken implementation\n modifiedContent =\n addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);\n\n // Add didFailToRegisterForRemoteNotificationsWithError implementation\n modifiedContent =\n addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);\n\n // Add deep link handling for killed state if enabled\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);\n }\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithNativeSDKInitializer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n console.log(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n const modifiedContent = modifyDidFinishLaunchingWithOptions(\n appDelegateContent,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n );\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Check if a method exists in the AppDelegate content\n * @param content The AppDelegate content\n * @param methodSignature The method signature to check for\n * @returns true if the method exists, false otherwise\n */\nconst methodExistsInAppDelegate = (\n content: string,\n methodSignature: string\n): boolean => {\n return content.includes(methodSignature);\n};\n\n/**\n * Add handler property declaration to the AppDelegate class\n * This adds the line: let cioSdkHandler = CioSdkAppDelegateHandler()\n * to the AppDelegate class\n */\nconst addHandlerPropertyDeclaration = (content: string): string => {\n // Look for the AppDelegate class declaration\n const classDeclarationRegex = /class\\s+AppDelegate\\s*:\\s*.*\\s*{/;\n const match = content.match(classDeclarationRegex);\n\n if (!match) {\n console.warn('Could not find AppDelegate class declaration');\n return content;\n }\n\n const position = (match.index ?? 0) + match[0].length;\n return (\n content.substring(0, position) +\n `\\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\\n` +\n content.substring(position)\n );\n};\n\n/**\n * Modify didFinishLaunchingWithOptions to inject Customer.io code\n * Injects the provided code (either handler call or auto initialization) before the return statement\n */\nconst modifyDidFinishLaunchingWithOptions = (content: string, codeToInject: string): string => {\n // Find the return statement in didFinishLaunchingWithOptions\n // Always look for launchOptions since modifiedLaunchOptions is only set later\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n console.warn(\n 'Could not find return statement with super.application in didFinishLaunchingWithOptions'\n );\n return content;\n }\n\n // Inject Customer.io code before the return statement\n const insertPosition = returnStatementMatch.index ?? 0;\n\n return (\n content.substring(0, insertPosition) +\n codeToInject +\n content.substring(insertPosition)\n );\n};\n\n/**\n * Add or modify didRegisterForRemoteNotificationsWithDeviceToken implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didRegisterForRemoteNotificationsWithDeviceToken\\s+deviceToken\\s*:\\s*Data\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n console.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle device token registration\\n' +\n ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add or modify didFailToRegisterForRemoteNotificationsWithError implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didFailToRegisterForRemoteNotificationsWithError\\s+error\\s*:\\s*Error\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n console.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle remote notification registration errors\\n' +\n ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add deep link handling for killed state\n * This replaces the return statement with deep link handling code\n * and a modified return statement that uses modifiedLaunchOptions\n */\nconst addHandleDeeplinkInKilledState = (content: string): string => {\n // Check if deep link code snippet is already present\n const deepLinkMarker = 'Deep link workaround for app killed state start';\n if (content.includes(deepLinkMarker)) {\n return content;\n }\n\n // Find the return statement with launchOptions\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n console.warn('Could not find return statement with launchOptions');\n return content;\n }\n\n // Create the replacement code with deep link handling and modified return statement\n const modifiedReturnStatement =\n 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';\n const replacementCode =\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET +\n '\\n\\n ' +\n modifiedReturnStatement;\n\n // Replace the return statement with deep link handling code and modified return statement\n return content.replace(returnStatementRegex, replacementCode);\n};\n"],"mappings":"AAIA,SAASA,eAAe,EAAEC,gBAAgB,QAAQ,sBAAsB;AAExE,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SACEC,+CAA+C,EAC/CC,0CAA0C,EAC1CC,8BAA8B,EAC9BC,iCAAiC,EACjCC,wCAAwC,EACxCC,0CAA0C,QACrC,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,yBAAyB,QAAQ,wCAAwC;AAElF,SAASC,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,SAAsC,EACtCC,KAAiC,KACS;EAC1C;EACA,MAAMC,WAAW,GAAGH,MAAM,CAACI,UAAU,CAACD,WAAW,IAAI,EAAE;EACvD,IAAI,CAACA,WAAW,EAAE;IAChBE,OAAO,CAACC,IAAI,CACV,yDACF,CAAC;IACD,OAAON,MAAM;EACf;;EAEA;EACA,MAAMO,YAAY,GAAGP,MAAM,CAACQ,UAAU;EACtC,MAAMC,WAAW,GAAGT,MAAM,CAACI,UAAU,CAACK,WAAW;EACjD,MAAMC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AO,CAACU,QAAQ,CAAC4B,cAAc,CAAC,EAAE;IACpC,OAAOtC,OAAO;EAChB;;EAEA;EACA,MAAM4B,oBAAoB,GACxB,6GAA6G;EAC/G,MAAMC,oBAAoB,GAAG7B,OAAO,CAACsB,KAAK,CAACM,oBAAoB,CAAC;EAEhE,IAAI,CAACC,oBAAoB,EAAE;IACzBhE,OAAO,CAACC,IAAI,CAAC,oDAAoD,CAAC;IAClE,OAAOkC,OAAO;EAChB;;EAEA;EACA,MAAMuC,uBAAuB,GAC3B,6FAA6F;EAC/F,MAAMC,eAAe,GACnBhG,+CAA+C,GAC/C,UAAU,GACV+F,uBAAuB;;EAEzB;EACA,OAAOvC,OAAO,CAACP,OAAO,CAACmC,oBAAoB,EAAEY,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withAppDelegate","withXcodeProject","path","PLATFORM","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","replaceCodeByRegex","FileManagement","patchNativeSDKInitializer","logger","getIosNativeFilesPath","copyFileToXcode","getOrCreateCustomerIOGroup","isFcmPushProvider","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","projectName","modRequest","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","join","group","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","useFcm","handlerSourcePath","handlerDestPath","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","replace","writeFile","filename","sourcePath","sourceFilePath","targetFileName","transform","content","IOS","customerIOGroup","withCIOIosSwift","configOuter","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","_props$pushNotificati5","appDelegateContent","contents","includes","info","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type {\n ExportedConfigWithProps,\n XcodeProject,\n} from '@expo/config-plugins';\nimport { withAppDelegate, withXcodeProject } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\nimport { PLATFORM } from '../helpers/constants/common';\nimport {\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_CALL,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type { CustomerIOPluginOptionsIOS, NativeSDKConfig } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { copyFileToXcode, getOrCreateCustomerIOGroup } from '../utils/xcode';\nimport { isFcmPushProvider } from './utils';\n\n// Constants\nconst CIO_SDK_APP_DELEGATE_HANDLER_CLASS = 'CioSdkAppDelegateHandler';\nconst CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}.swift`;\n\n/**\n * Copy and configure the CioSdkAppDelegateHandler.swift file\n */\nconst copyAndConfigureAppDelegateHandler = (\n config: ExportedConfigWithProps<XcodeProject>,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n): ExportedConfigWithProps<XcodeProject> => {\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n logger.warn(\n 'Project name is undefined, cannot copy CustomerIO files'\n );\n return config;\n }\n\n // Add files to the Xcode project\n const xcodeProject = config.modResults;\n const projectRoot = config.modRequest.projectRoot;\n const iosProjectRoot = path.join(projectRoot, 'ios');\n\n const group = getOrCreateCustomerIOGroup(xcodeProject, projectName);\n if (props?.pushNotification) {\n // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support\n copyAndConfigurePushAppDelegateHandler({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n });\n } else if (sdkConfig) {\n // Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications\n copyAndConfigureNativeSDKInitializer({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n });\n }\n\n return config;\n};\n\nconst copyAndConfigurePushAppDelegateHandler = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig | undefined;\n props: CustomerIOPluginOptionsIOS;\n}) => {\n const useFcm = isFcmPushProvider(props);\n\n // Source path for the handler file\n const handlerSourcePath = path.join(\n getIosNativeFilesPath(),\n useFcm ? 'fcm' : 'apn',\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n const handlerDestPath = path.join(\n iosProjectRoot,\n projectName,\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n FileManagement.copyFile(handlerSourcePath, handlerDestPath);\n\n // Add the file to the Xcode project\n xcodeProject.addSourceFile(\n `${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`,\n null,\n group\n );\n\n let handlerFileContent = FileManagement.readFile(handlerDestPath);\n\n const disableNotificationRegistration =\n props.pushNotification?.disableNotificationRegistration;\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2;\n }\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n snippet\n );\n\n const autoTrackPushEvents =\n props.pushNotification?.autoTrackPushEvents !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n props.pushNotification?.autoFetchDeviceToken !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n props.pushNotification?.showPushAppInForeground !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n // Also copy CustomerIOSDKInitializer.swift for auto-initialization\n copyAndConfigureNativeSDKInitializer({ xcodeProject, group, iosProjectRoot, projectName, sdkConfig });\n\n // Inject auto initialization call before MessagingPush initialization\n handlerFileContent = handlerFileContent.replace(CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET + '$1');\n }\n\n FileManagement.writeFile(handlerDestPath, handlerFileContent);\n};\n\nconst copyAndConfigureNativeSDKInitializer = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig;\n}) => {\n const filename = 'CustomerIOSDKInitializer.swift';\n const sourcePath = path.join(getIosNativeFilesPath(), filename);\n // Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler\n copyFileToXcode({\n xcodeProject,\n iosProjectRoot,\n projectName,\n sourceFilePath: sourcePath,\n targetFileName: filename,\n transform: (content) => patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig),\n customerIOGroup: group,\n });\n};\n\nexport const withCIOIosSwift = (\n configOuter: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n) => {\n // First, copy required swift files to iOS folder and add it to Xcode project\n configOuter = withXcodeProject(configOuter, async (config) => {\n return copyAndConfigureAppDelegateHandler(config, sdkConfig, props);\n });\n\n // Modify the AppDelegate based on configuration\n if (props?.pushNotification) {\n // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithPushAppDelegateHandler(config, props);\n });\n } else if (sdkConfig) {\n // Without push notifications: directly inject auto initialization into AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithNativeSDKInitializer(config);\n });\n } else {\n return configOuter;\n }\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithPushAppDelegateHandler = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n props: CustomerIOPluginOptionsIOS\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Add the handler property declaration\n let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n modifiedContent = modifyDidFinishLaunchingWithOptions(\n modifiedContent,\n ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `\n );\n\n // Add didRegisterForRemoteNotificationsWithDeviceToken implementation\n modifiedContent =\n addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);\n\n // Add didFailToRegisterForRemoteNotificationsWithError implementation\n modifiedContent =\n addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);\n\n // Add deep link handling for killed state if enabled\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);\n }\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithNativeSDKInitializer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n const modifiedContent = modifyDidFinishLaunchingWithOptions(\n appDelegateContent,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n );\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Check if a method exists in the AppDelegate content\n * @param content The AppDelegate content\n * @param methodSignature The method signature to check for\n * @returns true if the method exists, false otherwise\n */\nconst methodExistsInAppDelegate = (\n content: string,\n methodSignature: string\n): boolean => {\n return content.includes(methodSignature);\n};\n\n/**\n * Add handler property declaration to the AppDelegate class\n * This adds the line: let cioSdkHandler = CioSdkAppDelegateHandler()\n * to the AppDelegate class\n */\nconst addHandlerPropertyDeclaration = (content: string): string => {\n // Look for the AppDelegate class declaration\n const classDeclarationRegex = /class\\s+AppDelegate\\s*:\\s*.*\\s*{/;\n const match = content.match(classDeclarationRegex);\n\n if (!match) {\n logger.warn('Could not find AppDelegate class declaration');\n return content;\n }\n\n const position = (match.index ?? 0) + match[0].length;\n return (\n content.substring(0, position) +\n `\\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\\n` +\n content.substring(position)\n );\n};\n\n/**\n * Modify didFinishLaunchingWithOptions to inject Customer.io code\n * Injects the provided code (either handler call or auto initialization) before the return statement\n */\nconst modifyDidFinishLaunchingWithOptions = (content: string, codeToInject: string): string => {\n // Find the return statement in didFinishLaunchingWithOptions\n // Always look for launchOptions since modifiedLaunchOptions is only set later\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn(\n 'Could not find return statement with super.application in didFinishLaunchingWithOptions'\n );\n return content;\n }\n\n // Inject Customer.io code before the return statement\n const insertPosition = returnStatementMatch.index ?? 0;\n\n return (\n content.substring(0, insertPosition) +\n codeToInject +\n content.substring(insertPosition)\n );\n};\n\n/**\n * Add or modify didRegisterForRemoteNotificationsWithDeviceToken implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didRegisterForRemoteNotificationsWithDeviceToken\\s+deviceToken\\s*:\\s*Data\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle device token registration\\n' +\n ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add or modify didFailToRegisterForRemoteNotificationsWithError implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didFailToRegisterForRemoteNotificationsWithError\\s+error\\s*:\\s*Error\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle remote notification registration errors\\n' +\n ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add deep link handling for killed state\n * This replaces the return statement with deep link handling code\n * and a modified return statement that uses modifiedLaunchOptions\n */\nconst addHandleDeeplinkInKilledState = (content: string): string => {\n // Check if deep link code snippet is already present\n const deepLinkMarker = 'Deep link workaround for app killed state start';\n if (content.includes(deepLinkMarker)) {\n return content;\n }\n\n // Find the return statement with launchOptions\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn('Could not find return statement with launchOptions');\n return content;\n }\n\n // Create the replacement code with deep link handling and modified return statement\n const modifiedReturnStatement =\n 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';\n const replacementCode =\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET +\n '\\n\\n ' +\n modifiedReturnStatement;\n\n // Replace the return statement with deep link handling code and modified return statement\n return content.replace(returnStatementRegex, replacementCode);\n};\n"],"mappings":"AAIA,SAASA,eAAe,EAAEC,gBAAgB,QAAQ,sBAAsB;AAExE,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SACEC,+CAA+C,EAC/CC,0CAA0C,EAC1CC,8BAA8B,EAC9BC,iCAAiC,EACjCC,wCAAwC,EACxCC,0CAA0C,QACrC,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,yBAAyB,QAAQ,wCAAwC;AAElF,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,eAAe,EAAEC,0BAA0B,QAAQ,gBAAgB;AAC5E,SAASC,iBAAiB,QAAQ,SAAS;;AAE3C;AACA,MAAMC,kCAAkC,GAAG,0BAA0B;AACrE,MAAMC,qCAAqC,GAAG,GAAGD,kCAAkC,QAAQ;;AAE3F;AACA;AACA;AACA,MAAME,kCAAkC,GAAGA,CACzCC,MAA6C,EAC7CC,SAA2B,EAC3BC,KAAkC,KACQ;EAC1C;EACA,MAAMC,WAAW,GAAGH,MAAM,CAACI,UAAU,CAACD,WAAW,IAAI,EAAE;EACvD,IAAI,CAACA,WAAW,EAAE;IAChBX,MAAM,CAACa,IAAI,CACT,yDACF,CAAC;IACD,OAAOL,MAAM;EACf;;EAEA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,CAACH,QAAQ,CAAC;EAE/B;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAML,8BAA8B,GAAIlB,OAAe,IAAa;EAClE;EACA,MAAMsC,cAAc,GAAG,iDAAiD;EACxE,IAAItC,OAAO,CAACU,QAAQ,CAAC4B,cAAc,CAAC,EAAE;IACpC,OAAOtC,OAAO;EAChB;;EAEA;EACA,MAAM4B,oBAAoB,GACxB,6GAA6G;EAC/G,MAAMC,oBAAoB,GAAG7B,OAAO,CAACsB,KAAK,CAACM,oBAAoB,CAAC;EAEhE,IAAI,CAACC,oBAAoB,EAAE;IACzB5E,MAAM,CAACa,IAAI,CAAC,oDAAoD,CAAC;IACjE,OAAOkC,OAAO;EAChB;;EAEA;EACA,MAAMuC,uBAAuB,GAC3B,6FAA6F;EAC/F,MAAMC,eAAe,GACnBhG,+CAA+C,GAC/C,UAAU,GACV+F,uBAAuB;;EAEzB;EACA,OAAOvC,OAAO,CAACP,OAAO,CAACmC,oBAAoB,EAAEY,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  import { IOSConfig, withXcodeProject } from '@expo/config-plugins';
2
+ import { logger } from '../utils/logger';
2
3
  import { FileManagement } from './../helpers/utils/fileManagement';
3
4
  import { isFcmPushProvider } from './utils';
4
5
  export const withGoogleServicesJsonFile = (config, cioProps) => {
@@ -9,35 +10,35 @@ export const withGoogleServicesJsonFile = (config, cioProps) => {
9
10
  // Nothing to do, for providers other than FCM, the Google services JSON file isn't needed
10
11
  return props;
11
12
  }
12
- console.log('Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' + ' GoogleService-Info.plist as part of Firebase integration');
13
+ logger.info('Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' + ' GoogleService-Info.plist as part of Firebase integration');
13
14
 
14
15
  // googleServicesFile
15
16
  const iosPath = props.modRequest.platformProjectRoot;
16
17
  const googleServicesFile = (_cioProps$pushNotific = cioProps.pushNotification) === null || _cioProps$pushNotific === void 0 ? void 0 : _cioProps$pushNotific.googleServicesFile;
17
18
  const appName = props.modRequest.projectName;
18
19
  if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {
19
- console.log(`File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`);
20
+ logger.info(`File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`);
20
21
  return props;
21
22
  }
22
23
  if (FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)) {
23
24
  // This is where RN Firebase potentially copies GoogleService-Info.plist
24
25
  // Do not copy if it's already done by Firebase to avoid conflict in Resources
25
- console.log(`File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`);
26
+ logger.info(`File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`);
26
27
  return props;
27
28
  }
28
29
  if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
29
30
  var _config$ios;
30
31
  if ((_config$ios = config.ios) !== null && _config$ios !== void 0 && _config$ios.googleServicesFile) {
31
- console.warn('Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' + ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile');
32
+ logger.warn('Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' + ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile');
32
33
  }
33
34
  try {
34
35
  FileManagement.copyFile(googleServicesFile, `${iosPath}/GoogleService-Info.plist`);
35
36
  addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');
36
37
  } catch {
37
- console.error(`There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`);
38
+ logger.error(`There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`);
38
39
  }
39
40
  } else {
40
- console.error(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`);
41
+ logger.error(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`);
41
42
  }
42
43
  return props;
43
44
  });
@@ -46,7 +47,7 @@ function addFileToXcodeProject(project, fileName) {
46
47
  const groupName = 'Resources';
47
48
  const filepath = fileName;
48
49
  if (!IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {
49
- console.error(`Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`);
50
+ logger.error(`Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`);
50
51
  return;
51
52
  }
52
53
 
@@ -1 +1 @@
1
- {"version":3,"names":["IOSConfig","withXcodeProject","FileManagement","isFcmPushProvider","withGoogleServicesJsonFile","config","cioProps","props","_cioProps$pushNotific","useFcm","console","log","iosPath","modRequest","platformProjectRoot","googleServicesFile","pushNotification","appName","projectName","exists","_config$ios","ios","warn","copyFile","addFileToXcodeProject","modResults","error","project","fileName","groupName","filepath","XcodeUtils","ensureGroupRecursively","addResourceFileToGroup","isBuildFile"],"sources":["withGoogleServicesJsonFile.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { IOSConfig, withXcodeProject } from '@expo/config-plugins';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isFcmPushProvider } from './utils';\n\nexport const withGoogleServicesJsonFile: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (config, cioProps) => {\n return withXcodeProject(config, async (props) => {\n const useFcm = isFcmPushProvider(cioProps);\n if (!useFcm) {\n // Nothing to do, for providers other than FCM, the Google services JSON file isn't needed\n return props;\n }\n\n console.log(\n 'Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' +\n ' GoogleService-Info.plist as part of Firebase integration'\n );\n\n // googleServicesFile\n const iosPath = props.modRequest.platformProjectRoot;\n const googleServicesFile = cioProps.pushNotification?.googleServicesFile;\n const appName = props.modRequest.projectName;\n\n if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {\n console.log(\n `File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (\n FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)\n ) {\n // This is where RN Firebase potentially copies GoogleService-Info.plist\n // Do not copy if it's already done by Firebase to avoid conflict in Resources\n console.log(\n `File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n if (config.ios?.googleServicesFile) {\n console.warn(\n 'Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' +\n ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile'\n );\n }\n\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${iosPath}/GoogleService-Info.plist`\n );\n\n addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');\n } catch {\n console.error(\n `There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n } else {\n console.error(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n\n return props;\n });\n};\n\nfunction addFileToXcodeProject(project: XcodeProject, fileName: string) {\n const groupName = 'Resources';\n const filepath = fileName;\n\n if (!IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {\n console.error(\n `Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`\n );\n return;\n }\n\n // Add GoogleService-Info.plist to the Xcode project\n IOSConfig.XcodeUtils.addResourceFileToGroup({\n project,\n filepath,\n groupName,\n isBuildFile: true,\n });\n}\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,gBAAgB,QAAQ,sBAAsB;AAGlE,SAASC,cAAc,QA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AQ,CACrBR,kBAAkB,EAClB,GAAGH,OAAO,2BACZ,CAAC;QAEDY,qBAAqB,CAACjB,KAAK,CAACkB,UAAU,EAAE,0BAA0B,CAAC;MACrE,CAAC,CAAC,MAAM;QACNf,OAAO,CAACgB,KAAK,CACX,gGAAgGd,OAAO,2BACzG,CAAC;MACH;IACF,CAAC,MAAM;MACLF,OAAO,CAACgB,KAAK,CACX,wCAAwCX,kBAAkB,yDAAyDH,OAAO,2BAC5H,CAAC;IACH;IAEA,OAAOL,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAED,SAASiB,qBAAqBA,CAACG,OAAqB,EAAEC,QAAgB,EAAE;EACtE,MAAMC,SAAS,GAAG,WAAW;EAC7B,MAAMC,QAAQ,GAAGF,QAAQ;EAEzB,IAAI,CAAC5B,SAAS,CAAC+B,UAAU,CAACC,sBAAsB,CAACL,OAAO,EAAEE,SAAS,CAAC,EAAE;IACpEnB,OAAO,CAACgB,KAAK,CACX,qEAAqEG,SAAS,mBAChF,CAAC;IACD;EACF;;EAEA;EACA7B,SAAS,CAAC+B,UAAU,CAACE,sBAAsB,CAAC;IAC1CN,OAAO;IACPG,QAAQ;IACRD,SAAS;IACTK,WAAW,EAAE;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["IOSConfig","withXcodeProject","logger","FileManagement","isFcmPushProvider","withGoogleServicesJsonFile","config","cioProps","props","_cioProps$pushNotific","useFcm","info","iosPath","modRequest","platformProjectRoot","googleServicesFile","pushNotification","appName","projectName","exists","_config$ios","ios","warn","copyFile","addFileToXcodeProject","modResults","error","project","fileName","groupName","filepath","XcodeUtils","ensureGroupRecursively","addResourceFileToGroup","isBuildFile"],"sources":["withGoogleServicesJsonFile.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { IOSConfig, withXcodeProject } from '@expo/config-plugins';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isFcmPushProvider } from './utils';\n\nexport const withGoogleServicesJsonFile: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (config, cioProps) => {\n return withXcodeProject(config, async (props) => {\n const useFcm = isFcmPushProvider(cioProps);\n if (!useFcm) {\n // Nothing to do, for providers other than FCM, the Google services JSON file isn't needed\n return props;\n }\n\n logger.info(\n 'Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' +\n ' GoogleService-Info.plist as part of Firebase integration'\n );\n\n // googleServicesFile\n const iosPath = props.modRequest.platformProjectRoot;\n const googleServicesFile = cioProps.pushNotification?.googleServicesFile;\n const appName = props.modRequest.projectName;\n\n if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {\n logger.info(\n `File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (\n FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)\n ) {\n // This is where RN Firebase potentially copies GoogleService-Info.plist\n // Do not copy if it's already done by Firebase to avoid conflict in Resources\n logger.info(\n `File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n if (config.ios?.googleServicesFile) {\n logger.warn(\n 'Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' +\n ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile'\n );\n }\n\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${iosPath}/GoogleService-Info.plist`\n );\n\n addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');\n } catch {\n logger.error(\n `There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n } else {\n logger.error(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n\n return props;\n });\n};\n\nfunction addFileToXcodeProject(project: XcodeProject, fileName: string) {\n const groupName = 'Resources';\n const filepath = fileName;\n\n if (!IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {\n logger.error(\n `Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`\n );\n return;\n }\n\n // Add GoogleService-Info.plist to the Xcode project\n IOSConfig.XcodeUtils.addResourceFileToGroup({\n project,\n filepath,\n groupName,\n isBuildFile: true,\n });\n}\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,gBAAgB,QAAQ,sBAAsB;AAGlE,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,OAAO,MAAMC,0BAEZ,GAAGA,CAACC,MAAM,EAAEC,QAAQ,KAAK;EACxB,OAAON,gBAAgB,CAACK,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA,IAAAC,qBAAA;IAC/C,MAAMC,MAAM,GAAGN,iBAAiB,CAACG,QAAQ,CAAC;IAC1C,IAAI,CAACG,MAAM,EAAE;MACX;MACA,OAAOF,KAAK;IACd;IAEAN,MAAM,CAACS,IAAI,CACT,0GAA0G,GAC1G,2DACF,CAAC;;IAED;IACA,MAAMC,OAAO,GAAGJ,KAAK,CAACK,UAAU,CAACC,mBAAmB;IACpD,MAAMC,kBAAkB,IAAAN,qBAAA,GAAGF,QAAQ,CAACS,gBAAgB,cAAAP,qBAAA,uBAAzBA,qBAAA,CAA2BM,kBAAkB;IACxE,MAAME,OAAO,GAAGT,KAAK,CAACK,UAAU,CAACK,WAAW;IAE5C,IAAIf,cAAc,CAACgB,MAAM,CAAC,GAAGP,OAAO,2BAA2B,CAAC,EAAE;MAChEV,MAAM,CAACS,IAAI,CACT,wBAAwBC,OAAO,wCACjC,CAAC;MACD,OAAOJ,KAAK;IACd;IAEA,IACEL,cAAc,CAACgB,MAAM,CAAC,GAAGP,OAAO,IAAIK,O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eProject } from '@expo/config-plugins';
2
2
  import { CIO_NOTIFICATION_TARGET_NAME, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET, DEFAULT_BUNDLE_VERSION } from '../helpers/constants/ios';
3
3
  import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
4
4
  import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
5
+ import { logger } from '../utils/logger';
5
6
  import { getIosNativeFilesPath } from '../utils/plugin';
7
+ import { validateRichPushConfig } from '../utils/validation';
6
8
  import { FileManagement } from './../helpers/utils/fileManagement';
7
9
  import { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';
8
10
  const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
@@ -20,7 +22,7 @@ const addNotificationServiceExtension = async (options, xcodeProject, isExpo53Or
20
22
  }
21
23
  return xcodeProject;
22
24
  } catch (error) {
23
- console.error(error);
25
+ logger.error(String(error));
24
26
  return null;
25
27
  }
26
28
  };
@@ -91,7 +93,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
91
93
  // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project
92
94
  // If true then skip creating a new group to avoid duplicate folders
93
95
  if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
94
- console.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
96
+ logger.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
95
97
  return;
96
98
  }
97
99
  const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;
@@ -144,7 +146,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
144
146
  projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};
145
147
  projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};
146
148
  if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
147
- console.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
149
+ logger.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
148
150
  return;
149
151
  }
150
152
 
@@ -194,21 +196,24 @@ const updateNseEnv = (envFileName, richPushConfig) => {
194
196
  // Use merged config values (config takes precedence over env)
195
197
  const cdpApiKey = richPushConfig === null || richPushConfig === void 0 ? void 0 : richPushConfig.cdpApiKey;
196
198
  const region = richPushConfig === null || richPushConfig === void 0 ? void 0 : richPushConfig.region;
197
- if (!cdpApiKey) {
198
- throw new Error('NotificationServiceExtension failed: cdpApiKey missing. Provide in config.cdpApiKey or ios.pushNotification.env.cdpApiKey.');
199
+ if (!validateRichPushConfig(richPushConfig)) {
200
+ return;
199
201
  }
200
- envFileContent = replaceCodeByRegex(envFileContent, CDP_API_KEY_RE, cdpApiKey);
201
- if (region) {
202
- const regionMap = {
203
- us: 'Region.US',
204
- eu: 'Region.EU'
205
- };
206
- const mappedRegion = regionMap[region.toLowerCase()] || '';
207
- if (!mappedRegion) {
208
- console.warn(`${region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`);
209
- } else {
210
- envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);
211
- }
202
+ envFileContent = replaceCodeByRegex(envFileContent, CDP_API_KEY_RE, cdpApiKey || 'MISSING_API_KEY');
203
+
204
+ // Simplify region mapping with case insensitive keys and fallback for invalid regions
205
+ const regionKey = (region === null || region === void 0 ? void 0 : region.toLowerCase()) ?? '';
206
+ const regionMap = {
207
+ us: 'Region.US',
208
+ eu: 'Region.EU'
209
+ };
210
+ const mappedRegion = regionMap[regionKey];
211
+ if (!mappedRegion) {
212
+ logger.warn(`${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`);
213
+ // Fallback to US if invalid region provided
214
+ envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, regionMap.us);
215
+ } else {
216
+ envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);
212
217
  }
213
218
  FileManagement.writeFile(envFileName, envFileContent);
214
219
  };
@@ -234,7 +239,7 @@ async function addPushNotificationFile(options, xcodeProject) {
234
239
  });
235
240
  FileManagement.copyFile(`${getIosNativeFilesPath()}/${sourceFile}`, targetFile);
236
241
  } else {
237
- console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);
242
+ logger.info(`${getTargetFile(targetFileName)} already exists. Skipping...`);
238
243
  return;
239
244
  }
240
245
  updatePushFile(options, targetFile);
@@ -250,18 +255,19 @@ const updatePushFile = (options, envFileName) => {
250
255
  const REGISTER_RE = /\{\{REGISTER_SNIPPET\}\}/;
251
256
  let envFileContent = FileManagement.readFile(envFileName);
252
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;
253
259
  const {
254
260
  cdpApiKey,
255
261
  region
256
- } = ((_options$pushNotifica4 = options.pushNotification) === null || _options$pushNotifica4 === void 0 ? void 0 : _options$pushNotifica4.env) || {
257
- cdpApiKey: undefined,
262
+ } = richPushConfig || {
263
+ cdpApiKey: 'MISSING_API_KEY',
258
264
  region: undefined
259
265
  };
260
- if (!cdpApiKey) {
261
- throw new Error('Adding NotificationServiceExtension failed: ios.pushNotification.env.cdpApiKey is missing from app.config.js or app.json.');
266
+ if (!validateRichPushConfig(richPushConfig)) {
267
+ return;
262
268
  }
263
269
  let snippet = '';
264
- // unless this property is explicity set to true, push notification
270
+ // unless this property is explicitly set to true, push notification
265
271
  // registration will be added to the AppDelegate
266
272
  if (disableNotificationRegistration !== true) {
267
273
  snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;