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":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","replaceCodeByRegex","injectCIONotificationPodfileCode","logger","getIosNativeFilesPath","validateRichPushConfig","FileManagement","isExpoVersion53OrHigher","isFcmPushProvider","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","isExpo53OrHigher","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","String","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","_options$pushNotifica2","_options$pushNotifica3","_options$pushNotifica4","isFcmProvider","pbxTargetByName","warn","nsePath","mkdir","recursive","platformSpecificFiles","nseEntitlementsFilename","appGroupId","nseEntitlementsContent","writeFile","commonFiles","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","env","updateNseNotificationService","allGroupFiles","extGroup","addPbxGroup","groups","hash","project","objects","PBXGroup","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","PBXTargetDependency","PBXContainerItemProxy","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","CODE_SIGN_ENTITLEMENTS","addTargetAttribute","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","notificationServiceFile","APP_GROUP_ID_BUILDER_LINE_RE","content","builderLine","JSON","stringify","envFileName","richPushConfig","CDP_API_KEY_RE","REGION_RE","envFileContent","cdpApiKey","region","regionKey","toLowerCase","regionMap","us","eu","mappedRegion","sourceFile","targetFileName","appPath","exists","info","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","_options$pushNotifica8","_options$pushNotifica9","_options$pushNotifica0","REGISTER_RE","disableNotificationRegistration","snippet","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","appGroupIdBuilderLine"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS, RichPushConfig } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { validateRichPushConfig } from '../utils/validation';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n isExpo53OrHigher: boolean,\n) => {\n try {\n // PushService file is only needed for pre-Expo 53 code generation\n if (options.pushNotification && !isExpo53OrHigher) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush === true) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: unknown) {\n logger.error(String(error));\n return null;\n }\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget, useFrameworks } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n } satisfies CustomerIOPluginOptionsIOS;\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults,\n isExpoVersion53OrHigher(configOuter),\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const platformSpecificFiles = ['NotificationService.swift'];\n\n const nseEntitlementsFilename = 'NotificationService.entitlements';\n const appGroupId = options.pushNotification?.appGroupId;\n\n // Write NSE entitlements file only when appGroupId is explicitly configured\n if (appGroupId) {\n const nseEntitlementsContent = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n <key>com.apple.security.application-groups</key>\n <array>\n <string>${appGroupId}</string>\n </array>\n</dict>\n</plist>\n`;\n FileManagement.writeFile(`${nsePath}/${nseEntitlementsFilename}`, nseEntitlementsContent);\n }\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${isFcmProvider ? 'fcm' : 'apn'\n }/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/common/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(getTargetFile(ENV_FILENAME), options.pushNotification?.env);\n updateNseNotificationService(getTargetFile('NotificationService.swift'), options.pushNotification?.appGroupId);\n\n // The entitlements file is generated (not copied from source), so it's listed separately\n // for the Xcode group so it appears in the file navigator\n const allGroupFiles = [\n ...platformSpecificFiles,\n ...commonFiles,\n ...(appGroupId ? [nseEntitlementsFilename] : []),\n ];\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n allGroupFiles,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects.PBXGroup;\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};\n projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n if (appGroupId) {\n buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${CIO_NOTIFICATION_TARGET_NAME}/${nseEntitlementsFilename}`;\n }\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseNotificationService = (\n notificationServiceFile: string,\n appGroupId?: string,\n) => {\n const APP_GROUP_ID_BUILDER_LINE_RE = /\\{\\{APP_GROUP_ID_BUILDER_LINE\\}\\}/;\n\n let content = FileManagement.readFile(notificationServiceFile);\n const builderLine = appGroupId\n ? ` .appGroupId(${JSON.stringify(appGroupId)})\\n`\n : '';\n content = replaceCodeByRegex(content, APP_GROUP_ID_BUILDER_LINE_RE, builderLine);\n FileManagement.writeFile(notificationServiceFile, content);\n};\n\nconst updateNseEnv = (\n envFileName: string,\n richPushConfig?: RichPushConfig\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n // Use merged config values (config takes precedence over env)\n const cdpApiKey = richPushConfig?.cdpApiKey;\n const region = richPushConfig?.region;\n\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n cdpApiKey || 'MISSING_API_KEY',\n );\n\n // Simplify region mapping with case insensitive keys and fallback for invalid regions\n const regionKey = region?.toLowerCase() ?? '';\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n } as const;\n const mappedRegion = regionMap[regionKey as keyof typeof regionMap];\n if (!mappedRegion) {\n logger.warn(\n `${regionKey} is an invalid region. Please use the values from the docs: https://docs.customer.io/integrations/sdk/expo/getting-started/packages-options/#configuring-the-expo-plugin`\n );\n // Fallback to US if invalid region provided\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, regionMap.us);\n } else {\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) {\n // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${sourceFile}`,\n targetFile\n );\n } else {\n logger.info(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n const richPushConfig = options.pushNotification?.env;\n const { cdpApiKey, region } = richPushConfig || {\n cdpApiKey: 'MISSING_API_KEY',\n region: undefined,\n };\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n\n let snippet = '';\n // unless this property is explicitly set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey,\n );\n\n if (region) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n const appGroupId = options.pushNotification?.appGroupId;\n const appGroupIdBuilderLine = appGroupId\n ? ` .appGroupId(${JSON.stringify(appGroupId)})\\n`\n : '';\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{APP_GROUP_ID_BUILDER_LINE\\}\\}/,\n appGroupIdBuilderLine\n );\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,sBAAsB;AAEvD,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,QACjB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,sBAAsB,QAAQ,qBAAqB;AAC5D,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,SAAS;AAEpE,MAAMC,cAAc,GAAG,GAAGX,4BAA4B,aAAa;AACnE,MAAMY,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAG,OAAO;AAEtC,MAAMC,+BAA+B,GAAG,MAAAA,CACtCC,OAAmC,EACnCC,YAA0B,EAC1BC,gBAAyB,KACtB;EACH,IAAI;IAAA,IAAAC,qBAAA;IACF;IACA,IAAIH,OAAO,CAACI,gBAAgB,IAAI,CAACF,gBAAgB,EAAE;MACjD,MAAMG,uBAAuB,CAACL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O,CAACI,gBAAgB,cAAA4H,sBAAA,uBAAxBA,sBAAA,CAA0BS,uBAAuB,MAAK,KAAK;EAC7DjC,cAAc,GAAGpH,kBAAkB,CACjCoH,cAAc,EACd,qCAAqC,EACrCiC,uBAAuB,CAACF,QAAQ,CAAC,CACnC,CAAC;EAED,MAAM5F,UAAU,IAAAsF,sBAAA,GAAGjI,OAAO,CAACI,gBAAgB,cAAA6H,sBAAA,uBAAxBA,sBAAA,CAA0BtF,UAAU;EACvD,MAAM+F,qBAAqB,GAAG/F,UAAU,GACpC,uBAAuBuD,IAAI,CAACC,SAAS,CAACxD,UAAU,CAAC,KAAK,GACtD,EAAE;EACN6D,cAAc,GAAGpH,kBAAkB,CACjCoH,cAAc,EACd,mCAAmC,EACnCkC,qBACF,CAAC;EAEDjJ,cAAc,CAACoD,SAAS,CAACuD,WAAW,EAAEI,cAAc,CAAC;AACvD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","replaceCodeByRegex","injectCIONotificationPodfileCode","logger","getIosNativeFilesPath","validateRichPushConfig","FileManagement","isExpoVersion53OrHigher","isFcmPushProvider","PLIST_FILENAME","ENV_FILENAME","NSE_PLATFORM_SPECIFIC_FILES","NSE_COMMON_FILES","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","isExpo53OrHigher","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","String","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","NSE_ENTITLEMENTS_FILENAME","addNotificationServiceExtensionToXcodeProject","pbxTargetByName","warn","appGroupId","allGroupFiles","extGroup","addPbxGroup","groups","hash","project","objects","PBXGroup","Object","keys","forEach","key","name","path","addToPbxGroup","uuid","projObjects","PBXTargetDependency","PBXContainerItemProxy","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","CODE_SIGN_ENTITLEMENTS","addTargetAttribute","_options$pushNotifica2","_options$pushNotifica3","isFcmProvider","nsePath","mkdir","recursive","nseEntitlementsContent","writeFile","getTargetFile","filename","copyFile","updateNseInfoPlist","infoPlistTargetFile","updateNseEnv","env","updateNseNotificationService","applyBundleVersionToNsePlist","content","payload","next","readFile","applyAppGroupIdToNotificationService","builderLine","JSON","stringify","notificationServiceFile","applyRichPushConfigToEnv","richPushConfig","cdpApiKey","region","regionKey","toLowerCase","regionMap","us","eu","mappedRegion","envFileName","sourceFile","targetFileName","appPath","targetFile","exists","info","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","applyConfigToPushFile","_options$pushNotifica4","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","_options$pushNotifica8","_options$pushNotifica9","disableNotificationRegistration","registerSnippet","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","appGroupIdBuilderLine","_options$pushNotifica0"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS, RichPushConfig } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { validateRichPushConfig } from '../utils/validation';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\n// NSE source files registered in the Xcode group AND copied to the target\n// directory. Single source of truth — both `addNotificationServiceExtensionToXcodeProject`\n// (registers them in the PBXGroup) and `addRichPushXcodeProj` (copies them\n// from the plugin's native-files dir) read the same arrays. Keeping these\n// in sync is load-bearing: the Xcode group must reference the same files\n// that exist on disk, or the build fails with \"no such file\" / unresolved\n// references.\nconst NSE_PLATFORM_SPECIFIC_FILES = ['NotificationService.swift'];\nconst NSE_COMMON_FILES = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n];\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n isExpo53OrHigher: boolean,\n) => {\n try {\n // PushService file is only needed for pre-Expo 53 code generation\n if (options.pushNotification && !isExpo53OrHigher) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush === true) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: unknown) {\n logger.error(String(error));\n return null;\n }\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget, useFrameworks } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n } satisfies CustomerIOPluginOptionsIOS;\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults,\n isExpoVersion53OrHigher(configOuter),\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst NSE_ENTITLEMENTS_FILENAME = 'NotificationService.entitlements';\n\nexport type AddNseTargetToXcodeProjectOptions = {\n appleTeamId?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appGroupId?: string;\n};\n\n/**\n * Mutates the parsed XcodeProject to register the rich-push NotificationService\n * extension target: creates a PBXGroup for its files, registers the group under\n * the project's top-level group, adds the app_extension target, wires three\n * build phases (Sources, Resources, Frameworks), configures the target's build\n * settings (DEVELOPMENT_TEAM, IPHONEOS_DEPLOYMENT_TARGET, code-sign style,\n * Swift version, and CODE_SIGN_ENTITLEMENTS when `appGroupId` is set), and\n * stamps the development team attribute on both the new target and the\n * project's main target attributes.\n *\n * Idempotent — returns the project unchanged if a target named\n * `CIO_NOTIFICATION_TARGET_NAME` is already present.\n */\nexport function addNotificationServiceExtensionToXcodeProject(\n xcodeProject: XcodeProject,\n options: AddNseTargetToXcodeProjectOptions,\n): XcodeProject {\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`,\n );\n return xcodeProject;\n }\n\n const { appleTeamId, bundleIdentifier, iosDeploymentTarget, appGroupId } = options;\n\n // The entitlements file is generated (not copied from source), so it's listed separately\n // for the Xcode group so it appears in the file navigator.\n const allGroupFiles = [\n ...NSE_PLATFORM_SPECIFIC_FILES,\n ...NSE_COMMON_FILES,\n ...(appGroupId ? [NSE_ENTITLEMENTS_FILENAME] : []),\n ];\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n allGroupFiles,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME,\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects.PBXGroup;\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};\n projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};\n\n // Add the NSE target. This also adds PBXTargetDependency and PBXContainerItemProxy.\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`,\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid,\n );\n xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);\n xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n if (appGroupId) {\n buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${CIO_NOTIFICATION_TARGET_NAME}/${NSE_ENTITLEMENTS_FILENAME}`;\n }\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n\n return xcodeProject;\n}\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n const isFcmProvider = isFcmPushProvider(options);\n const appGroupId = options.pushNotification?.appGroupId;\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Skip the rest of the work if the NSE target is already in place. The pbxproj-mutating\n // helper has its own idempotency check, but bailing out here also avoids redundant file\n // copies and entitlements writes when prebuild re-runs against an already-prepared project.\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`,\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, { recursive: true });\n\n // Write NSE entitlements file only when appGroupId is explicitly configured\n if (appGroupId) {\n const nseEntitlementsContent = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n <key>com.apple.security.application-groups</key>\n <array>\n <string>${appGroupId}</string>\n </array>\n</dict>\n</plist>\n`;\n FileManagement.writeFile(`${nsePath}/${NSE_ENTITLEMENTS_FILENAME}`, nseEntitlementsContent);\n }\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n\n // Copy platform-specific files\n NSE_PLATFORM_SPECIFIC_FILES.forEach((filename) => {\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${isFcmProvider ? 'fcm' : 'apn'}/${filename}`,\n getTargetFile(filename),\n );\n });\n\n // Copy common files\n NSE_COMMON_FILES.forEach((filename) => {\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/common/${filename}`,\n getTargetFile(filename),\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile: getTargetFile(PLIST_FILENAME),\n });\n updateNseEnv(getTargetFile(ENV_FILENAME), options.pushNotification?.env);\n updateNseNotificationService(getTargetFile('NotificationService.swift'), appGroupId);\n\n // Register the NSE target in the parsed Xcode project\n addNotificationServiceExtensionToXcodeProject(xcodeProject, {\n appleTeamId,\n bundleIdentifier,\n iosDeploymentTarget,\n appGroupId,\n });\n};\n\n/**\n * Pure string transform: substitutes the `{{BUNDLE_VERSION}}` and\n * `{{BUNDLE_SHORT_VERSION}}` placeholders in the NSE Info.plist template.\n * Either or both may be provided; missing values leave the corresponding\n * placeholder untouched.\n */\nexport function applyBundleVersionToNsePlist(\n content: string,\n payload: { bundleVersion?: string; bundleShortVersion?: string }\n): string {\n let next = content;\n if (payload.bundleVersion) {\n next = replaceCodeByRegex(next, /\\{\\{BUNDLE_VERSION\\}\\}/, payload.bundleVersion);\n }\n if (payload.bundleShortVersion) {\n next = replaceCodeByRegex(next, /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/, payload.bundleShortVersion);\n }\n return next;\n}\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const next = applyBundleVersionToNsePlist(\n FileManagement.readFile(payload.infoPlistTargetFile),\n payload,\n );\n FileManagement.writeFile(payload.infoPlistTargetFile, next);\n};\n\n/**\n * Pure string transform: substitutes the `{{APP_GROUP_ID_BUILDER_LINE}}`\n * placeholder in NotificationService.swift with either the configured\n * appGroupId builder line or an empty string.\n */\nexport function applyAppGroupIdToNotificationService(\n content: string,\n appGroupId?: string\n): string {\n const builderLine = appGroupId\n ? ` .appGroupId(${JSON.stringify(appGroupId)})\\n`\n : '';\n return replaceCodeByRegex(content, /\\{\\{APP_GROUP_ID_BUILDER_LINE\\}\\}/, builderLine);\n}\n\nconst updateNseNotificationService = (\n notificationServiceFile: string,\n appGroupId?: string,\n) => {\n const next = applyAppGroupIdToNotificationService(\n FileManagement.readFile(notificationServiceFile),\n appGroupId,\n );\n FileManagement.writeFile(notificationServiceFile, next);\n};\n\n/**\n * Pure string transform: substitutes the `{{CDP_API_KEY}}` and `{{REGION}}`\n * placeholders in the NSE Env.swift template. Missing or invalid region\n * falls back to `Region.US` and logs a warning.\n */\nexport function applyRichPushConfigToEnv(\n content: string,\n richPushConfig?: RichPushConfig,\n): string {\n const cdpApiKey = richPushConfig?.cdpApiKey;\n const region = richPushConfig?.region;\n\n let next = replaceCodeByRegex(\n content,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey || 'MISSING_API_KEY',\n );\n\n const regionKey = region?.toLowerCase() ?? '';\n const regionMap = { us: 'Region.US', eu: 'Region.EU' } as const;\n const mappedRegion = regionMap[regionKey as keyof typeof regionMap];\n if (!mappedRegion) {\n logger.warn(\n `${regionKey} is an invalid region. Please use the values from the docs: https://docs.customer.io/integrations/sdk/expo/getting-started/packages-options/#configuring-the-expo-plugin`\n );\n next = replaceCodeByRegex(next, /\\{\\{REGION\\}\\}/, regionMap.us);\n } else {\n next = replaceCodeByRegex(next, /\\{\\{REGION\\}\\}/, mappedRegion);\n }\n return next;\n}\n\nconst updateNseEnv = (\n envFileName: string,\n richPushConfig?: RichPushConfig\n) => {\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n const next = applyRichPushConfigToEnv(\n FileManagement.readFile(envFileName),\n richPushConfig,\n );\n FileManagement.writeFile(envFileName, next);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) {\n // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${sourceFile}`,\n targetFile\n );\n } else {\n logger.info(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\n/**\n * Pure string transform: substitutes every PushService.swift placeholder\n * (`{{REGISTER_SNIPPET}}`, `{{CDP_API_KEY}}`, `{{REGION}}`,\n * `{{AUTO_TRACK_PUSH_EVENTS}}`, `{{AUTO_FETCH_DEVICE_TOKEN}}`,\n * `{{SHOW_PUSH_APP_IN_FOREGROUND}}`, `{{APP_GROUP_ID_BUILDER_LINE}}`) using\n * the configured push-notification options. Validation of the rich-push\n * config (cdpApiKey/region required) is the wrapper's responsibility.\n */\nexport function applyConfigToPushFile(\n content: string,\n options: CustomerIOPluginOptionsIOS,\n): string {\n const richPushConfig = options.pushNotification?.env;\n const { cdpApiKey, region } = richPushConfig || {\n cdpApiKey: 'MISSING_API_KEY',\n region: undefined,\n };\n const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n\n // unless this property is explicitly set to true, push notification\n // registration will be added to the AppDelegate\n const registerSnippet = disableNotificationRegistration !== true\n ? CIO_REGISTER_PUSHNOTIFICATION_SNIPPET\n : '';\n\n let next = replaceCodeByRegex(content, /\\{\\{REGISTER_SNIPPET\\}\\}/, registerSnippet);\n next = replaceCodeByRegex(next, /\\{\\{CDP_API_KEY\\}\\}/, cdpApiKey);\n\n if (region) {\n next = replaceCodeByRegex(next, /\\{\\{REGION\\}\\}/, region.toUpperCase());\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n next = replaceCodeByRegex(\n next,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString(),\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n next = replaceCodeByRegex(\n next,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString(),\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n next = replaceCodeByRegex(\n next,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString(),\n );\n\n const appGroupId = options.pushNotification?.appGroupId;\n const appGroupIdBuilderLine = appGroupId\n ? ` .appGroupId(${JSON.stringify(appGroupId)})\\n`\n : '';\n next = replaceCodeByRegex(\n next,\n /\\{\\{APP_GROUP_ID_BUILDER_LINE\\}\\}/,\n appGroupIdBuilderLine,\n );\n\n return next;\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const richPushConfig = options.pushNotification?.env;\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n const next = applyConfigToPushFile(FileManagement.readFile(envFileName), options);\n FileManagement.writeFile(envFileName, next);\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,sBAAsB;AAEvD,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,QACjB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,sBAAsB,QAAQ,qBAAqB;AAC5D,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,SAAS;AAEpE,MAAMC,cAAc,GAAG,GAAGX,4BAA4B,aAAa;AACnE,MAAMY,YAAY,GAAG,WAAW;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,2BAA2B,GAAG,CAAC,2BAA2B,CAAC;AACjE,MAAMC,gBAAgB,GAAG,CACvBH,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACvBC,YAAY,CACb;AAED,MAAMG,sBAAsB,GAAG,OAAO;AAEtC,MAAMC,+BAA+B,GAAG,MAAAA,CACtCC,OAAmC,EACnCC,YAA0B,EAC1BC,gBAAyB,KACtB;EACH,IAAI;IAAA,IAAAC,qBAAA;IACF;IACA,IAAIH,OAAO,CAACI,gBAAgB,IAAI,CAACF,gBAAgB,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s = require('fs');
2
+ const path = require('path');
3
+ const RN_SDK_PACKAGE = 'customerio-reactnative';
4
+
5
+ // Locate customerio-reactnative/package.json from a postinstall context.
6
+ //
7
+ // `INIT_CWD` is set by npm, pnpm, and yarn during lifecycle scripts to point
8
+ // at the consumer's project root. That makes it the most reliable starting
9
+ // point — the plugin's own __dirname can be deep inside `.pnpm/...` under pnpm.
10
+ //
11
+ // We probe `${INIT_CWD}/node_modules/customerio-reactnative/package.json` first
12
+ // so we agree with the symlinked layout React Native autolinking expects, then
13
+ // fall back to resolve-from from the consumer root, then to the legacy
14
+ // __dirname-relative walk-up for environments where INIT_CWD is missing.
15
+ function findRNSDKPackageJson() {
16
+ const candidates = [];
17
+ if (process.env.INIT_CWD) {
18
+ candidates.push(path.join(process.env.INIT_CWD, 'node_modules', RN_SDK_PACKAGE, 'package.json'));
19
+ }
20
+
21
+ // Legacy flat-npm layout fallback: plugin lives at
22
+ // <consumer>/node_modules/customerio-expo-plugin/plugin/src and the SDK at
23
+ // <consumer>/node_modules/customerio-reactnative.
24
+ candidates.push(path.join(__dirname, '..', '..', '..', RN_SDK_PACKAGE, 'package.json'));
25
+ for (const candidate of candidates) {
26
+ if (fs.existsSync(candidate)) {
27
+ return candidate;
28
+ }
29
+ }
30
+
31
+ // Final fallback: resolve-from from INIT_CWD. This walks up node_modules
32
+ // and handles yarn classic workspaces where the dep is hoisted.
33
+ if (process.env.INIT_CWD) {
34
+ try {
35
+ const resolveFrom = require('resolve-from');
36
+ const resolved = resolveFrom.silent(process.env.INIT_CWD, `${RN_SDK_PACKAGE}/package.json`);
37
+ if (resolved) return resolved;
38
+ } catch (_) {
39
+ // resolve-from missing or unable to resolve — fall through to null.
40
+ }
41
+ }
42
+ return null;
43
+ }
2
44
  function runPostInstall() {
3
- // react native SDK package.json path
4
- const reactNativePackageJsonFile = `${__dirname}/../../../customerio-reactnative/package.json`;
5
- const expoPackageJsonFile = `${__dirname}/../../package.json`;
45
+ const expoPackageJsonFile = path.join(__dirname, '..', '..', 'package.json');
6
46
  try {
7
- // if react native SDK is installed
8
- if (fs.existsSync(reactNativePackageJsonFile)) {
9
- const reactNativePackageJson = fs.readFileSync(reactNativePackageJsonFile, 'utf8');
10
- const expoPackageJson = require(expoPackageJsonFile);
11
- const reactNativePackage = JSON.parse(reactNativePackageJson);
12
- reactNativePackage.expoVersion = expoPackageJson.version;
13
- fs.writeFileSync(reactNativePackageJsonFile, JSON.stringify(reactNativePackage, null, 2));
47
+ const reactNativePackageJsonFile = findRNSDKPackageJson();
48
+ if (!reactNativePackageJsonFile) {
49
+ // Not necessarily an error: the plugin may be installed without the RN
50
+ // SDK (e.g., during a tooling-only install). The prebuild-time write
51
+ // covers the common case anyway.
52
+ return;
53
+ }
54
+ const expoPackageJson = require(expoPackageJsonFile);
55
+ const reactNativePackage = JSON.parse(fs.readFileSync(reactNativePackageJsonFile, 'utf8'));
56
+ if (reactNativePackage.expoVersion === expoPackageJson.version) {
57
+ return;
14
58
  }
59
+ reactNativePackage.expoVersion = expoPackageJson.version;
60
+ fs.writeFileSync(reactNativePackageJsonFile, JSON.stringify(reactNativePackage, null, 2));
15
61
  } catch (error) {
16
- console.warn('Unable to find customerio-reactnative package.json file. Please make sure you have installed the customerio-reactnative package.', error);
62
+ console.warn('customerio-expo-plugin postinstall: failed to write expoVersion into customerio-reactnative/package.json. ' + 'The expo prebuild step will retry this. Original error:', error);
17
63
  }
18
64
  }
19
65
  exports.runPostInstall = runPostInstall;
66
+ exports.findRNSDKPackageJson = findRNSDKPackageJson;
20
67
  //# sourceMappingURL=postInstallHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["fs","require","runPostInstall","reactNativePackageJsonFile","__dirname","expoPackageJsonFile","existsSync","reactNativePackageJson","readFileSync","expoPackageJson","reactNativePackage","JSON","parse","expoVersion","version","writeFileSync","stringify","error","console","warn","exports"],"sources":["postInstallHelper.js"],"sourcesContent":["const fs = require('fs');\n\nfunction runPostInstall() {\n // react native SDK package.json path\n const reactNativePackageJsonFile = `${__dirname}/../../../customerio-reactnative/package.json`;\n const expoPackageJsonFile = `${__dirname}/../../package.json`;\n try {\n // if react native SDK is installed\n if (fs.existsSync(reactNativePackageJsonFile)) {\n const reactNativePackageJson = fs.readFileSync(\n reactNativePackageJsonFile,\n 'utf8'\n );\n const expoPackageJson = require(expoPackageJsonFile);\n\n const reactNativePackage = JSON.parse(reactNativePackageJson);\n reactNativePackage.expoVersion = expoPackageJson.version;\n\n fs.writeFileSync(\n reactNativePackageJsonFile,\n JSON.stringify(reactNativePackage, null, 2)\n );\n }\n } catch (error) {\n console.warn(\n 'Unable to find customerio-reactnative package.json file. Please make sure you have installed the customerio-reactnative package.',\n error\n );\n }\n}\n\nexports.runPostInstall = runPostInstall;\n"],"mappings":"AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AAExB,SAASC,cAAcA,CAAA,EAAG;EACxB;EACA,MAAMC,0BAA0B,GAAG,GAAGC,SAAS,+CAA+C;EAC9F,MAAMC,mBAAmB,GAAG,GAAGD,SAAS,qBAAqB;EAC7D,IAAI;IACF;IACA,IAAIJ,EAAE,CAACM,UAAU,CAACH,0BAA0B,CAAC,EAAE;MAC7C,MAAMI,sBAAsB,GAAGP,EAAE,CAACQ,YAAY,CAC5CL,0BAA0B,EAC1B,MACF,CAAC;MACD,MAAMM,eAAe,GAAGR,OAAO,CAACI,mBAAmB,CAAC;MAEpD,MAAMK,kBAAkB,GAAGC,IAAI,CAACC,KAAK,CAACL,sBAAsB,CAAC;MAC7DG,kBAAkB,CAACG,WAAW,GAAGJ,eAAe,CAACK,OAAO;MAExDd,EAAE,CAACe,aAAa,CACdZ,0BAA0B,EAC1BQ,IAAI,CAACK,SAAS,CAACN,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAC5C,CAAC;IACH;EACF,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CACV,kIAAkI,EAClIF,KACF,CAAC;EACH;AACF;AAEAG,OAAO,CAAClB,cAAc,GAAGA,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["fs","require","path","RN_SDK_PACKAGE","findRNSDKPackageJson","candidates","process","env","INIT_CWD","push","join","__dirname","candidate","existsSync","resolveFrom","resolved","silent","_","runPostInstall","expoPackageJsonFile","reactNativePackageJsonFile","expoPackageJson","reactNativePackage","JSON","parse","readFileSync","expoVersion","version","writeFileSync","stringify","error","console","warn","exports"],"sources":["postInstallHelper.js"],"sourcesContent":["const fs = require('fs');\nconst path = require('path');\n\nconst RN_SDK_PACKAGE = 'customerio-reactnative';\n\n// Locate customerio-reactnative/package.json from a postinstall context.\n//\n// `INIT_CWD` is set by npm, pnpm, and yarn during lifecycle scripts to point\n// at the consumer's project root. That makes it the most reliable starting\n// point — the plugin's own __dirname can be deep inside `.pnpm/...` under pnpm.\n//\n// We probe `${INIT_CWD}/node_modules/customerio-reactnative/package.json` first\n// so we agree with the symlinked layout React Native autolinking expects, then\n// fall back to resolve-from from the consumer root, then to the legacy\n// __dirname-relative walk-up for environments where INIT_CWD is missing.\nfunction findRNSDKPackageJson() {\n const candidates = [];\n\n if (process.env.INIT_CWD) {\n candidates.push(\n path.join(process.env.INIT_CWD, 'node_modules', RN_SDK_PACKAGE, 'package.json')\n );\n }\n\n // Legacy flat-npm layout fallback: plugin lives at\n // <consumer>/node_modules/customerio-expo-plugin/plugin/src and the SDK at\n // <consumer>/node_modules/customerio-reactnative.\n candidates.push(path.join(__dirname, '..', '..', '..', RN_SDK_PACKAGE, 'package.json'));\n\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n }\n\n // Final fallback: resolve-from from INIT_CWD. This walks up node_modules\n // and handles yarn classic workspaces where the dep is hoisted.\n if (process.env.INIT_CWD) {\n try {\n const resolveFrom = require('resolve-from');\n const resolved = resolveFrom.silent(\n process.env.INIT_CWD,\n `${RN_SDK_PACKAGE}/package.json`\n );\n if (resolved) return resolved;\n } catch (_) {\n // resolve-from missing or unable to resolve — fall through to null.\n }\n }\n\n return null;\n}\n\nfunction runPostInstall() {\n const expoPackageJsonFile = path.join(__dirname, '..', '..', 'package.json');\n\n try {\n const reactNativePackageJsonFile = findRNSDKPackageJson();\n if (!reactNativePackageJsonFile) {\n // Not necessarily an error: the plugin may be installed without the RN\n // SDK (e.g., during a tooling-only install). The prebuild-time write\n // covers the common case anyway.\n return;\n }\n\n const expoPackageJson = require(expoPackageJsonFile);\n const reactNativePackage = JSON.parse(\n fs.readFileSync(reactNativePackageJsonFile, 'utf8')\n );\n\n if (reactNativePackage.expoVersion === expoPackageJson.version) {\n return;\n }\n\n reactNativePackage.expoVersion = expoPackageJson.version;\n fs.writeFileSync(\n reactNativePackageJsonFile,\n JSON.stringify(reactNativePackage, null, 2)\n );\n } catch (error) {\n console.warn(\n 'customerio-expo-plugin postinstall: failed to write expoVersion into customerio-reactnative/package.json. ' +\n 'The expo prebuild step will retry this. Original error:',\n error\n );\n }\n}\n\nexports.runPostInstall = runPostInstall;\nexports.findRNSDKPackageJson = findRNSDKPackageJson;\n"],"mappings":"AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AACxB,MAAMC,IAAI,GAAGD,OAAO,CAAC,MAAM,CAAC;AAE5B,MAAME,cAAc,GAAG,wBAAwB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,oBAAoBA,CAAA,EAAG;EAC9B,MAAMC,UAAU,GAAG,EAAE;EAErB,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,EAAE;IACxBH,UAAU,CAACI,IAAI,CACbP,IAAI,CAACQ,IAAI,CAACJ,OAAO,CAACC,GAAG,CAACC,QAAQ,EAAE,cAAc,EAAEL,cAAc,EAAE,cAAc,CAChF,CAAC;EACH;;EAEA;EACA;EACA;EACAE,UAAU,CAACI,IAAI,CAACP,IAAI,CAACQ,IAAI,CAACC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAER,cAAc,EAAE,cA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CAACC,IAAI,CACV,4GAA4G,GAC1G,yDAAyD,EAC3DF,KACF,CAAC;EACH;AACF;AAEAG,OAAO,CAACf,cAAc,GAAGA,cAAc;AACvCe,OAAO,CAAC7B,oBAAoB,GAAGA,oBAAoB","ignoreList":[]}
@@ -0,0 +1,88 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ const RN_SDK_PACKAGE = 'customerio-reactnative';
4
+ const REACT_NATIVE_PACKAGE = 'react-native';
5
+ // Reads the installed react-native package's version starting from `fromDir`.
6
+ // Used to decide which autolinking flavor will resolve customerio-reactnative
7
+ // at pod install time, so our :path agrees with what autolinking emits:
8
+ // - RN <0.80 ships @react-native-community/cli, which uses a lexical
9
+ // resolution (no realpath following).
10
+ // - RN >=0.80 routes pod autolinking through expo-modules-autolinking,
11
+ // which realpaths.
12
+ // Returns null if react-native cannot be located or its package.json cannot
13
+ // be read; callers should default to the modern (realpath) behavior in that
14
+ // case since it has been the working path for the last several Expo SDKs.
15
+ export function tryReadRNVersion(fromDir) {
16
+ try {
17
+ const direct = path.join(fromDir, 'node_modules', REACT_NATIVE_PACKAGE, 'package.json');
18
+ if (fs.existsSync(direct)) {
19
+ return readVersion(direct);
20
+ }
21
+ const resolveFrom = require('resolve-from');
22
+ const fallback = resolveFrom.silent(fromDir, `${REACT_NATIVE_PACKAGE}/package.json`);
23
+ if (fallback) {
24
+ return readVersion(fallback);
25
+ }
26
+ } catch {
27
+ // Fall through to null.
28
+ }
29
+ return null;
30
+ }
31
+ function readVersion(pkgJsonPath) {
32
+ try {
33
+ const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
34
+ return typeof pkg.version === 'string' ? pkg.version : null;
35
+ } catch {
36
+ return null;
37
+ }
38
+ }
39
+
40
+ // Resolves the customerio-reactnative SDK location starting from `fromDir`.
41
+ //
42
+ // Probe-then-fallback so the result agrees with React Native autolinking
43
+ // across npm flat, pnpm, and yarn-workspace layouts:
44
+ // 1. `fromDir/node_modules/customerio-reactnative/package.json` — preferred.
45
+ // Works for npm flat, pnpm (the symlinked path; we never realpath it),
46
+ // and yarn workspaces with leaf node_modules. Matches what RN
47
+ // autolinking emits for its pod entry, so CocoaPods sees one
48
+ // consistent :path.
49
+ // 2. `resolve-from` walking up from `fromDir` — only used when (1) misses.
50
+ // Handles yarn classic workspaces where the dep is hoisted to a parent
51
+ // node_modules. yarn classic has no symlinks, so the realpath is fine.
52
+ //
53
+ // Returns null if neither finds the package, including the case where
54
+ // `resolve-from` itself can't be required (mirrors tryReadRNVersion's
55
+ // graceful-failure shape so callers can rely on the documented contract).
56
+ export function tryResolveRNSDK(fromDir) {
57
+ try {
58
+ const directPkgJson = path.join(fromDir, 'node_modules', RN_SDK_PACKAGE, 'package.json');
59
+ if (fs.existsSync(directPkgJson)) {
60
+ return {
61
+ packageDir: path.dirname(directPkgJson),
62
+ packageJsonPath: directPkgJson
63
+ };
64
+ }
65
+ const resolveFrom = require('resolve-from');
66
+ const fallbackPkgJson = resolveFrom.silent(fromDir, `${RN_SDK_PACKAGE}/package.json`);
67
+ if (fallbackPkgJson) {
68
+ return {
69
+ packageDir: path.dirname(fallbackPkgJson),
70
+ packageJsonPath: fallbackPkgJson
71
+ };
72
+ }
73
+ } catch {
74
+ // Fall through to null. resolveRNSDK() turns this into a clear
75
+ // "customerio-reactnative was not found" error for the caller.
76
+ }
77
+ return null;
78
+ }
79
+
80
+ // Same as tryResolveRNSDK but throws a clear error when the package is missing.
81
+ export function resolveRNSDK(fromDir) {
82
+ const resolved = tryResolveRNSDK(fromDir);
83
+ if (!resolved) {
84
+ throw new Error(`${RN_SDK_PACKAGE} was not found relative to ${fromDir}. ` + `Ensure it is installed in your project (or in a parent workspace's node_modules).`);
85
+ }
86
+ return resolved;
87
+ }
88
+ //# sourceMappingURL=resolveRNSDK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fs","path","RN_SDK_PACKAGE","REACT_NATIVE_PACKAGE","tryReadRNVersion","fromDir","direct","join","existsSync","readVersion","resolveFrom","require","fallback","silent","pkgJsonPath","pkg","JSON","parse","readFileSync","version","tryResolveRNSDK","directPkgJson","packageDir","dirname","packageJsonPath","fallbackPkgJson","resolveRNSDK","resolved","Error"],"sources":["resolveRNSDK.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nconst RN_SDK_PACKAGE = 'customerio-reactnative';\nconst REACT_NATIVE_PACKAGE = 'react-native';\n\nexport type ResolvedRNSDK = {\n // Absolute path to the package directory.\n packageDir: string;\n // Absolute path to package.json inside that directory.\n packageJsonPath: string;\n};\n\n// Reads the installed react-native package's version starting from `fromDir`.\n// Used to decide which autolinking flavor will resolve customerio-reactnative\n// at pod install time, so our :path agrees with what autolinking emits:\n// - RN <0.80 ships @react-native-community/cli, which uses a lexical\n// resolution (no realpath following).\n// - RN >=0.80 routes pod autolinking through expo-modules-autolinking,\n// which realpaths.\n// Returns null if react-native cannot be located or its package.json cannot\n// be read; callers should default to the modern (realpath) behavior in that\n// case since it has been the working path for the last several Expo SDKs.\nexport function tryReadRNVersion(fromDir: string): string | null {\n try {\n const direct = path.join(\n fromDir,\n 'node_modules',\n REACT_NATIVE_PACKAGE,\n 'package.json'\n );\n if (fs.existsSync(direct)) {\n return readVersion(direct);\n }\n const resolveFrom = require('resolve-from');\n const fallback = resolveFrom.silent(\n fromDir,\n `${REACT_NATIVE_PACKAGE}/package.json`\n );\n if (fallback) {\n return readVersion(fallback);\n }\n } catch {\n // Fall through to null.\n }\n return null;\n}\n\nfunction readVersion(pkgJsonPath: string): string | null {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));\n return typeof pkg.version === 'string' ? pkg.version : null;\n } catch {\n return null;\n }\n}\n\n// Resolves the customerio-reactnative SDK location starting from `fromDir`.\n//\n// Probe-then-fallback so the result agrees with React Native autolinking\n// across npm flat, pnpm, and yarn-workspace layouts:\n// 1. `fromDir/node_modules/customerio-reactnative/package.json` — preferred.\n// Works for npm flat, pnpm (the symlinked path; we never realpath it),\n// and yarn workspaces with leaf node_modules. Matches what RN\n// autolinking emits for its pod entry, so CocoaPods sees one\n// consistent :path.\n// 2. `resolve-from` walking up from `fromDir` — only used when (1) misses.\n// Handles yarn classic workspaces where the dep is hoisted to a parent\n// node_modules. yarn classic has no symlinks, so the realpath is fine.\n//\n// Returns null if neither finds the package, including the case where\n// `resolve-from` itself can't be required (mirrors tryReadRNVersion's\n// graceful-failure shape so callers can rely on the documented contract).\nexport function tryResolveRNSDK(fromDir: string): ResolvedRNSDK | null {\n try {\n const directPkgJson = path.join(\n fromDir,\n 'node_modules',\n RN_SDK_PACKAGE,\n 'package.json'\n );\n if (fs.existsSync(directPkgJson)) {\n return {\n packageDir: path.dirname(directPkgJson),\n packageJsonPath: directPkgJson,\n };\n }\n\n const resolveFrom = require('resolve-from');\n const fallbackPkgJson = resolveFrom.silent(\n fromDir,\n `${RN_SDK_PACKAGE}/package.json`\n );\n if (fallbackPkgJson) {\n return {\n packageDir: path.dirname(fallbackPkgJson),\n packageJsonPath: fallbackPkgJson,\n };\n }\n } catch {\n // Fall through to null. resolveRNSDK() turns this into a clear\n // \"customerio-reactnative was not found\" error for the caller.\n }\n\n return null;\n}\n\n// Same as tryResolveRNSDK but throws a clear error when the package is missing.\nexport function resolveRNSDK(fromDir: string): ResolvedRNSDK {\n const resolved = tryResolveRNSDK(fromDir);\n if (!resolved) {\n throw new Error(\n `${RN_SDK_PACKAGE} was not found relative to ${fromDir}. ` +\n `Ensure it is installed in your project (or in a parent workspace's node_modules).`\n );\n }\n return resolved;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,MAAMC,cAAc,GAAG,wBAAwB;AAC/C,MAAMC,oBAAoB,GAAG,cAAc;AAS3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAACC,OAAe,EAAiB;EAC/D,IAAI;IACF,MAAMC,MAAM,GAAGL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AM,CACxCR,OAAO,EACP,GAAGH,cAAc,eACnB,CAAC;IACD,IAAIuB,eAAe,EAAE;MACnB,OAAO;QACLH,UAAU,EAAErB,IAAI,CAACsB,OAAO,CAACE,eAAe,CAAC;QACzCD,eAAe,EAAEC;MACnB,CAAC;IACH;EACF,CAAC,CAAC,MAAM;IACN;IACA;EAAA;EAGF,OAAO,IAAI;AACb;;AAEA;AACA,OAAO,SAASC,YAAYA,CAACrB,OAAe,EAAiB;EAC3D,MAAMsB,QAAQ,GAAGP,eAAe,CAACf,OAAO,CAAC;EACzC,IAAI,CAACsB,QAAQ,EAAE;IACb,MAAM,IAAIC,KAAK,CACb,GAAG1B,cAAc,8BAA8BG,OAAO,IAAI,GAC1D,mFACF,CAAC;EACH;EACA,OAAOsB,QAAQ;AACjB","ignoreList":[]}
@@ -0,0 +1,48 @@
1
+ import fs from 'fs';
2
+ import { logger } from './logger';
3
+ import { getPluginVersion } from './plugin';
4
+ import { tryResolveRNSDK } from './resolveRNSDK';
5
+
6
+ // Writes the plugin's version into customerio-reactnative/package.json under
7
+ // the `expoVersion` key. The RN SDK reads this at runtime (customerio-cdp.ts)
8
+ // to set its User-Agent `packageSource` to "Expo" instead of "ReactNative".
9
+ //
10
+ // We rely on the postinstall hook (postInstallHelper.js) for the same write
11
+ // at install time, but call this from the plugin entry as a fallback for
12
+ // installs where postinstall does not run cleanly — most notably pnpm
13
+ // monorepos and any CI that uses --ignore-scripts.
14
+ //
15
+ // The write is idempotent: we no-op when the value is already correct.
16
+ export function writeExpoVersion(projectRoot) {
17
+ let resolved;
18
+ try {
19
+ resolved = tryResolveRNSDK(projectRoot);
20
+ } catch (error) {
21
+ logger.warn(`Could not locate customerio-reactnative to write expoVersion. ` + `User-Agent attribution may be incorrect. Original error: ${error}`);
22
+ return;
23
+ }
24
+ if (!resolved) {
25
+ return;
26
+ }
27
+ try {
28
+ const pluginVersion = getPluginVersion();
29
+ const pkg = JSON.parse(fs.readFileSync(resolved.packageJsonPath, 'utf8'));
30
+ if (pkg.expoVersion === pluginVersion) {
31
+ return;
32
+ }
33
+ pkg.expoVersion = pluginVersion;
34
+ fs.writeFileSync(resolved.packageJsonPath, JSON.stringify(pkg, null, 2));
35
+ } catch (error) {
36
+ logger.warn(`Failed to write expoVersion into ${resolved.packageJsonPath}. ` + `User-Agent attribution may be incorrect. Original error: ${error}`);
37
+ }
38
+ }
39
+ export const withExpoVersion = config => {
40
+ var _internal;
41
+ // _internal.projectRoot is set by Expo when running through prebuild;
42
+ // fall back to process.cwd() for any path that calls the plugin in
43
+ // a non-prebuild context.
44
+ const projectRoot = ((_internal = config._internal) === null || _internal === void 0 ? void 0 : _internal.projectRoot) || process.cwd();
45
+ writeExpoVersion(projectRoot);
46
+ return config;
47
+ };
48
+ //# sourceMappingURL=writeExpoVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fs","logger","getPluginVersion","tryResolveRNSDK","writeExpoVersion","projectRoot","resolved","error","warn","pluginVersion","pkg","JSON","parse","readFileSync","packageJsonPath","expoVersion","writeFileSync","stringify","withExpoVersion","config","_internal","process","cwd"],"sources":["writeExpoVersion.ts"],"sourcesContent":["import fs from 'fs';\nimport type { ConfigPlugin } from '@expo/config-plugins';\n\nimport { logger } from './logger';\nimport { getPluginVersion } from './plugin';\nimport { tryResolveRNSDK } from './resolveRNSDK';\n\n// Writes the plugin's version into customerio-reactnative/package.json under\n// the `expoVersion` key. The RN SDK reads this at runtime (customerio-cdp.ts)\n// to set its User-Agent `packageSource` to \"Expo\" instead of \"ReactNative\".\n//\n// We rely on the postinstall hook (postInstallHelper.js) for the same write\n// at install time, but call this from the plugin entry as a fallback for\n// installs where postinstall does not run cleanly — most notably pnpm\n// monorepos and any CI that uses --ignore-scripts.\n//\n// The write is idempotent: we no-op when the value is already correct.\nexport function writeExpoVersion(projectRoot: string): void {\n let resolved;\n try {\n resolved = tryResolveRNSDK(projectRoot);\n } catch (error) {\n logger.warn(\n `Could not locate customerio-reactnative to write expoVersion. ` +\n `User-Agent attribution may be incorrect. Original error: ${error}`\n );\n return;\n }\n\n if (!resolved) {\n return;\n }\n\n try {\n const pluginVersion = getPluginVersion();\n const pkg = JSON.parse(fs.readFileSync(resolved.packageJsonPath, 'utf8'));\n if (pkg.expoVersion === pluginVersion) {\n return;\n }\n pkg.expoVersion = pluginVersion;\n fs.writeFileSync(\n resolved.packageJsonPath,\n JSON.stringify(pkg, null, 2)\n );\n } catch (error) {\n logger.warn(\n `Failed to write expoVersion into ${resolved.packageJsonPath}. ` +\n `User-Agent attribution may be incorrect. Original error: ${error}`\n );\n }\n}\n\nexport const withExpoVersion: ConfigPlugin = (config) => {\n // _internal.projectRoot is set by Expo when running through prebuild;\n // fall back to process.cwd() for any path that calls the plugin in\n // a non-prebuild context.\n const projectRoot =\n (config as unknown as { _internal?: { projectRoot?: string } })._internal?.projectRoot ||\n process.cwd();\n writeExpoVersion(projectRoot);\n return config;\n};\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAGnB,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,gBAAgB,QAAQ,UAAU;AAC3C,SAASC,eAAe,QAAQ,gBAAgB;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAACC,WAAmB,EAAQ;EAC1D,IAAIC,QAAQ;EACZ,IAAI;IACFA,QAAQ,GAAGH,eAAe,CAACE,WAAW,CAAC;EACzC,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdN,MAAM,CAACO,IAAI,CACT,gEAAgE,GAChE,4DAA4DD,KAAK,EACnE,CAAC;IACD;EACF;EAEA,IAAI,CAACD,QAAQ,EAAE;IACb;EACF;EAEA,IAAI;IACF,MAAMG,aAAa,GAAGP,gBAAgB,CAAC,CAAC;IACxC,MAAMQ,GAAG,GAAGC,IAAI,CAACC,KAAK,CAACZ,EAAE,CAACa,YAAY,CAACP,QAAQ,CAACQ,eAAe,EAAE,MAAM,CAAC,CAAC;IACzE,IAAIJ,GAAG,CAACK,WAAW,KAAKN,aAAa,EAAE;MACrC;IACF;IACAC,GAAG,CAACK,WAAW,GAAGN,aAAa;IAC/BT,EAAE,CAACgB,aAAa,CACdV,QAAQ,CAACQ,eAAe,EACxBH,IAAI,CAACM,SAAS,CAACP,GAAG,EAAE,IAAI,EAAE,CAAC,CAC7B,CAAC;EACH,CAAC,CAAC,OAAOH,KAAK,EAAE;IACdN,MAAM,CAACO,IAAI,CACT,oCAAoCF,QAAQ,CAACQ,eAAe,IAAI,GAChE,4DAA4DP,KAAK,EACnE,CAAC;EACH;AACF;AAEA,OAAO,MAAMW,eAA6B,GAAIC,MAAM,IAAK;EAAA,IAAAC,SAAA;EACvD;EACA;EACA;EACA,MAAMf,WAAW,GACf,EAAAe,SAAA,GAACD,MAAM,CAAyDC,SAAS,cAAAA,SAAA,uBAAzEA,SAAA,CAA2Ef,WAAW,KACtFgB,OAAO,CAACC,GAAG,CAAC,CAAC;EACflB,gBAAgB,CAACC,WAAW,CAAC;EAC7B,OAAOc,MAAM;AACf,CAAC","ignoreList":[]}
@@ -1,4 +1,6 @@
1
1
  import type { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';
2
3
  import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
3
4
  export declare const DEFAULT_LOW_PRIORITY = -10;
5
+ export declare function modifyAndroidManifestApplication(application: ManifestApplication[], options: CustomerIOPluginOptionsAndroid): ManifestApplication[];
4
6
  export declare const withAndroidManifestUpdates: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -1,3 +1,4 @@
1
1
  import type { ConfigPlugin } from '@expo/config-plugins';
2
2
  import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
3
+ export declare function modifyAppBuildGradle(contents: string): string;
3
4
  export declare const withAppGoogleServices: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -1,3 +1,4 @@
1
1
  import type { ConfigPlugin } from '@expo/config-plugins';
2
2
  import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
3
+ export declare function copyGoogleServicesFile(androidPath: string, googleServicesFile: string | undefined): void;
3
4
  export declare const withGoogleServicesJSON: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -1,5 +1,7 @@
1
1
  import type { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { PropertiesItem } from '@expo/config-plugins/build/android/Properties';
2
3
  import type { CustomerIOPluginLocationOptions } from '../types/cio-types';
4
+ export declare function modifyGradleProperties(items: PropertiesItem[]): PropertiesItem[];
3
5
  /**
4
6
  * Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.
5
7
  * The Customer.io React Native SDK reads this to enable the location native module.
@@ -5,4 +5,10 @@ type MainApplicationModParams = {
5
5
  location?: CustomerIOPluginLocationOptions;
6
6
  };
7
7
  export declare const withMainApplicationModifications: ConfigPlugin<MainApplicationModParams>;
8
+ /**
9
+ * Pure string transform: given the existing MainApplication contents, returns the contents
10
+ * with the CustomerIOSDKInitializer import and onCreate call injected (idempotent — if the
11
+ * initialize call is already present, the call-injection step is skipped).
12
+ */
13
+ export declare function injectCustomerIOInitializerIntoMainApplication(contents: string): string;
8
14
  export {};
@@ -1,3 +1,8 @@
1
1
  import type { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';
2
3
  import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
4
+ /**
5
+ * Adds a metadata entry to the Android manifest if it doesn't already exist
6
+ */
7
+ export declare const addMetadataIfNotExists: (application: ManifestApplication, name: string, value: string) => void;
3
8
  export declare const withNotificationChannelMetadata: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -1,5 +1,14 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
2
  import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
3
+ /**
4
+ * Pure string transform: injects an androidx resolution-strategy block into the
5
+ * project-level build.gradle's `allprojects { ... }` section when
6
+ * `disableAndroid16Support` is true. Idempotent — returns input unchanged if the
7
+ * snippet is already present, or if the flag is false.
8
+ */
9
+ export declare function modifyProjectBuildGradleAndroid16Support(contents: string, options: {
10
+ disableAndroid16Support: boolean;
11
+ }): string;
3
12
  /**
4
13
  * Adds dependency resolution strategy to force specific androidx versions.
5
14
  * This disables Android 16 support for apps using Expo SDK 53 or older gradle versions.
@@ -1,3 +1,4 @@
1
1
  import type { ConfigPlugin } from '@expo/config-plugins';
2
2
  import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
3
+ export declare function modifyProjectBuildGradleForGoogleServices(contents: string): string;
3
4
  export declare const withProjectGoogleServices: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -1,3 +1,21 @@
1
+ /**
2
+ * Returns the relative path from the iOS project dir to the installed
3
+ * customerio-reactnative directory, in the exact form React Native pod
4
+ * autolinking will emit for the same package. The two autolinking
5
+ * flavors disagree on path shape under pnpm/yarn symlinks:
6
+ *
7
+ * - RN <0.80 (`@react-native-community/cli`): walks node_modules
8
+ * lexically, preserves symlinks. We keep the symlink path too —
9
+ * `tryResolveRNSDK` already does this without calling realpath.
10
+ *
11
+ * - RN >=0.80 (`expo-modules-autolinking`): realpaths the package
12
+ * via Node, emitting the underlying `.pnpm/...` (or yarn-classic)
13
+ * path. We match by realpath'ing the resolved directory.
14
+ *
15
+ * Decision points are logged so a customer's prebuild output is enough
16
+ * to triage path-resolution issues without a follow-up "set
17
+ * CUSTOMERIO_DEBUG_MODE and rerun" round-trip.
18
+ */
1
19
  export declare function getRelativePathToRNSDK(iosPath: string): any;
2
20
  export declare const IOS_DEPLOYMENT_TARGET = "13.0";
3
21
  export declare const GROUP_IDENTIFIER_TEMPLATE_REGEX: RegExp;
@@ -5,7 +5,31 @@ export type InjectCIOPodfileOptions = {
5
5
  /** When false and locationEnabled, inject only :subspecs => ['location']. When true, use push + location. */
6
6
  hasPush?: boolean;
7
7
  };
8
- /** Builds the host app pod line for the Podfile (single subspec or :subspecs with location). Exported for tests. */
8
+ /** Builds the host-app pod snippet for the Podfile.
9
+ *
10
+ * The :path is resolved at prebuild time by `getRelativePathToRNSDK`,
11
+ * which dispatches on the installed React Native version so the path
12
+ * matches what RN pod autolinking will emit (lexical for RN <0.80,
13
+ * realpath for RN >=0.80). Baking the resolved string directly avoids
14
+ * any Ruby/install-time logic in the Podfile and keeps the snippet
15
+ * trivially diff-able.
16
+ *
17
+ * Exported for tests.
18
+ */
9
19
  export declare function buildHostAppPodSnippet(iosPath: string, isFcmPushProvider: boolean, options?: InjectCIOPodfileOptions): string;
20
+ /**
21
+ * Pure string transform: given the existing Podfile contents, returns the
22
+ * Podfile with the CustomerIO host-app block injected before the Expo
23
+ * `post_install do |installer|` anchor. Idempotent — returns input unchanged
24
+ * if the block is already present.
25
+ */
26
+ export declare function injectHostAppPodfileCode(podfileContent: string, iosPath: string, isFcmPushProvider: boolean, options?: InjectCIOPodfileOptions): string;
10
27
  export declare function injectCIOPodfileCode(iosPath: string, isFcmPushProvider: boolean, options?: InjectCIOPodfileOptions): Promise<void>;
28
+ /**
29
+ * Pure string transform: given the existing Podfile contents, returns the
30
+ * Podfile with the rich-push NotificationService target block appended at
31
+ * the end. Idempotent — returns input unchanged if the block is already
32
+ * present.
33
+ */
34
+ export declare function appendNotificationTargetToPodfile(podfileContent: string, iosPath: string, isFcmPushProvider: boolean, useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']): string;
11
35
  export declare function injectCIONotificationPodfileCode(iosPath: string, useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'], isFcmPushProvider: boolean): Promise<void>;
@@ -1,3 +1,16 @@
1
1
  import type { ConfigPlugin } from '@expo/config-plugins';
2
2
  import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
+ /**
4
+ * Pure string transform: ensures the AppDelegate header (Objective-C path) declares
5
+ * `UNUserNotificationCenterDelegate` and imports `UserNotifications`. Idempotent.
6
+ */
7
+ export declare function modifyAppDelegateHeader(headerContent: string): string;
8
+ /**
9
+ * Pure string transform: produces the modified Objective-C AppDelegate.m / AppDelegate.mm
10
+ * contents wired with the Customer.io push pipeline (imports, declarations, notification
11
+ * configuration, registration callbacks, optional killed-state deep-link, FCM forward decl,
12
+ * Expo notifications header). The caller is responsible for the AppDelegate header file
13
+ * (.h) — see `modifyAppDelegateHeader`.
14
+ */
15
+ export declare function modifyAppDelegateContents(contents: string, projectName: string, props: CustomerIOPluginOptionsIOS): string;
3
16
  export declare const withAppDelegateModifications: ConfigPlugin<CustomerIOPluginOptionsIOS>;
@@ -1,3 +1,14 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
2
  import type { CustomerIOPluginOptionsIOS, CustomerIOPluginLocationOptions, NativeSDKConfig } from '../types/cio-types';
3
3
  export declare const withCIOIosSwift: (configOuter: ExpoConfig, sdkConfig?: NativeSDKConfig, props?: CustomerIOPluginOptionsIOS, location?: CustomerIOPluginLocationOptions) => ExpoConfig;
4
+ /**
5
+ * Pure string transform: produces the Swift AppDelegate contents wired to delegate to
6
+ * `CioSdkAppDelegateHandler` for both push notifications and (when configured) auto-init.
7
+ * Idempotent — returns `contents` unchanged when the handler is already present.
8
+ */
9
+ export declare function modifyAppDelegateForPushHandler(contents: string, props: CustomerIOPluginOptionsIOS): string;
10
+ /**
11
+ * Pure string transform: injects the auto-init snippet into the Swift AppDelegate's
12
+ * didFinishLaunchingWithOptions for the no-push path. Idempotent.
13
+ */
14
+ export declare function modifyAppDelegateForNativeSDKInitializer(contents: string): string;