customerio-expo-plugin 3.3.0 → 3.5.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 (107) hide show
  1. package/package.json +8 -1
  2. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +64 -59
  3. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
  4. package/plugin/lib/commonjs/android/withAppGoogleServices.js +10 -7
  5. package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
  6. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +18 -21
  7. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  8. package/plugin/lib/commonjs/android/withLocationGradleProperties.js +16 -12
  9. package/plugin/lib/commonjs/android/withLocationGradleProperties.js.map +1 -1
  10. package/plugin/lib/commonjs/android/withMainApplicationModifications.js +19 -12
  11. package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
  12. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +2 -1
  13. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
  14. package/plugin/lib/commonjs/android/withProjectBuildGradle.js +29 -25
  15. package/plugin/lib/commonjs/android/withProjectBuildGradle.js.map +1 -1
  16. package/plugin/lib/commonjs/android/withProjectGoogleServices.js +9 -5
  17. package/plugin/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
  18. package/plugin/lib/commonjs/helpers/constants/ios.js +76 -8
  19. package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
  20. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +76 -31
  21. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  22. package/plugin/lib/commonjs/index.js +7 -0
  23. package/plugin/lib/commonjs/index.js.map +1 -1
  24. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +47 -33
  25. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  26. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +44 -54
  27. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  28. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +46 -30
  29. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
  30. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +192 -122
  31. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  32. package/plugin/lib/commonjs/postInstallHelper.js +58 -11
  33. package/plugin/lib/commonjs/postInstallHelper.js.map +1 -1
  34. package/plugin/lib/commonjs/utils/resolveRNSDK.js +97 -0
  35. package/plugin/lib/commonjs/utils/resolveRNSDK.js.map +1 -0
  36. package/plugin/lib/commonjs/utils/writeExpoVersion.js +56 -0
  37. package/plugin/lib/commonjs/utils/writeExpoVersion.js.map +1 -0
  38. package/plugin/lib/module/android/withAndroidManifestUpdates.js +61 -58
  39. package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
  40. package/plugin/lib/module/android/withAppGoogleServices.js +9 -7
  41. package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
  42. package/plugin/lib/module/android/withGoogleServicesJSON.js +17 -21
  43. package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  44. package/plugin/lib/module/android/withLocationGradleProperties.js +15 -12
  45. package/plugin/lib/module/android/withLocationGradleProperties.js.map +1 -1
  46. package/plugin/lib/module/android/withMainApplicationModifications.js +18 -12
  47. package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
  48. package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
  49. package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
  50. package/plugin/lib/module/android/withProjectBuildGradle.js +28 -25
  51. package/plugin/lib/module/android/withProjectBuildGradle.js.map +1 -1
  52. package/plugin/lib/module/android/withProjectGoogleServices.js +8 -5
  53. package/plugin/lib/module/android/withProjectGoogleServices.js.map +1 -1
  54. package/plugin/lib/module/helpers/constants/ios.js +75 -8
  55. package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
  56. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +74 -31
  57. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  58. package/plugin/lib/module/index.js +7 -0
  59. package/plugin/lib/module/index.js.map +1 -1
  60. package/plugin/lib/module/ios/withAppDelegateModifications.js +45 -33
  61. package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  62. package/plugin/lib/module/ios/withCIOIosSwift.js +42 -54
  63. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  64. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +45 -30
  65. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
  66. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +187 -122
  67. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  68. package/plugin/lib/module/postInstallHelper.js +58 -11
  69. package/plugin/lib/module/postInstallHelper.js.map +1 -1
  70. package/plugin/lib/module/utils/resolveRNSDK.js +88 -0
  71. package/plugin/lib/module/utils/resolveRNSDK.js.map +1 -0
  72. package/plugin/lib/module/utils/writeExpoVersion.js +48 -0
  73. package/plugin/lib/module/utils/writeExpoVersion.js.map +1 -0
  74. package/plugin/lib/typescript/android/withAndroidManifestUpdates.d.ts +2 -0
  75. package/plugin/lib/typescript/android/withAppGoogleServices.d.ts +1 -0
  76. package/plugin/lib/typescript/android/withGoogleServicesJSON.d.ts +1 -0
  77. package/plugin/lib/typescript/android/withLocationGradleProperties.d.ts +2 -0
  78. package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +6 -0
  79. package/plugin/lib/typescript/android/withNotificationChannelMetadata.d.ts +5 -0
  80. package/plugin/lib/typescript/android/withProjectBuildGradle.d.ts +9 -0
  81. package/plugin/lib/typescript/android/withProjectGoogleServices.d.ts +1 -0
  82. package/plugin/lib/typescript/helpers/constants/ios.d.ts +18 -0
  83. package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +25 -1
  84. package/plugin/lib/typescript/ios/withAppDelegateModifications.d.ts +13 -0
  85. package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +11 -0
  86. package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +14 -1
  87. package/plugin/lib/typescript/ios/withNotificationsXcodeProject.d.ts +53 -2
  88. package/plugin/lib/typescript/utils/resolveRNSDK.d.ts +7 -0
  89. package/plugin/lib/typescript/utils/writeExpoVersion.d.ts +3 -0
  90. package/plugin/src/android/withAndroidManifestUpdates.ts +83 -73
  91. package/plugin/src/android/withAppGoogleServices.ts +13 -11
  92. package/plugin/src/android/withGoogleServicesJSON.ts +30 -28
  93. package/plugin/src/android/withLocationGradleProperties.ts +23 -17
  94. package/plugin/src/android/withMainApplicationModifications.ts +25 -15
  95. package/plugin/src/android/withNotificationChannelMetadata.ts +1 -1
  96. package/plugin/src/android/withProjectBuildGradle.ts +37 -27
  97. package/plugin/src/android/withProjectGoogleServices.ts +14 -9
  98. package/plugin/src/helpers/constants/ios.ts +87 -8
  99. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +97 -50
  100. package/plugin/src/index.ts +7 -0
  101. package/plugin/src/ios/withAppDelegateModifications.ts +61 -48
  102. package/plugin/src/ios/withCIOIosSwift.ts +58 -62
  103. package/plugin/src/ios/withGoogleServicesJsonFile.ts +66 -48
  104. package/plugin/src/ios/withNotificationsXcodeProject.ts +257 -207
  105. package/plugin/src/postInstallHelper.js +75 -17
  106. package/plugin/src/utils/resolveRNSDK.ts +118 -0
  107. package/plugin/src/utils/writeExpoVersion.ts +62 -0
@@ -1 +1 @@
1
- {"version":3,"names":["logger","getRelativePathToRNSDK","injectCodeByRegex","FileManagement","buildHostAppPodSnippet","iosPath","isFcmPushProvider","options","path","locationEnabled","hasPush","subspec","pushSubspec","injectCIOPodfileCode","blockStart","blockEnd","filename","podfile","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","podLine","snippetToInjectInPodfile","trim","write","join","info","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { logger } from '../../utils/logger';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport type InjectCIOPodfileOptions = {\n /** When true, add the location subspec. When false/omit, use single push subspec only. */\n locationEnabled?: boolean;\n /** When false and locationEnabled, inject only :subspecs => ['location']. When true, use push + location. */\n hasPush?: boolean;\n};\n\n/** Builds the host app pod line for the Podfile (single subspec or :subspecs with location). Exported for tests. */\nexport function buildHostAppPodSnippet(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n): string {\n const path = getRelativePathToRNSDK(iosPath);\n const locationEnabled = options?.locationEnabled === true;\n const hasPush = options?.hasPush !== false;\n\n if (!locationEnabled) {\n const subspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative/${subspec}', :path => '${path}'`;\n }\n\n if (!hasPush) {\n return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${path}'`;\n }\n\n const pushSubspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${path}'`;\n}\n\nexport async function injectCIOPodfileCode(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const podLine = buildHostAppPodSnippet(iosPath, isFcmPushProvider, options);\n\n const snippetToInjectInPodfile = `\n${blockStart}\n ${podLine}\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n logger.info('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],\n isFcmPushProvider: boolean\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/${isFcmPushProvider ? 'fcm' : 'apn'\n }', :path => '${getRelativePathToRNSDK(iosPath)}'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,cAAc,QAAQ,kBAAkB;AASjD;AACA,OAAO,SAASC,sBAAsBA,CACpCC,OAAe,EACfC,iBAA0B,EAC1BC,OAAiC,EACzB;EACR,MAAMC,IAAI,GAAGP,sBAAsB,CAACI,OAAO,CAAC;EAC5C,MAAMI,eAAe,GAAG,CAAAF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,eAAe,MAAK,IAAI;EACzD,MAAMC,OAAO,GAAG,CAAAH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,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B,OAAe,EACfyB,aAA0D,EAC1DxB,iBAA0B,EAC1B;EACA,MAAMU,QAAQ,GAAG,GAAGX,OAAO,UAAU;EACrC,MAAMY,OAAO,GAAG,MAAMd,cAAc,CAACe,IAAI,CAACF,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMI,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,IAAIC,MAAM,CAACP,UAAU,CAAC,CAAC;EAErD,IAAI,CAACK,OAAO,EAAE;IACZ,MAAMK,wBAAwB,GAAG;AACrC,EAAEV,UAAU;AACZ;AACA,IAAIgB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyCxB,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBACpDL,sBAAsB,CAACI,OAAO,CAAC;AACrD;AACA,EAAEU,QAAQ;AACV,CAAC,CAACU,IAAI,CAAC,CAAC;IAEJtB,cAAc,CAAC4B,MAAM,CAACf,QAAQ,EAAEQ,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
1
+ {"version":3,"names":["logger","getRelativePathToRNSDK","injectCodeByRegex","FileManagement","buildHostAppPodSnippet","iosPath","isFcmPushProvider","options","resolvedPath","locationEnabled","hasPush","subspec","pushSubspec","HOST_APP_BLOCK_START","HOST_APP_BLOCK_END","NOTIFICATION_BLOCK_START","NOTIFICATION_BLOCK_END","injectHostAppPodfileCode","podfileContent","match","RegExp","lineInPodfileToInjectSnippetBefore","podLine","snippetToInjectInPodfile","trim","join","injectCIOPodfileCode","filename","podfile","read","next","write","info","appendNotificationTargetToPodfile","useFrameworks","snippetToAppend","injectCIONotificationPodfileCode","append","slice","length"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { logger } from '../../utils/logger';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport type InjectCIOPodfileOptions = {\n /** When true, add the location subspec. When false/omit, use single push subspec only. */\n locationEnabled?: boolean;\n /** When false and locationEnabled, inject only :subspecs => ['location']. When true, use push + location. */\n hasPush?: boolean;\n};\n\n/** Builds the host-app pod snippet for the Podfile.\n *\n * The :path is resolved at prebuild time by `getRelativePathToRNSDK`,\n * which dispatches on the installed React Native version so the path\n * matches what RN pod autolinking will emit (lexical for RN <0.80,\n * realpath for RN >=0.80). Baking the resolved string directly avoids\n * any Ruby/install-time logic in the Podfile and keeps the snippet\n * trivially diff-able.\n *\n * Exported for tests.\n */\nexport function buildHostAppPodSnippet(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n): string {\n const resolvedPath = getRelativePathToRNSDK(iosPath);\n const locationEnabled = options?.locationEnabled === true;\n const hasPush = options?.hasPush !== false;\n\n if (!locationEnabled) {\n const subspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative/${subspec}', :path => '${resolvedPath}'`;\n }\n if (!hasPush) {\n return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${resolvedPath}'`;\n }\n const pushSubspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${resolvedPath}'`;\n}\n\nconst HOST_APP_BLOCK_START = '# --- CustomerIO Host App START ---';\nconst HOST_APP_BLOCK_END = '# --- CustomerIO Host App END ---';\nconst NOTIFICATION_BLOCK_START = '# --- CustomerIO Notification START ---';\nconst NOTIFICATION_BLOCK_END = '# --- CustomerIO Notification END ---';\n\n/**\n * Pure string transform: given the existing Podfile contents, returns the\n * Podfile with the CustomerIO host-app block injected before the Expo\n * `post_install do |installer|` anchor. Idempotent — returns input unchanged\n * if the block is already present.\n */\nexport function injectHostAppPodfileCode(\n podfileContent: string,\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n): string {\n if (podfileContent.match(new RegExp(HOST_APP_BLOCK_START))) {\n return podfileContent;\n }\n\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n const podLine = buildHostAppPodSnippet(iosPath, isFcmPushProvider, options);\n\n const snippetToInjectInPodfile = `\n${HOST_APP_BLOCK_START}\n ${podLine}\n${HOST_APP_BLOCK_END}\n`.trim();\n\n return injectCodeByRegex(\n podfileContent,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile,\n ).join('\\n');\n}\n\nexport async function injectCIOPodfileCode(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const next = injectHostAppPodfileCode(podfile, iosPath, isFcmPushProvider, options);\n if (next !== podfile) {\n FileManagement.write(filename, next);\n } else {\n logger.info('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\n/**\n * Pure string transform: given the existing Podfile contents, returns the\n * Podfile with the rich-push NotificationService target block appended at\n * the end. Idempotent — returns input unchanged if the block is already\n * present.\n */\nexport function appendNotificationTargetToPodfile(\n podfileContent: string,\n iosPath: string,\n isFcmPushProvider: boolean,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],\n): string {\n if (podfileContent.match(new RegExp(NOTIFICATION_BLOCK_START))) {\n return podfileContent;\n }\n\n const snippetToAppend = `\n${NOTIFICATION_BLOCK_START}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/${isFcmPushProvider ? 'fcm' : 'apn'}', :path => '${getRelativePathToRNSDK(iosPath)}'\nend\n${NOTIFICATION_BLOCK_END}\n`.trim();\n\n // Mirror FileManagement.append: append directly with no separator (real\n // Podfiles end with a trailing newline, so the appended block starts on a\n // fresh line in practice).\n return `${podfileContent}${snippetToAppend}`;\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],\n isFcmPushProvider: boolean\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const next = appendNotificationTargetToPodfile(\n podfile,\n iosPath,\n isFcmPushProvider,\n useFrameworks,\n );\n if (next !== podfile) {\n // FileManagement.append matches what the previous direct-append did.\n // Slice off the leading content (already on disk) and append only the new tail.\n FileManagement.append(filename, next.slice(podfile.length));\n }\n}\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,cAAc,QAAQ,kBAAkB;AASjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCC,OAAe,EACfC,iBAA0B,EAC1BC,OAAiC,EACzB;EACR,MAAMC,YAAY,GAAGP,sBAAsB,CAACI,OAAO,CAAC;EACpD,MAAMI,eAAe,GAAG,CAAAF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,eAAe,MAAK,IAAI;EACzD,MAAMC,OAAO,GAAG,CAAAH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,OAAO,MAAK,KAAK;EAE1C,IAAI,CAACD,eAAe,EAAE;IACpB,MAAME,OAAO,GAAGL,iBAAiB,GAAG,KAAK,GAAG,KAAK;IACjD,OAAO,+BAA+BK,OAAO,gBAAgBH,YAAY,GAAG;EAC9E;EACA,IAAI,CAACE,OAAO,EAAE;IACZ,OAAO,sEAAsEF,YAAY,GAAG;EAC9F;EACA,MAAMI,WAAW,GAAGN,iBAAiB,GAAG,KAAK,GAAG,KAAK;EACrD,OAAO,gDAAgDM,WAAW,6BAA6BJ,YAAY,GAAG;AAChH;AAEA,MAAMK,oBAA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A;AACA,OAAO,SAASC,iCAAiCA,CAC/Cf,cAAsB,EACtBb,OAAe,EACfC,iBAA0B,EAC1B4B,aAA0D,EAClD;EACR,IAAIhB,cAAc,CAACC,KAAK,CAAC,IAAIC,MAAM,CAACL,wBAAwB,CAAC,CAAC,EAAE;IAC9D,OAAOG,cAAc;EACvB;EAEA,MAAMiB,eAAe,GAAG;AAC1B,EAAEpB,wBAAwB;AAC1B;AACA,IAAImB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyC5B,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBAAgBL,sBAAsB,CAACI,OAAO,CAAC;AACzH;AACA,EAAEW,sBAAsB;AACxB,CAAC,CAACQ,IAAI,CAAC,CAAC;;EAEN;EACA;EACA;EACA,OAAO,GAAGN,cAAc,GAAGiB,eAAe,EAAE;AAC9C;AAEA,OAAO,eAAeC,gCAAgCA,CACpD/B,OAAe,EACf6B,aAA0D,EAC1D5B,iBAA0B,EAC1B;EACA,MAAMqB,QAAQ,GAAG,GAAGtB,OAAO,UAAU;EACrC,MAAMuB,OAAO,GAAG,MAAMzB,cAAc,CAAC0B,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,IAAI,GAAGG,iCAAiC,CAC5CL,OAAO,EACPvB,OAAO,EACPC,iBAAiB,EACjB4B,aACF,CAAC;EACD,IAAIJ,IAAI,KAAKF,OAAO,EAAE;IACpB;IACA;IACAzB,cAAc,CAACkC,MAAM,CAACV,QAAQ,EAAEG,IAAI,CAACQ,KAAK,CAACV,OAAO,CAACW,MAAM,CAAC,CAAC;EAC7D;AACF","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  import { withCIOAndroid } from './android/withCIOAndroid';
2
2
  import { isExpoVersion53OrHigher } from './ios/utils';
3
3
  import { withCIOIos } from './ios/withCIOIos';
4
+ import { withExpoVersion } from './utils/writeExpoVersion';
4
5
  // Entry point for config plugin
5
6
  function withCustomerIOPlugin(config, props) {
6
7
  // Check if config is being used with unsupported Expo version
@@ -8,6 +9,12 @@ function withCustomerIOPlugin(config, props) {
8
9
  throw new Error('CustomerIO auto initialization (config property) requires Expo SDK 53 or higher. ' + 'Please upgrade to Expo SDK 53+ or use manual initialization instead. ' + 'See documentation for manual setup instructions.');
9
10
  }
10
11
 
12
+ // Belt-and-suspenders write of the plugin version into the RN SDK's
13
+ // package.json. The postinstall hook does the same write at install time;
14
+ // this covers installs where postinstall didn't run cleanly (pnpm with
15
+ // strict store layouts, --ignore-scripts, cached CI installs, etc).
16
+ config = withExpoVersion(config);
17
+
11
18
  // Apply platform specific modifications
12
19
  config = withCIOIos(config, props.config, props.ios, props.location);
13
20
  config = withCIOAndroid(config, props.config, props.android, props.location);
@@ -1 +1 @@
1
- {"version":3,"names":["withCIOAndroid","isExpoVersion53OrHigher","withCIOIos","withCustomerIOPlugin","config","props","Error","ios","location","android"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { isExpoVersion53OrHigher } from './ios/utils';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {\n CustomerIOPluginOptions,\n LocationTrackingMode,\n NativeSDKConfig,\n} from './types/cio-types';\n\nexport type { LocationTrackingMode, NativeSDKConfig };\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n // Check if config is being used with unsupported Expo version\n if (props.config && !isExpoVersion53OrHigher(config)) {\n throw new Error(\n 'CustomerIO auto initialization (config property) requires Expo SDK 53 or higher. ' +\n 'Please upgrade to Expo SDK 53+ or use manual initialization instead. ' +\n 'See documentation for manual setup instructions.'\n );\n }\n\n // Apply platform specific modifications\n config = withCIOIos(config, props.config, props.ios, props.location);\n config = withCIOAndroid(config, props.config, props.android, props.location);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,uBAAuB,QAAQ,aAAa;AACrD,SAASC,UAAU,QAAQ,kBAAkB;AAS7C;AACA,SAASC,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA;EACA,IAAIA,KAAK,CAACD,MAAM,IAAI,CAACH,uBAAuB,CAACG,MAAM,CAAC,EAAE;IACpD,MAAM,IAAIE,KAAK,CACb,mFAAmF,GACnF,uEAAuE,GACvE,kDACF,CAAC;EACH;;EAEA;EACAF,MAAM,GAAGF,UAAU,CAACE,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACE,GAAG,EAAEF,KAAK,CAACG,QAAQ,CAAC;EACpEJ,MAAM,GAAGJ,cAAc,CAACI,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACI,OAAO,EAAEJ,KAAK,CAACG,QAAQ,CAAC;EAE5E,OAAOJ,MAAM;AACf;AAEA,eAAeD,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["withCIOAndroid","isExpoVersion53OrHigher","withCIOIos","withExpoVersion","withCustomerIOPlugin","config","props","Error","ios","location","android"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { isExpoVersion53OrHigher } from './ios/utils';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {\n CustomerIOPluginOptions,\n LocationTrackingMode,\n NativeSDKConfig,\n} from './types/cio-types';\nimport { withExpoVersion } from './utils/writeExpoVersion';\n\nexport type { LocationTrackingMode, NativeSDKConfig };\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n // Check if config is being used with unsupported Expo version\n if (props.config && !isExpoVersion53OrHigher(config)) {\n throw new Error(\n 'CustomerIO auto initialization (config property) requires Expo SDK 53 or higher. ' +\n 'Please upgrade to Expo SDK 53+ or use manual initialization instead. ' +\n 'See documentation for manual setup instructions.'\n );\n }\n\n // Belt-and-suspenders write of the plugin version into the RN SDK's\n // package.json. The postinstall hook does the same write at install time;\n // this covers installs where postinstall didn't run cleanly (pnpm with\n // strict store layouts, --ignore-scripts, cached CI installs, etc).\n config = withExpoVersion(config);\n\n // Apply platform specific modifications\n config = withCIOIos(config, props.config, props.ios, props.location);\n config = withCIOAndroid(config, props.config, props.android, props.location);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,uBAAuB,QAAQ,aAAa;AACrD,SAASC,UAAU,QAAQ,kBAAkB;AAM7C,SAASC,eAAe,QAAQ,0BAA0B;AAI1D;AACA,SAASC,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA;EACA,IAAIA,KAAK,CAACD,MAAM,IAAI,CAACJ,uBAAuB,CAACI,MAAM,CAAC,EAAE;IACpD,MAAM,IAAIE,KAAK,CACb,mFAAmF,GACnF,uEAAuE,GACvE,kDACF,CAAC;EACH;;EAEA;EACA;EACA;EACA;EACAF,MAAM,GAAGF,eAAe,CAACE,MAAM,CAAC;;EAEhC;EACAA,MAAM,GAAGH,UAAU,CAACG,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACE,GAAG,EAAEF,KAAK,CAACG,QAAQ,CAAC;EACpEJ,MAAM,GAAGL,cAAc,CAACK,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACI,OAAO,EAAEJ,KAAK,CAACG,QAAQ,CAAC;EAE5E,OAAOJ,MAAM;AACf;AAEA,eAAeD,oBAAoB","ignoreList":[]}
@@ -59,9 +59,13 @@ const addFirebaseDelegateForwardDeclarationIfNeeded = stringContents => {
59
59
  stringContents = injectCodeByLineNumber(stringContents, 0, '@protocol FIRMessagingDelegate;');
60
60
  return stringContents;
61
61
  };
62
- const addAppdelegateHeaderModification = stringContents => {
63
- // Add UNUserNotificationCenterDelegate if needed
64
- stringContents = stringContents.replace(CIO_APPDELEGATEHEADER_REGEX, (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {
62
+
63
+ /**
64
+ * Pure string transform: ensures the AppDelegate header (Objective-C path) declares
65
+ * `UNUserNotificationCenterDelegate` and imports `UserNotifications`. Idempotent.
66
+ */
67
+ export function modifyAppDelegateHeader(headerContent) {
68
+ return headerContent.replace(CIO_APPDELEGATEHEADER_REGEX, (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {
65
69
  if (existingDelegates && existingDelegates.includes(CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET)) {
66
70
  // The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it
67
71
  return match;
@@ -77,8 +81,7 @@ ${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER
77
81
  `;
78
82
  }
79
83
  });
80
- return stringContents;
81
- };
84
+ }
82
85
  const addHandleDeeplinkInKilledState = stringContents => {
83
86
  // Find if the deep link code snippet is already present
84
87
  if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {
@@ -101,39 +104,48 @@ const addHandleDeeplinkInKilledState = stringContents => {
101
104
  }
102
105
  return stringContents;
103
106
  };
107
+
108
+ /**
109
+ * Pure string transform: produces the modified Objective-C AppDelegate.m / AppDelegate.mm
110
+ * contents wired with the Customer.io push pipeline (imports, declarations, notification
111
+ * configuration, registration callbacks, optional killed-state deep-link, FCM forward decl,
112
+ * Expo notifications header). The caller is responsible for the AppDelegate header file
113
+ * (.h) — see `modifyAppDelegateHeader`.
114
+ */
115
+ export function modifyAppDelegateContents(contents, projectName, props) {
116
+ var _props$pushNotificati, _props$pushNotificati2;
117
+ let next = addImport(contents, projectName);
118
+ next = addNotificationHandlerDeclaration(next);
119
+
120
+ // unless this property is explicity set to true, push notification
121
+ // registration will be added to the AppDelegate
122
+ if (((_props$pushNotificati = props.pushNotification) === null || _props$pushNotificati === void 0 ? void 0 : _props$pushNotificati.disableNotificationRegistration) !== true) {
123
+ next = addNotificationConfiguration(next);
124
+ }
125
+ next = addInitializeNativeCioSdk(next);
126
+ if (((_props$pushNotificati2 = props.pushNotification) === null || _props$pushNotificati2 === void 0 ? void 0 : _props$pushNotificati2.handleDeeplinkInKilledState) === true) {
127
+ next = addHandleDeeplinkInKilledState(next);
128
+ }
129
+ next = addDidFailToRegisterForRemoteNotificationsWithError(next);
130
+ next = addDidRegisterForRemoteNotificationsWithDeviceToken(next);
131
+ if (isFcmPushProvider(props)) {
132
+ next = addFirebaseDelegateForwardDeclarationIfNeeded(next);
133
+ }
134
+ next = addExpoNotificationsHeaderModification(next);
135
+ return next;
136
+ }
104
137
  export const withAppDelegateModifications = (configOuter, props) => {
105
138
  return withAppDelegate(configOuter, async config => {
106
- let stringContents = config.modResults.contents;
139
+ const stringContents = config.modResults.contents;
107
140
  const regex = new RegExp(`#import <${config.modRequest.projectName}-Swift.h>`);
108
- const match = stringContents.match(regex);
109
- if (!match) {
110
- var _props$pushNotificati, _props$pushNotificati2;
111
- const headerPath = getAppDelegateHeaderFilePath(config.modRequest.projectRoot);
112
- let headerContent = await FileManagement.read(headerPath);
113
- headerContent = addAppdelegateHeaderModification(headerContent);
114
- FileManagement.write(headerPath, headerContent);
115
- stringContents = addImport(stringContents, config.modRequest.projectName);
116
- stringContents = addNotificationHandlerDeclaration(stringContents);
117
-
118
- // unless this property is explicity set to true, push notification
119
- // registration will be added to the AppDelegate
120
- if (((_props$pushNotificati = props.pushNotification) === null || _props$pushNotificati === void 0 ? void 0 : _props$pushNotificati.disableNotificationRegistration) !== true) {
121
- stringContents = addNotificationConfiguration(stringContents);
122
- }
123
- stringContents = addInitializeNativeCioSdk(stringContents);
124
- if (((_props$pushNotificati2 = props.pushNotification) === null || _props$pushNotificati2 === void 0 ? void 0 : _props$pushNotificati2.handleDeeplinkInKilledState) === true) {
125
- stringContents = addHandleDeeplinkInKilledState(stringContents);
126
- }
127
- stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
128
- stringContents = addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
129
- if (isFcmPushProvider(props)) {
130
- stringContents = addFirebaseDelegateForwardDeclarationIfNeeded(stringContents);
131
- }
132
- stringContents = addExpoNotificationsHeaderModification(stringContents);
133
- config.modResults.contents = stringContents;
134
- } else {
141
+ if (stringContents.match(regex)) {
135
142
  logger.info('Customerio AppDelegate changes already exist. Skipping...');
143
+ return config;
136
144
  }
145
+ const headerPath = getAppDelegateHeaderFilePath(config.modRequest.projectRoot);
146
+ const headerContent = await FileManagement.read(headerPath);
147
+ FileManagement.write(headerPath, modifyAppDelegateHeader(headerContent));
148
+ config.modResults.contents = modifyAppDelegateContents(stringContents, config.modRequest.projectName, props);
137
149
  return config;
138
150
  });
139
151
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_DEEPLINK_COMMENT_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_INITIALIZECIOSDK_SNIPPET","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","injectCodeBeforeMultiLineRegex","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","matchRegexExists","replaceCodeByRegex","FileManagement","logger","isFcmPushProvider","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addInitializeNativeCioSdk","addHandleDeeplinkInKilledStateConfiguration","regex","addDidFailToRegisterForRemoteNotificationsWithError","addDidRegisterForRemoteNotificationsWithDeviceToken","addExpoNotificationsHeaderModification","addFirebaseDelegateForwardDeclarationIfNeeded","addAppdelegateHeaderModification","replace","interfaceDeclaration","_groupedDelegates","existingDelegates","includes","trim","addHandleDeeplinkInKilledState","snippet","withAppDelegateModifications","configOuter","props","config","modResults","contents","RegExp","modRequest","projectName","_props$pushNotificati","_props$pushNotificati2","headerPath","projectRoot","headerContent","read","write","pushNotification","disableNotificationRegistration","handleDeeplinkInKilledState","info"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_IMPORT_SNIPPET,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,\n CIO_DEEPLINK_COMMENT_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_INITIALIZECIOSDK_SNIPPET,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeBeforeMultiLineRegex,\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n matchRegexExists,\n replaceCodeByRegex,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { isFcmPushProvider } from './utils';\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n );\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addInitializeNativeCioSdk = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledStateConfiguration = (\n stringContents: string,\n regex: RegExp\n) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n regex,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\n// Adds required import for Expo Notifications package in AppDelegate.\n// Required to call functions from the package.\nconst addExpoNotificationsHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n `\n#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n#import <EXNotifications/EXNotificationCenterDelegate.h>\n#endif\n`\n );\n\n return stringContents;\n};\n\nconst addFirebaseDelegateForwardDeclarationIfNeeded = (\n stringContents: string\n) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n '@protocol FIRMessagingDelegate;'\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n // Add UNUserNotificationCenterDelegate if needed\n stringContents = stringContents.replace(\n CIO_APPDELEGATEHEADER_REGEX,\n (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {\n if (\n existingDelegates &&\n existingDelegates.includes(\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET\n )\n ) {\n // The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it\n return match;\n } else if (existingDelegates) {\n // Other delegates exist, append ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration}<${existingDelegates}, ${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n } else {\n // No delegates exist, add ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n }\n }\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledState = (stringContents: string) => {\n // Find if the deep link code snippet is already present\n if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {\n return stringContents;\n }\n\n // Check if the app delegate is using RCTBridge or LaunchOptions\n let snippet;\n let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n if (\n matchRegexExists(\n stringContents,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;\n regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n } else if (\n matchRegexExists(\n stringContents,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;\n }\n // Add code only if the app delegate is using RCTBridge or LaunchOptions\n if (snippet !== undefined) {\n stringContents = addHandleDeeplinkInKilledStateConfiguration(\n stringContents,\n regex\n );\n stringContents = replaceCodeByRegex(stringContents, regex, snippet);\n }\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n const match = stringContents.match(regex);\n\n if (!match) {\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(\n stringContents,\n config.modRequest.projectName as string\n );\n stringContents = addNotificationHandlerDeclaration(stringContents);\n\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (props.pushNotification?.disableNotificationRegistration !== true) {\n stringContents = addNotificationConfiguration(stringContents);\n }\n\n stringContents = addInitializeNativeCioSdk(stringContents);\n\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n stringContents = addHandleDeeplinkInKilledState(stringContents);\n }\n\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n if (isFcmPushProvider(props)) {\n stringContents =\n addFirebaseDelegateForwardDeclarationIfNeeded(stringContents);\n }\n\n stringContents = addExpoNotificationsHeaderModification(stringContents);\n\n config.modResults.contents = stringContents;\n } else {\n logger.info('Customerio AppDelegate changes already exist. Skipping...');\n }\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":"AACA,SAASA,eAAe,QAAQ,sBAAsB;AACtD,SA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C,EAAE;QAC5B9B,cAAc,GACZkB,6CAA6C,CAAClB,cAAc,CAAC;MACjE;MAEAA,cAAc,GAAGiB,sCAAsC,CAACjB,cAAc,CAAC;MAEvE+B,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGjC,cAAc;IAC7C,CAAC,MAAM;MACLH,MAAM,CAACkD,IAAI,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOhB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AACD,SAAS3B,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAO;AACT;AACA;AACA,WAAWA,OAAO;AAClB,GAAG;AACH","ignoreList":[]}
1
+ {"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_DEEPLINK_COMMENT_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_INITIALIZECIOSDK_SNIPPET","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","injectCodeBeforeMultiLineRegex","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","matchRegexExists","replaceCodeByRegex","FileManagement","logger","isFcmPushProvider","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addInitializeNativeCioSdk","addHandleDeeplinkInKilledStateConfiguration","regex","addDidFailToRegisterForRemoteNotificationsWithError","addDidRegisterForRemoteNotificationsWithDeviceToken","addExpoNotificationsHeaderModification","addFirebaseDelegateForwardDeclarationIfNeeded","modifyAppDelegateHeader","headerContent","replace","interfaceDeclaration","_groupedDelegates","existingDelegates","includes","trim","addHandleDeeplinkInKilledState","snippet","modifyAppDelegateContents","contents","projectName","props","_props$pushNotificati","_props$pushNotificati2","next","pushNotification","disableNotificationRegistration","handleDeeplinkInKilledState","withAppDelegateModifications","configOuter","config","modResults","RegExp","modRequest","info","headerPath","projectRoot","read","write"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_IMPORT_SNIPPET,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,\n CIO_DEEPLINK_COMMENT_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_INITIALIZECIOSDK_SNIPPET,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeBeforeMultiLineRegex,\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n matchRegexExists,\n replaceCodeByRegex,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { isFcmPushProvider } from './utils';\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n );\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addInitializeNativeCioSdk = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledStateConfiguration = (\n stringContents: string,\n regex: RegExp\n) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n regex,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\n// Adds required import for Expo Notifications package in AppDelegate.\n// Required to call functions from the package.\nconst addExpoNotificationsHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n `\n#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n#import <EXNotifications/EXNotificationCenterDelegate.h>\n#endif\n`\n );\n\n return stringContents;\n};\n\nconst addFirebaseDelegateForwardDeclarationIfNeeded = (\n stringContents: string\n) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n '@protocol FIRMessagingDelegate;'\n );\n\n return stringContents;\n};\n\n/**\n * Pure string transform: ensures the AppDelegate header (Objective-C path) declares\n * `UNUserNotificationCenterDelegate` and imports `UserNotifications`. Idempotent.\n */\nexport function modifyAppDelegateHeader(headerContent: string): string {\n return headerContent.replace(\n CIO_APPDELEGATEHEADER_REGEX,\n (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {\n if (\n existingDelegates &&\n existingDelegates.includes(\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET\n )\n ) {\n // The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it\n return match;\n } else if (existingDelegates) {\n // Other delegates exist, append ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration}<${existingDelegates}, ${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n } else {\n // No delegates exist, add ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n }\n }\n );\n}\n\nconst addHandleDeeplinkInKilledState = (stringContents: string) => {\n // Find if the deep link code snippet is already present\n if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {\n return stringContents;\n }\n\n // Check if the app delegate is using RCTBridge or LaunchOptions\n let snippet;\n let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n if (\n matchRegexExists(\n stringContents,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;\n regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n } else if (\n matchRegexExists(\n stringContents,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;\n }\n // Add code only if the app delegate is using RCTBridge or LaunchOptions\n if (snippet !== undefined) {\n stringContents = addHandleDeeplinkInKilledStateConfiguration(\n stringContents,\n regex\n );\n stringContents = replaceCodeByRegex(stringContents, regex, snippet);\n }\n return stringContents;\n};\n\n/**\n * Pure string transform: produces the modified Objective-C AppDelegate.m / AppDelegate.mm\n * contents wired with the Customer.io push pipeline (imports, declarations, notification\n * configuration, registration callbacks, optional killed-state deep-link, FCM forward decl,\n * Expo notifications header). The caller is responsible for the AppDelegate header file\n * (.h) — see `modifyAppDelegateHeader`.\n */\nexport function modifyAppDelegateContents(\n contents: string,\n projectName: string,\n props: CustomerIOPluginOptionsIOS\n): string {\n let next = addImport(contents, projectName);\n next = addNotificationHandlerDeclaration(next);\n\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (props.pushNotification?.disableNotificationRegistration !== true) {\n next = addNotificationConfiguration(next);\n }\n\n next = addInitializeNativeCioSdk(next);\n\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n next = addHandleDeeplinkInKilledState(next);\n }\n\n next = addDidFailToRegisterForRemoteNotificationsWithError(next);\n next = addDidRegisterForRemoteNotificationsWithDeviceToken(next);\n\n if (isFcmPushProvider(props)) {\n next = addFirebaseDelegateForwardDeclarationIfNeeded(next);\n }\n\n next = addExpoNotificationsHeaderModification(next);\n\n return next;\n}\n\nexport const withAppDelegateModifications: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withAppDelegate(configOuter, async (config) => {\n const stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n\n if (stringContents.match(regex)) {\n logger.info('Customerio AppDelegate changes already exist. Skipping...');\n return config;\n }\n\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n const headerContent = await FileManagement.read(headerPath);\n FileManagement.write(headerPath, modifyAppDelegateHeader(headerContent));\n\n config.modResults.contents = modifyAppDelegateContents(\n stringContents,\n config.modRequest.projectName as string,\n props\n );\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":"AACA,SAASA,eAAe,QAAQ,sBAAsB;AACtD,SAASC,4BAA4B,QAAQ,sCAAsC;AAEnF,SACEC,gCAAgC,EAChCC,oCAAoC,EACpCC,2BAA2B,EAC3BC,sDAAsD,EACtDC,2CAA2C,EAC3CC,yCAAyC,EACzCC,0BAA0B,EAC1BC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,kCAAkC,EAClCC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,4BAA4B,EAC5BC,gDAAgD,EAChDC,yCAAyC,EACzCC,8CAA8C,EAC9CC,4CAA4C,EAC5CC,8CAA8C,QACzC,0BAA0B;AACjC,SACEC,8BAA8B,EAC9BC,sBAAsB,EACtBC,0BAA0B,EAC1BC,wCAAwC,EACxCC,gBAAgB,EAChBC,kBAAkB,QACb,gCAAgC;AACvC,SAASC,cAAc,QAAQ,iCAAiC;AAEhE,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,MAAMC,SAAS,GAAGA,CAACC,cAAsB,EAAEC,OAAe,KAAK;EAC7D,MAAMC,WAAW,GAAG,mBAAmB;EACvC,MAAMC,WAAW,GAAGC,gBAAgB,CAACH,OAAO,CAAC;EAE7C,MAAMI,KAAK,GAAGL,cAAc,CAACK,KAAK,CAACH,WAAW,CAAC;EAC/C,IAAII,eAAuB;EAC3B,IAAI,CAACD,KAAK,IAAIA,KAAK,CAACE,KAAK,KAAKC,SAAS,EAAE;IACvC;IACAF,eAAe,GAAG,CAAC;EACrB,CAAC,MAAM;IACL;IACAA,eAAe,GAAGD,KAAK,CAACE,KAAK,GAAGF,KAAK,CAAC,CAAC,CAAC,CAACI,MAAM;EACjD;EAEAT,cAAc,GAAGT,sBAAsB,CACrCS,cAAc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M,CACtB,YAAYF,MAAM,CAACG,UAAU,CAACb,WAAW,WAC3C,CAAC;IAED,IAAI/B,cAAc,CAACK,KAAK,CAACS,KAAK,CAAC,EAAE;MAC/BjB,MAAM,CAACgD,IAAI,CAAC,2DAA2D,CAAC;MACxE,OAAOJ,MAAM;IACf;IAEA,MAAMK,UAAU,GAAG3E,4BAA4B,CAC7CsE,MAAM,CAACG,UAAU,CAACG,WACpB,CAAC;IACD,MAAM3B,aAAa,GAAG,MAAMxB,cAAc,CAACoD,IAAI,CAACF,UAAU,CAAC;IAC3DlD,cAAc,CAACqD,KAAK,CAACH,UAAU,EAAE3B,uBAAuB,CAACC,aAAa,CAAC,CAAC;IAExEqB,MAAM,CAACC,UAAU,CAACZ,QAAQ,GAAGD,yBAAyB,CACpD7B,cAAc,EACdyC,MAAM,CAACG,UAAU,CAACb,WAAW,EAC7BC,KACF,CAAC;IAED,OAAOS,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AACD,SAASrC,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAO;AACT;AACA;AACA,WAAWA,OAAO;AAClB,GAAG;AACH","ignoreList":[]}
@@ -145,12 +145,14 @@ export const withCIOIosSwift = (configOuter, sdkConfig, props, location) => {
145
145
  if (props !== null && props !== void 0 && props.pushNotification) {
146
146
  // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init
147
147
  return withAppDelegate(configOuter, async config => {
148
- return modifyAppDelegateWithPushAppDelegateHandler(config, props);
148
+ config.modResults.contents = modifyAppDelegateForPushHandler(config.modResults.contents, props);
149
+ return config;
149
150
  });
150
151
  } else if (sdkConfig) {
151
152
  // Without push notifications: directly inject auto initialization into AppDelegate
152
153
  return withAppDelegate(configOuter, async config => {
153
- return modifyAppDelegateWithNativeSDKInitializer(config);
154
+ config.modResults.contents = modifyAppDelegateForNativeSDKInitializer(config.modResults.contents);
155
+ return config;
154
156
  });
155
157
  } else {
156
158
  return configOuter;
@@ -158,57 +160,37 @@ export const withCIOIosSwift = (configOuter, sdkConfig, props, location) => {
158
160
  };
159
161
 
160
162
  /**
161
- * Modify the AppDelegate to integrate with Customer.io SDK
163
+ * Pure string transform: produces the Swift AppDelegate contents wired to delegate to
164
+ * `CioSdkAppDelegateHandler` for both push notifications and (when configured) auto-init.
165
+ * Idempotent — returns `contents` unchanged when the handler is already present.
162
166
  */
163
- const modifyAppDelegateWithPushAppDelegateHandler = (config, props) => {
167
+ export function modifyAppDelegateForPushHandler(contents, props) {
164
168
  var _props$pushNotificati6;
165
- const appDelegateContent = config.modResults.contents;
166
-
167
- // Check if modifications have already been applied
168
- if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {
169
+ if (contents.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {
169
170
  logger.info('CustomerIO Swift AppDelegate changes already exist. Skipping...');
170
- return config;
171
+ return contents;
171
172
  }
172
-
173
- // Add the handler property declaration
174
- let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);
175
-
176
- // Modify didFinishLaunchingWithOptions to initialize and call the handler
177
- modifiedContent = modifyDidFinishLaunchingWithOptions(modifiedContent, ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\n\n `);
178
-
179
- // Add didRegisterForRemoteNotificationsWithDeviceToken implementation
180
- modifiedContent = addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);
181
-
182
- // Add didFailToRegisterForRemoteNotificationsWithError implementation
183
- modifiedContent = addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);
184
-
185
- // Add deep link handling for killed state if enabled
173
+ let next = addHandlerPropertyDeclaration(contents);
174
+ next = modifyDidFinishLaunchingWithOptions(next, ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\n\n `);
175
+ next = addDidRegisterForRemoteNotificationsWithDeviceToken(next);
176
+ next = addDidFailToRegisterForRemoteNotificationsWithError(next);
186
177
  if (((_props$pushNotificati6 = props.pushNotification) === null || _props$pushNotificati6 === void 0 ? void 0 : _props$pushNotificati6.handleDeeplinkInKilledState) === true) {
187
- modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);
178
+ next = addHandleDeeplinkInKilledState(next);
188
179
  }
189
- config.modResults.contents = modifiedContent;
190
- return config;
191
- };
180
+ return next;
181
+ }
192
182
 
193
183
  /**
194
- * Modify the AppDelegate to integrate with Customer.io SDK
184
+ * Pure string transform: injects the auto-init snippet into the Swift AppDelegate's
185
+ * didFinishLaunchingWithOptions for the no-push path. Idempotent.
195
186
  */
196
- const modifyAppDelegateWithNativeSDKInitializer = (config
197
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
198
- ) => {
199
- const appDelegateContent = config.modResults.contents;
200
-
201
- // Check if modifications have already been applied
202
- if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {
187
+ export function modifyAppDelegateForNativeSDKInitializer(contents) {
188
+ if (contents.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {
203
189
  logger.info('CustomerIO Swift AppDelegate changes already exist. Skipping...');
204
- return config;
190
+ return contents;
205
191
  }
206
-
207
- // Modify didFinishLaunchingWithOptions to initialize and call the handler
208
- const modifiedContent = modifyDidFinishLaunchingWithOptions(appDelegateContent, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
209
- config.modResults.contents = modifiedContent;
210
- return config;
211
- };
192
+ return modifyDidFinishLaunchingWithOptions(contents, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
193
+ }
212
194
 
213
195
  /**
214
196
  * Check if a method exists in the AppDelegate content
@@ -332,29 +314,35 @@ const addDidFailToRegisterForRemoteNotificationsWithError = content => {
332
314
 
333
315
  /**
334
316
  * Add deep link handling for killed state
335
- * This replaces the return statement with deep link handling code
336
- * and a modified return statement that uses modifiedLaunchOptions
317
+ *
318
+ * On modern Expo Swift templates, RN is bootstrapped by `factory.startReactNative(...)`
319
+ * inside an `#if os(iOS) || os(tvOS)` guard, *before* the trailing `return super.application(...)`.
320
+ * The deep-link block must run before that call so `modifiedLaunchOptions` flows into RN's
321
+ * initial launchOptions; otherwise the workaround is a no-op.
322
+ *
323
+ * For older templates (no `factory.startReactNative` — `super.application(...)` is what
324
+ * starts RN), the snippet is injected before the return statement as before.
337
325
  */
338
326
  const addHandleDeeplinkInKilledState = content => {
339
- // Check if deep link code snippet is already present
340
327
  const deepLinkMarker = 'Deep link workaround for app killed state start';
341
328
  if (content.includes(deepLinkMarker)) {
342
329
  return content;
343
330
  }
344
-
345
- // Find the return statement with launchOptions
346
331
  const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
347
- const returnStatementMatch = content.match(returnStatementRegex);
348
- if (!returnStatementMatch) {
332
+ const modifiedReturnStatement = 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';
333
+ 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)/;
334
+ if (factoryStartRegex.test(content)) {
335
+ let result = content.replace(factoryStartRegex, `\n${CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET}\n#if os(iOS) || os(tvOS)$2modifiedLaunchOptions$3`);
336
+ if (returnStatementRegex.test(result)) {
337
+ result = result.replace(returnStatementRegex, modifiedReturnStatement);
338
+ }
339
+ return result;
340
+ }
341
+ if (!returnStatementRegex.test(content)) {
349
342
  logger.warn('Could not find return statement with launchOptions');
350
343
  return content;
351
344
  }
352
-
353
- // Create the replacement code with deep link handling and modified return statement
354
- const modifiedReturnStatement = 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';
355
345
  const replacementCode = CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET + '\n\n ' + modifiedReturnStatement;
356
-
357
- // Replace the return statement with deep link handling code and modified return statement
358
346
  return content.replace(returnStatementRegex, replacementCode);
359
347
  };
360
348
  //# 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","_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","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 * 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,UAAU,CAACD,WAAW,IAAI,EAAE;EACvD,IAAI,CAACA,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,MAAMuC,uBAAuB,GAC3B,6FAA6F;EAC/F,MAAMC,eAAe,GACnB3G,+CAA+C,GAC/C,UAAU,GACV0G,uBAAuB;;EAEzB;EACA,OAAOvC,OAAO,CAACZ,OAAO,CAACwC,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","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","contents","modifyAppDelegateForPushHandler","modifyAppDelegateForNativeSDKInitializer","_props$pushNotificati6","includes","info","next","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 config.modResults.contents = modifyAppDelegateForPushHandler(\n config.modResults.contents,\n props\n );\n return config;\n });\n } else if (sdkConfig) {\n // Without push notifications: directly inject auto initialization into AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n config.modResults.contents = modifyAppDelegateForNativeSDKInitializer(\n config.modResults.contents\n );\n return config;\n });\n } else {\n return configOuter;\n }\n};\n\n/**\n * Pure string transform: produces the Swift AppDelegate contents wired to delegate to\n * `CioSdkAppDelegateHandler` for both push notifications and (when configured) auto-init.\n * Idempotent — returns `contents` unchanged when the handler is already present.\n */\nexport function modifyAppDelegateForPushHandler(\n contents: string,\n props: CustomerIOPluginOptionsIOS\n): string {\n if (contents.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return contents;\n }\n\n let next = addHandlerPropertyDeclaration(contents);\n next = modifyDidFinishLaunchingWithOptions(\n next,\n ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `\n );\n next = addDidRegisterForRemoteNotificationsWithDeviceToken(next);\n next = addDidFailToRegisterForRemoteNotificationsWithError(next);\n\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n next = addHandleDeeplinkInKilledState(next);\n }\n\n return next;\n}\n\n/**\n * Pure string transform: injects the auto-init snippet into the Swift AppDelegate's\n * didFinishLaunchingWithOptions for the no-push path. Idempotent.\n */\nexport function modifyAppDelegateForNativeSDKInitializer(contents: string): string {\n if (contents.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return contents;\n }\n\n return modifyDidFinishLaunchingWithOptions(\n contents,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n );\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,SAASC,eAAe,EAAEC,0BAA0B,QAAQ,gBAAgB;AAC5E,SAASC,iBAAiB,QAAQ,SAAS;;AAE3C;AACA,MAAMC,kCAAkC,GAAG,0BAA0B;AACrE,MAAMC,qCAAqC,GAAG,GAAGD,k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