customerio-expo-plugin 3.2.0 → 3.3.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 (44) hide show
  1. package/package.json +2 -2
  2. package/plugin/lib/commonjs/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
  3. package/plugin/lib/commonjs/helpers/native-files/ios/apn/NotificationService.swift +1 -1
  4. package/plugin/lib/commonjs/helpers/native-files/ios/apn/PushService.swift +1 -1
  5. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
  6. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
  7. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/PushService.swift +1 -1
  8. package/plugin/lib/commonjs/ios/withCIOIos.js +17 -0
  9. package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
  10. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +6 -3
  11. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  12. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +45 -11
  13. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  14. package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
  15. package/plugin/lib/commonjs/utils/validation.js +13 -0
  16. package/plugin/lib/commonjs/utils/validation.js.map +1 -1
  17. package/plugin/lib/module/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
  18. package/plugin/lib/module/helpers/native-files/ios/apn/NotificationService.swift +1 -1
  19. package/plugin/lib/module/helpers/native-files/ios/apn/PushService.swift +1 -1
  20. package/plugin/lib/module/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
  21. package/plugin/lib/module/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
  22. package/plugin/lib/module/helpers/native-files/ios/fcm/PushService.swift +1 -1
  23. package/plugin/lib/module/ios/withCIOIos.js +17 -0
  24. package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
  25. package/plugin/lib/module/ios/withCIOIosSwift.js +6 -3
  26. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  27. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +45 -11
  28. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  29. package/plugin/lib/module/types/cio-types.js.map +1 -1
  30. package/plugin/lib/module/utils/validation.js +13 -1
  31. package/plugin/lib/module/utils/validation.js.map +1 -1
  32. package/plugin/lib/typescript/types/cio-types.d.ts +7 -0
  33. package/plugin/lib/typescript/utils/validation.d.ts +3 -2
  34. package/plugin/src/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
  35. package/plugin/src/helpers/native-files/ios/apn/NotificationService.swift +1 -1
  36. package/plugin/src/helpers/native-files/ios/apn/PushService.swift +1 -1
  37. package/plugin/src/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
  38. package/plugin/src/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
  39. package/plugin/src/helpers/native-files/ios/fcm/PushService.swift +1 -1
  40. package/plugin/src/ios/withCIOIos.ts +16 -0
  41. package/plugin/src/ios/withCIOIosSwift.ts +10 -0
  42. package/plugin/src/ios/withNotificationsXcodeProject.ts +56 -1
  43. package/plugin/src/types/cio-types.ts +8 -0
  44. package/plugin/src/utils/validation.ts +18 -1
@@ -77,7 +77,7 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
77
77
  });
78
78
  };
79
79
  const addRichPushXcodeProj = async (options, xcodeProject) => {
80
- var _options$pushNotifica2;
80
+ var _options$pushNotifica2, _options$pushNotifica3, _options$pushNotifica4;
81
81
  const {
82
82
  appleTeamId,
83
83
  bundleIdentifier,
@@ -101,6 +101,24 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
101
101
  recursive: true
102
102
  });
103
103
  const platformSpecificFiles = ['NotificationService.swift'];
104
+ const nseEntitlementsFilename = 'NotificationService.entitlements';
105
+ const appGroupId = (_options$pushNotifica2 = options.pushNotification) === null || _options$pushNotifica2 === void 0 ? void 0 : _options$pushNotifica2.appGroupId;
106
+
107
+ // Write NSE entitlements file only when appGroupId is explicitly configured
108
+ if (appGroupId) {
109
+ const nseEntitlementsContent = `<?xml version="1.0" encoding="UTF-8"?>
110
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
111
+ <plist version="1.0">
112
+ <dict>
113
+ <key>com.apple.security.application-groups</key>
114
+ <array>
115
+ <string>${appGroupId}</string>
116
+ </array>
117
+ </dict>
118
+ </plist>
119
+ `;
120
+ FileManagement.writeFile(`${nsePath}/${nseEntitlementsFilename}`, nseEntitlementsContent);
121
+ }
104
122
  const commonFiles = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.m', ENV_FILENAME];
105
123
  const getTargetFile = filename => `${nsePath}/${filename}`;
106
124
  // Copy platform-specific files
@@ -122,12 +140,15 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
122
140
  bundleShortVersion,
123
141
  infoPlistTargetFile
124
142
  });
125
- updateNseEnv(getTargetFile(ENV_FILENAME), (_options$pushNotifica2 = options.pushNotification) === null || _options$pushNotifica2 === void 0 ? void 0 : _options$pushNotifica2.env);
143
+ updateNseEnv(getTargetFile(ENV_FILENAME), (_options$pushNotifica3 = options.pushNotification) === null || _options$pushNotifica3 === void 0 ? void 0 : _options$pushNotifica3.env);
144
+ updateNseNotificationService(getTargetFile('NotificationService.swift'), (_options$pushNotifica4 = options.pushNotification) === null || _options$pushNotifica4 === void 0 ? void 0 : _options$pushNotifica4.appGroupId);
145
+
146
+ // The entitlements file is generated (not copied from source), so it's listed separately
147
+ // for the Xcode group so it appears in the file navigator
148
+ const allGroupFiles = [...platformSpecificFiles, ...commonFiles, ...(appGroupId ? [nseEntitlementsFilename] : [])];
126
149
 
127
150
  // Create new PBXGroup for the extension
128
- const extGroup = xcodeProject.addPbxGroup([...platformSpecificFiles, ...commonFiles],
129
- // Combine platform-specific and common files,
130
- CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
151
+ const extGroup = xcodeProject.addPbxGroup(allGroupFiles, CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
131
152
 
132
153
  // Add the new PBXGroup to the top level group. This makes the
133
154
  // files / folder appear in the file explorer in Xcode.
@@ -169,6 +190,9 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
169
190
  buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
170
191
  buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
171
192
  buildSettingsObj.SWIFT_VERSION = 4.2;
193
+ if (appGroupId) {
194
+ buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${CIO_NOTIFICATION_TARGET_NAME}/${nseEntitlementsFilename}`;
195
+ }
172
196
  }
173
197
  }
174
198
 
@@ -188,6 +212,13 @@ const updateNseInfoPlist = payload => {
188
212
  }
189
213
  FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
190
214
  };
215
+ const updateNseNotificationService = (notificationServiceFile, appGroupId) => {
216
+ const APP_GROUP_ID_BUILDER_LINE_RE = /\{\{APP_GROUP_ID_BUILDER_LINE\}\}/;
217
+ let content = FileManagement.readFile(notificationServiceFile);
218
+ const builderLine = appGroupId ? ` .appGroupId(${JSON.stringify(appGroupId)})\n` : '';
219
+ content = replaceCodeByRegex(content, APP_GROUP_ID_BUILDER_LINE_RE, builderLine);
220
+ FileManagement.writeFile(notificationServiceFile, content);
221
+ };
191
222
  const updateNseEnv = (envFileName, richPushConfig) => {
192
223
  const CDP_API_KEY_RE = /\{\{CDP_API_KEY\}\}/;
193
224
  const REGION_RE = /\{\{REGION\}\}/;
@@ -251,11 +282,11 @@ async function addPushNotificationFile(options, xcodeProject) {
251
282
  xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);
252
283
  }
253
284
  const updatePushFile = (options, envFileName) => {
254
- var _options$pushNotifica3, _options$pushNotifica4, _options$pushNotifica5, _options$pushNotifica6, _options$pushNotifica7;
285
+ var _options$pushNotifica5, _options$pushNotifica6, _options$pushNotifica7, _options$pushNotifica8, _options$pushNotifica9, _options$pushNotifica0;
255
286
  const REGISTER_RE = /\{\{REGISTER_SNIPPET\}\}/;
256
287
  let envFileContent = FileManagement.readFile(envFileName);
257
- const disableNotificationRegistration = (_options$pushNotifica3 = options.pushNotification) === null || _options$pushNotifica3 === void 0 ? void 0 : _options$pushNotifica3.disableNotificationRegistration;
258
- const richPushConfig = (_options$pushNotifica4 = options.pushNotification) === null || _options$pushNotifica4 === void 0 ? void 0 : _options$pushNotifica4.env;
288
+ const disableNotificationRegistration = (_options$pushNotifica5 = options.pushNotification) === null || _options$pushNotifica5 === void 0 ? void 0 : _options$pushNotifica5.disableNotificationRegistration;
289
+ const richPushConfig = (_options$pushNotifica6 = options.pushNotification) === null || _options$pushNotifica6 === void 0 ? void 0 : _options$pushNotifica6.env;
259
290
  const {
260
291
  cdpApiKey,
261
292
  region
@@ -277,12 +308,15 @@ const updatePushFile = (options, envFileName) => {
277
308
  if (region) {
278
309
  envFileContent = replaceCodeByRegex(envFileContent, /\{\{REGION\}\}/, region.toUpperCase());
279
310
  }
280
- const autoTrackPushEvents = ((_options$pushNotifica5 = options.pushNotification) === null || _options$pushNotifica5 === void 0 ? void 0 : _options$pushNotifica5.autoTrackPushEvents) !== false;
311
+ const autoTrackPushEvents = ((_options$pushNotifica7 = options.pushNotification) === null || _options$pushNotifica7 === void 0 ? void 0 : _options$pushNotifica7.autoTrackPushEvents) !== false;
281
312
  envFileContent = replaceCodeByRegex(envFileContent, /\{\{AUTO_TRACK_PUSH_EVENTS\}\}/, autoTrackPushEvents.toString());
282
- const autoFetchDeviceToken = ((_options$pushNotifica6 = options.pushNotification) === null || _options$pushNotifica6 === void 0 ? void 0 : _options$pushNotifica6.autoFetchDeviceToken) !== false;
313
+ const autoFetchDeviceToken = ((_options$pushNotifica8 = options.pushNotification) === null || _options$pushNotifica8 === void 0 ? void 0 : _options$pushNotifica8.autoFetchDeviceToken) !== false;
283
314
  envFileContent = replaceCodeByRegex(envFileContent, /\{\{AUTO_FETCH_DEVICE_TOKEN\}\}/, autoFetchDeviceToken.toString());
284
- const showPushAppInForeground = ((_options$pushNotifica7 = options.pushNotification) === null || _options$pushNotifica7 === void 0 ? void 0 : _options$pushNotifica7.showPushAppInForeground) !== false;
315
+ const showPushAppInForeground = ((_options$pushNotifica9 = options.pushNotification) === null || _options$pushNotifica9 === void 0 ? void 0 : _options$pushNotifica9.showPushAppInForeground) !== false;
285
316
  envFileContent = replaceCodeByRegex(envFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
317
+ const appGroupId = (_options$pushNotifica0 = options.pushNotification) === null || _options$pushNotifica0 === void 0 ? void 0 : _options$pushNotifica0.appGroupId;
318
+ const appGroupIdBuilderLine = appGroupId ? ` .appGroupId(${JSON.stringify(appGroupId)})\n` : '';
319
+ envFileContent = replaceCodeByRegex(envFileContent, /\{\{APP_GROUP_ID_BUILDER_LINE\}\}/, appGroupIdBuilderLine);
286
320
  FileManagement.writeFile(envFileName, envFileContent);
287
321
  };
288
322
  //# sourceMappingURL=withNotificationsXcodeProject.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","replaceCodeByRegex","injectCIONotificationPodfileCode","logger","getIosNativeFilesPath","validateRichPushConfig","FileManagement","isExpoVersion53OrHigher","isFcmPushProvider","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","isExpo53OrHigher","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","String","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","_options$pushNotifica2","isFcmProvider","pbxTargetByName","warn","nsePath","mkdir","recursive","platformSpecificFiles","commonFiles","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","env","extGroup","addPbxGroup","groups","hash","project","objects","PBXGroup","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","PBXTargetDependency","PBXContainerItemProxy","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","writeFile","envFileName","richPushConfig","CDP_API_KEY_RE","REGION_RE","envFileContent","cdpApiKey","region","regionKey","toLowerCase","regionMap","us","eu","mappedRegion","sourceFile","targetFileName","appPath","exists","info","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","_options$pushNotifica3","_options$pushNotifica4","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","REGISTER_RE","disableNotificationRegistration","snippet","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS, RichPushConfig } from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { validateRichPushConfig } from '../utils/validation';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n isExpo53OrHigher: boolean,\n) => {\n try {\n // PushService file is only needed for pre-Expo 53 code generation\n if (options.pushNotification && !isExpo53OrHigher) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush === true) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: unknown) {\n logger.error(String(error));\n return null;\n }\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget, useFrameworks } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n } satisfies CustomerIOPluginOptionsIOS;\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults,\n isExpoVersion53OrHigher(configOuter),\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject,\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const platformSpecificFiles = ['NotificationService.swift'];\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${isFcmProvider ? 'fcm' : 'apn'\n }/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/common/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(getTargetFile(ENV_FILENAME), options.pushNotification?.env);\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects.PBXGroup;\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects.PBXTargetDependency = projObjects.PBXTargetDependency || {};\n projObjects.PBXContainerItemProxy = projObjects.PBXTargetDependency || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n logger.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n envFileName: string,\n richPushConfig?: RichPushConfig\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n // Use merged config values (config takes precedence over env)\n const cdpApiKey = richPushConfig?.cdpApiKey;\n const region = richPushConfig?.region;\n\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n cdpApiKey || 'MISSING_API_KEY',\n );\n\n // Simplify region mapping with case insensitive keys and fallback for invalid regions\n const regionKey = region?.toLowerCase() ?? '';\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n } as const;\n const mappedRegion = regionMap[regionKey as keyof typeof regionMap];\n if (!mappedRegion) {\n logger.warn(\n `${regionKey} is an invalid region. Please use the values from the docs: https://docs.customer.io/integrations/sdk/expo/getting-started/packages-options/#configuring-the-expo-plugin`\n );\n // Fallback to US if invalid region provided\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, regionMap.us);\n } else {\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) {\n // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${getIosNativeFilesPath()}/${sourceFile}`,\n targetFile\n );\n } else {\n logger.info(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n const richPushConfig = options.pushNotification?.env;\n const { cdpApiKey, region } = richPushConfig || {\n cdpApiKey: 'MISSING_API_KEY',\n region: undefined,\n };\n if (!validateRichPushConfig(richPushConfig)) {\n return;\n }\n\n let snippet = '';\n // unless this property is explicitly set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey,\n );\n\n if (region) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,sBAAsB;AAEvD,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,QACjB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,sBAAsB,QAAQ,qBAAqB;AAC5D,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,SAAS;AAEpE,MAAMC,cAAc,GAAG,GAAGX,4BAA4B,aAAa;AACnE,MAAMY,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAG,OAAO;AAEtC,MAAMC,+BAA+B,GAAG,MAAAA,CACtCC,OAAmC,EACnCC,YAA0B,EAC1BC,gBAAyB,KACtB;EACH,IAAI;IAAA,IAAAC,qBAAA;IACF;IACA,IAAIH,OAAO,CAACI,gBAAgB,IAAI,CAACF,gBAAgB,EAAE;MACjD,MAAMG,uBAAuB,CAACL,OAAO,EAAEC,YAAY,CAAC;IACtD;IAEA,IAAI,EAAAE,qBAAA,GAAAH,OAAO,CAACI,gBAAgB,cAAAD,qBAAA,uBAAxBA,qBAAA,CAA0BG,WAAW,MAAK,IAAI,EAAE;MAClD,MAAMC,oBAAoB,CAACP,OAAO,EAAEC,YAAY,CAAC;IACnD;IACA,OAAOA,YAAY;EACrB,CAAC,CAAC,OAAOO,KAAc,EAAE;IACvBlB,MAAM,CAACkB,KAAK,CAACC,MAAM,CAACD,KAAK,CAAC,CAAC;IAC3B,OAAO,IAAI;EACb;AACF,CAAC;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O_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,IA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EACd,iCAAiC,EACjCgC,oBAAoB,CAACD,QAAQ,CAAC,CAChC,CAAC;EAED,MAAME,uBAAuB,GAC3B,EAAAT,sBAAA,GAAAhI,OAAO,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 +1 @@
1
- {"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["/**\n * Properties set by the user in their app config file (e.g: app.json or app.plugin.js)\n * @public\n */\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n/**\n * Plugin options for iOS platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n\n useFrameworks?: 'static' | 'dynamic';\n\n pushNotification?: CustomerIOPluginPushNotificationOptions;\n\n /**\n * @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.\n */\n handleNotificationClick?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoFetchDeviceToken instead\n */\n autoFetchDeviceToken?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.showPushAppInForeground instead\n */\n showPushAppInForeground?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoTrackPushEvents instead\n */\n autoTrackPushEvents?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.handleDeeplinkInKilledState instead\n */\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.disableNotificationRegistration instead\n */\n disableNotificationRegistration?: boolean;\n};\n\n/**\n * Plugin options for Android platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n pushNotification?: {\n channel?: {\n id?: string;\n name?: string;\n importance?: number;\n };\n };\n /**\n * Controls whether to disable Android 16 support by downgrading androidx dependencies.\n *\n * When true (default for Expo SDK 53), forces older androidx versions compatible with\n * Android API 35 and AGP 8.8.2, preventing Android 16 incompatibility errors.\n *\n * When false (default for Expo SDK 54+), allows newer androidx versions that support Android 16\n * but require Android API 36 and AGP 8.9.1+.\n *\n * If not specified, the plugin auto-detects based on Expo SDK version:\n * - Expo SDK ≤53: true (disables Android 16)\n * - Expo SDK ≥54: false (enables Android 16)\n */\n disableAndroid16Support?: boolean;\n};\n\n/**\n * Location tracking mode for the Customer.io SDK location module.\n * Location is off by default. Only used when location is enabled (plugin option location.enabled: true).\n * @public\n */\nexport type LocationTrackingMode = 'OFF' | 'MANUAL' | 'ON_APP_START';\n\n/**\n * SDK configuration options for auto initialization\n * @public\n */\nexport type NativeSDKConfig = {\n cdpApiKey: string; // Required\n region?: 'US' | 'EU'; // Default: 'US'. The workspace region set for your workspace on the Customer.io dashboard\n autoTrackDeviceAttributes?: boolean; // Default: true\n trackApplicationLifecycleEvents?: boolean; // Default: true\n screenViewUse?: 'all' | 'inapp'; // Default: 'all'. 'all': sent to server + in-app messages, 'inapp': in-app messages only\n logLevel?: 'none' | 'error' | 'info' | 'debug'; // Default: 'debug'. Controls SDK logging verbosity\n siteId?: string; // Optional, if only siteId defined, migrationSiteId = siteId\n migrationSiteId?: string; // Optional, if only migrationSiteId defined, siteId should be null\n /**\n * Location module config. Location is off by default; only applied when plugin option location.enabled is true.\n * trackingMode: 'MANUAL' (host app controls when location is captured, default),\n * 'ON_APP_START' (SDK captures once per launch when app becomes active), or 'OFF'.\n */\n location?: {\n trackingMode?: LocationTrackingMode;\n };\n};\n\n/**\n * Location is off by default. When true, enables the Customer.io SDK location native module (iOS Podfile location subspec,\n * Android gradle.properties flag). Permissions and privacy keys (Info.plist, AndroidManifest)\n * remain the host app's responsibility.\n * @public\n */\nexport type CustomerIOPluginLocationOptions = {\n enabled?: boolean;\n};\n\n/**\n * Combined plugin options for both iOS and Android platforms\n * @public\n */\nexport type CustomerIOPluginOptions = {\n config?: NativeSDKConfig; // If defined, enables auto initialization of native SDK\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n /**\n * Location is off by default. When location.enabled is true, the plugin adds SDK build-time setup (Podfile location subspec,\n * gradle.properties). Host apps must add their own location permissions and privacy usage strings.\n */\n location?: CustomerIOPluginLocationOptions;\n};\n\n/**\n * Rich push configuration used to initialize Notification Service Extension (NSE) on the native side\n * @public\n */\nexport type RichPushConfig = {\n cdpApiKey: string;\n region?: string;\n};\n\n/**\n * Push notification configuration options\n * @public\n */\nexport type CustomerIOPluginPushNotificationOptions = {\n provider?: 'apn' | 'fcm';\n googleServicesFile?: string;\n useRichPush?: boolean;\n autoFetchDeviceToken?: boolean;\n autoTrackPushEvents?: boolean;\n showPushAppInForeground?: boolean;\n disableNotificationRegistration?: boolean;\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * Rich push config should match the values used to initialize SDK in the app.\n * Optional if `config` is provided at the top level.\n */\n env?: RichPushConfig;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["/**\n * Properties set by the user in their app config file (e.g: app.json or app.plugin.js)\n * @public\n */\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n/**\n * Plugin options for iOS platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n\n useFrameworks?: 'static' | 'dynamic';\n\n pushNotification?: CustomerIOPluginPushNotificationOptions;\n\n /**\n * @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.\n */\n handleNotificationClick?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoFetchDeviceToken instead\n */\n autoFetchDeviceToken?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.showPushAppInForeground instead\n */\n showPushAppInForeground?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoTrackPushEvents instead\n */\n autoTrackPushEvents?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.handleDeeplinkInKilledState instead\n */\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.disableNotificationRegistration instead\n */\n disableNotificationRegistration?: boolean;\n};\n\n/**\n * Plugin options for Android platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n pushNotification?: {\n channel?: {\n id?: string;\n name?: string;\n importance?: number;\n };\n };\n /**\n * Controls whether to disable Android 16 support by downgrading androidx dependencies.\n *\n * When true (default for Expo SDK 53), forces older androidx versions compatible with\n * Android API 35 and AGP 8.8.2, preventing Android 16 incompatibility errors.\n *\n * When false (default for Expo SDK 54+), allows newer androidx versions that support Android 16\n * but require Android API 36 and AGP 8.9.1+.\n *\n * If not specified, the plugin auto-detects based on Expo SDK version:\n * - Expo SDK ≤53: true (disables Android 16)\n * - Expo SDK ≥54: false (enables Android 16)\n */\n disableAndroid16Support?: boolean;\n};\n\n/**\n * Location tracking mode for the Customer.io SDK location module.\n * Location is off by default. Only used when location is enabled (plugin option location.enabled: true).\n * @public\n */\nexport type LocationTrackingMode = 'OFF' | 'MANUAL' | 'ON_APP_START';\n\n/**\n * SDK configuration options for auto initialization\n * @public\n */\nexport type NativeSDKConfig = {\n cdpApiKey: string; // Required\n region?: 'US' | 'EU'; // Default: 'US'. The workspace region set for your workspace on the Customer.io dashboard\n autoTrackDeviceAttributes?: boolean; // Default: true\n trackApplicationLifecycleEvents?: boolean; // Default: true\n screenViewUse?: 'all' | 'inapp'; // Default: 'all'. 'all': sent to server + in-app messages, 'inapp': in-app messages only\n logLevel?: 'none' | 'error' | 'info' | 'debug'; // Default: 'debug'. Controls SDK logging verbosity\n siteId?: string; // Optional, if only siteId defined, migrationSiteId = siteId\n migrationSiteId?: string; // Optional, if only migrationSiteId defined, siteId should be null\n /**\n * Location module config. Location is off by default; only applied when plugin option location.enabled is true.\n * trackingMode: 'MANUAL' (host app controls when location is captured, default),\n * 'ON_APP_START' (SDK captures once per launch when app becomes active), or 'OFF'.\n */\n location?: {\n trackingMode?: LocationTrackingMode;\n };\n};\n\n/**\n * Location is off by default. When true, enables the Customer.io SDK location native module (iOS Podfile location subspec,\n * Android gradle.properties flag). Permissions and privacy keys (Info.plist, AndroidManifest)\n * remain the host app's responsibility.\n * @public\n */\nexport type CustomerIOPluginLocationOptions = {\n enabled?: boolean;\n};\n\n/**\n * Combined plugin options for both iOS and Android platforms\n * @public\n */\nexport type CustomerIOPluginOptions = {\n config?: NativeSDKConfig; // If defined, enables auto initialization of native SDK\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n /**\n * Location is off by default. When location.enabled is true, the plugin adds SDK build-time setup (Podfile location subspec,\n * gradle.properties). Host apps must add their own location permissions and privacy usage strings.\n */\n location?: CustomerIOPluginLocationOptions;\n};\n\n/**\n * Rich push configuration used to initialize Notification Service Extension (NSE) on the native side\n * @public\n */\nexport type RichPushConfig = {\n cdpApiKey: string;\n region?: string;\n};\n\n/**\n * Push notification configuration options\n * @public\n */\nexport type CustomerIOPluginPushNotificationOptions = {\n provider?: 'apn' | 'fcm';\n googleServicesFile?: string;\n useRichPush?: boolean;\n autoFetchDeviceToken?: boolean;\n autoTrackPushEvents?: boolean;\n showPushAppInForeground?: boolean;\n disableNotificationRegistration?: boolean;\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * Rich push config should match the values used to initialize SDK in the app.\n * Optional if `config` is provided at the top level.\n */\n env?: RichPushConfig;\n\n /**\n * iOS App Group identifier shared between the host app and the Notification Service Extension.\n * When set, `.appGroupId(...)` is injected into the MessagingPushConfigBuilder, the identifier\n * is added to the host app entitlements, and an NSE entitlements file is written.\n * When omitted, the native SDK handles group discovery on its own and no entitlements are added.\n */\n appGroupId?: string;\n};\n"],"mappings":"","ignoreList":[]}
@@ -76,5 +76,17 @@ function validateRichPushConfig(config) {
76
76
  isValid = validateRegion(config === null || config === void 0 ? void 0 : config.region, 'region', context) && isValid;
77
77
  return isValid;
78
78
  }
79
- export { validateNativeSDKConfig, validateRequired, validateRichPushConfig, validateString };
79
+ function validatePushNotificationOptions(options) {
80
+ const context = 'PushNotification';
81
+ let isValid = true;
82
+ const appGroupId = options.appGroupId;
83
+ if (appGroupId !== undefined) {
84
+ isValid = validateString(appGroupId, 'appGroupId', context) && isValid;
85
+ if (isValid && !appGroupId.startsWith('group.')) {
86
+ logger.warn(`${context}: appGroupId "${appGroupId}" does not start with "group." — ensure this matches your Apple App Group entitlement.`);
87
+ }
88
+ }
89
+ return isValid;
90
+ }
91
+ export { validateNativeSDKConfig, validatePushNotificationOptions, validateRequired, validateRichPushConfig, validateString };
80
92
  //# sourceMappingURL=validation.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["logger","validate","isValid","messageFactory","message","process","env","CUSTOMERIO_STRICT_MODE","Error","format","warn","isUndefined","value","undefined","validateRequired","fieldName","context","validateString","trim","validateBoolean","validateEnum","allowedValues","lowerValue","toLowerCase","lowerAllowedValues","map","v","includes","valuesStr","join","validateRegion","validateNativeSDKConfig","config","cdpApiKey","region","screenViewUse","logLevel","autoTrackDeviceAttributes","trackApplicationLifecycleEvents","siteId","migrationSiteId","validateRichPushConfig"],"sources":["validation.ts"],"sourcesContent":["import type { NativeSDKConfig, RichPushConfig } from '../types/cio-types';\nimport { logger } from './logger';\n\n/**\n * Validates a condition and handles errors based on CUSTOMERIO_STRICT_MODE flag.\n * @param isValid - Function that returns true if validation passes\n * @param messageFactory - Function that returns the error message if validation fails\n * @returns true if validation passes, false if it fails\n */\nfunction validate(isValid: () => boolean, messageFactory: () => string): boolean {\n if (isValid()) {\n return true;\n }\n\n // Throw errors unless explicitly disabled, default to strict validation\n const message = messageFactory();\n // Throw an error if strict mode is enabled, log a warning otherwise\n if (process.env.CUSTOMERIO_STRICT_MODE === 'true') {\n throw new Error(logger.format(message));\n } else {\n logger.warn(message);\n }\n return false;\n}\n\nfunction isUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nfunction validateRequired(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => !isUndefined(value) && value !== null,\n () => `${context}: ${fieldName} is required, received: ${value}`\n );\n}\n\nfunction validateString(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || (typeof value === 'string' && value.trim() !== ''),\n () => `${context}: ${fieldName} must be a non-empty string, received: ${typeof value === 'string' ? `\"${value}\"` : value}`\n );\n}\n\nfunction validateBoolean(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || typeof value === 'boolean',\n () => `${context}: ${fieldName} must be a boolean, received: ${value}`\n );\n}\n\nfunction validateEnum<T extends string>(\n value: unknown,\n fieldName: string,\n allowedValues: readonly T[],\n context: string\n): boolean {\n if (isUndefined(value)) return true;\n\n // First validate it's a string\n if (!validateString(value, fieldName, context)) {\n return false;\n }\n\n // Then validate it's in the allowed values\n return validate(\n () => {\n const lowerValue = (value as string).toLowerCase();\n const lowerAllowedValues = allowedValues.map(v => v.toLowerCase());\n return lowerAllowedValues.includes(lowerValue);\n },\n () => {\n const valuesStr = allowedValues.map(v => `\"${v}\"`).join(', ');\n return `${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`;\n }\n );\n}\n\nfunction validateRegion(value: unknown, fieldName: string, context: string): boolean {\n return validateEnum(value, fieldName, ['US', 'EU'], context);\n}\n\nfunction validateNativeSDKConfig(config: NativeSDKConfig): boolean {\n const context = 'NativeSDKConfig';\n\n let isValid = true;\n\n isValid = validateRequired(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config.region, 'region', context) && isValid;\n isValid = validateEnum(config.screenViewUse, 'screenViewUse', ['all', 'inapp'], context) && isValid;\n isValid = validateEnum(config.logLevel, 'logLevel', ['none', 'error', 'info', 'debug'], context) && isValid;\n isValid = validateBoolean(config.autoTrackDeviceAttributes, 'autoTrackDeviceAttributes', context) && isValid;\n isValid = validateBoolean(config.trackApplicationLifecycleEvents, 'trackApplicationLifecycleEvents', context) && isValid;\n isValid = validateString(config.siteId, 'siteId', context) && isValid;\n isValid = validateString(config.migrationSiteId, 'migrationSiteId', context) && isValid;\n\n return isValid;\n}\n\nfunction validateRichPushConfig(config: RichPushConfig | undefined): boolean {\n const context = 'NotificationServiceExtension';\n\n let isValid = true;\n\n isValid = validateRequired(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config?.region, 'region', context) && isValid;\n\n return isValid;\n}\n\nexport {\n validateNativeSDKConfig,\n validateRequired,\n validateRichPushConfig,\n validateString\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AAId,OAAO;EAC5EA,OAAO,GAAG4B,cAAc,CAACE,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,EAAE,QAAQ,EAAElB,OAAO,CAAC,IAAId,OAAO;EAEtE,OAAOA,OAAO;AAChB;AAEA,SACE6B,uBAAuB,EACvBjB,gBAAgB,EAChB2B,sBAAsB,EACtBxB,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["logger","validate","isValid","messageFactory","message","process","env","CUSTOMERIO_STRICT_MODE","Error","format","warn","isUndefined","value","undefined","validateRequired","fieldName","context","validateString","trim","validateBoolean","validateEnum","allowedValues","lowerValue","toLowerCase","lowerAllowedValues","map","v","includes","valuesStr","join","validateRegion","validateNativeSDKConfig","config","cdpApiKey","region","screenViewUse","logLevel","autoTrackDeviceAttributes","trackApplicationLifecycleEvents","siteId","migrationSiteId","validateRichPushConfig","validatePushNotificationOptions","options","appGroupId","startsWith"],"sources":["validation.ts"],"sourcesContent":["import type { CustomerIOPluginPushNotificationOptions, NativeSDKConfig, RichPushConfig } from '../types/cio-types';\nimport { logger } from './logger';\n\n/**\n * Validates a condition and handles errors based on CUSTOMERIO_STRICT_MODE flag.\n * @param isValid - Function that returns true if validation passes\n * @param messageFactory - Function that returns the error message if validation fails\n * @returns true if validation passes, false if it fails\n */\nfunction validate(isValid: () => boolean, messageFactory: () => string): boolean {\n if (isValid()) {\n return true;\n }\n\n // Throw errors unless explicitly disabled, default to strict validation\n const message = messageFactory();\n // Throw an error if strict mode is enabled, log a warning otherwise\n if (process.env.CUSTOMERIO_STRICT_MODE === 'true') {\n throw new Error(logger.format(message));\n } else {\n logger.warn(message);\n }\n return false;\n}\n\nfunction isUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nfunction validateRequired(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => !isUndefined(value) && value !== null,\n () => `${context}: ${fieldName} is required, received: ${value}`\n );\n}\n\nfunction validateString(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || (typeof value === 'string' && value.trim() !== ''),\n () => `${context}: ${fieldName} must be a non-empty string, received: ${typeof value === 'string' ? `\"${value}\"` : value}`\n );\n}\n\nfunction validateBoolean(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || typeof value === 'boolean',\n () => `${context}: ${fieldName} must be a boolean, received: ${value}`\n );\n}\n\nfunction validateEnum<T extends string>(\n value: unknown,\n fieldName: string,\n allowedValues: readonly T[],\n context: string\n): boolean {\n if (isUndefined(value)) return true;\n\n // First validate it's a string\n if (!validateString(value, fieldName, context)) {\n return false;\n }\n\n // Then validate it's in the allowed values\n return validate(\n () => {\n const lowerValue = (value as string).toLowerCase();\n const lowerAllowedValues = allowedValues.map(v => v.toLowerCase());\n return lowerAllowedValues.includes(lowerValue);\n },\n () => {\n const valuesStr = allowedValues.map(v => `\"${v}\"`).join(', ');\n return `${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`;\n }\n );\n}\n\nfunction validateRegion(value: unknown, fieldName: string, context: string): boolean {\n return validateEnum(value, fieldName, ['US', 'EU'], context);\n}\n\nfunction validateNativeSDKConfig(config: NativeSDKConfig): boolean {\n const context = 'NativeSDKConfig';\n\n let isValid = true;\n\n isValid = validateRequired(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config.region, 'region', context) && isValid;\n isValid = validateEnum(config.screenViewUse, 'screenViewUse', ['all', 'inapp'], context) && isValid;\n isValid = validateEnum(config.logLevel, 'logLevel', ['none', 'error', 'info', 'debug'], context) && isValid;\n isValid = validateBoolean(config.autoTrackDeviceAttributes, 'autoTrackDeviceAttributes', context) && isValid;\n isValid = validateBoolean(config.trackApplicationLifecycleEvents, 'trackApplicationLifecycleEvents', context) && isValid;\n isValid = validateString(config.siteId, 'siteId', context) && isValid;\n isValid = validateString(config.migrationSiteId, 'migrationSiteId', context) && isValid;\n\n return isValid;\n}\n\nfunction validateRichPushConfig(config: RichPushConfig | undefined): boolean {\n const context = 'NotificationServiceExtension';\n\n let isValid = true;\n\n isValid = validateRequired(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config?.region, 'region', context) && isValid;\n\n return isValid;\n}\n\nfunction validatePushNotificationOptions(options: CustomerIOPluginPushNotificationOptions): boolean {\n const context = 'PushNotification';\n\n let isValid = true;\n\n const appGroupId = options.appGroupId;\n if (appGroupId !== undefined) {\n isValid = validateString(appGroupId, 'appGroupId', context) && isValid;\n if (isValid && !appGroupId.startsWith('group.')) {\n logger.warn(`${context}: appGroupId \"${appGroupId}\" does not start with \"group.\" — ensure this matches your Apple App Group entitlement.`);\n }\n }\n\n return isValid;\n}\n\nexport {\n validateNativeSDKConfig,\n validatePushNotificationOptions,\n validateRequired,\n validateRichPushConfig,\n validateString\n};\n\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,UAAU;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAACC,OAAsB,EAAEC,cAA4B,EAAW;EAC/E,IAAID,OAAO,CAAC,CAAC,EAAE;IACb,OAAO,IAAI;EACb;;EAEA;EACA,MAAME,OAAO,GAAGD,cAAc,CAAC,CAAC;EAChC;EACA,IAAIE,OAAO,CAACC,GAAG,CAACC,sBAAsB,KAAK,MAAM,EAAE;IACjD,MAAM,IAAIC,KAAK,CAACR,MAAM,CAACS,MAAM,CAACL,OAAO,CAAC,CAAC;EACzC,CAAC,MAAM;IACLJ,MAAM,CAACU,IAAI,CAACN,OAAO,CAAC;EACtB;EACA,OAAO,KAAK;AACd;AAEA,SAASO,WAAWA,CAACC,KAAc,EAAW;EAC5C,OAAOA,KAAK,KAAKC,SAAS;AAC5B;AAEA,SAASC,gBAAgBA,CAACF,KAAc,EAAEG,SAAiB,EAAEC,OAAe,EAAW;EACrF,OAAOf,QAAQ,CACb,MAAM,CAACU,WAAW,CAACC,KAAK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,EAC/B5B,gBAAgB,EAChB2B,sBAAsB,EACtBxB,cAAc","ignoreList":[]}
@@ -153,4 +153,11 @@ export type CustomerIOPluginPushNotificationOptions = {
153
153
  * Optional if `config` is provided at the top level.
154
154
  */
155
155
  env?: RichPushConfig;
156
+ /**
157
+ * iOS App Group identifier shared between the host app and the Notification Service Extension.
158
+ * When set, `.appGroupId(...)` is injected into the MessagingPushConfigBuilder, the identifier
159
+ * is added to the host app entitlements, and an NSE entitlements file is written.
160
+ * When omitted, the native SDK handles group discovery on its own and no entitlements are added.
161
+ */
162
+ appGroupId?: string;
156
163
  };
@@ -1,6 +1,7 @@
1
- import type { NativeSDKConfig, RichPushConfig } from '../types/cio-types';
1
+ import type { CustomerIOPluginPushNotificationOptions, NativeSDKConfig, RichPushConfig } from '../types/cio-types';
2
2
  declare function validateRequired(value: unknown, fieldName: string, context: string): boolean;
3
3
  declare function validateString(value: unknown, fieldName: string, context: string): boolean;
4
4
  declare function validateNativeSDKConfig(config: NativeSDKConfig): boolean;
5
5
  declare function validateRichPushConfig(config: RichPushConfig | undefined): boolean;
6
- export { validateNativeSDKConfig, validateRequired, validateRichPushConfig, validateString };
6
+ declare function validatePushNotificationOptions(options: CustomerIOPluginPushNotificationOptions): boolean;
7
+ export { validateNativeSDKConfig, validatePushNotificationOptions, validateRequired, validateRichPushConfig, validateString };
@@ -42,7 +42,7 @@ public class CioSdkAppDelegateHandler: NSObject {
42
42
  MessagingPushAPN.initialize(
43
43
  withConfig: MessagingPushConfigBuilder()
44
44
  .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
45
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
45
+ {{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
46
46
  .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
47
47
  .build()
48
48
  )
@@ -12,7 +12,7 @@ public class NotificationServiceCioManager : NSObject {
12
12
  MessagingPushAPN.initializeForExtension(
13
13
  withConfig: MessagingPushConfigBuilder(cdpApiKey: Env.customerIOCdpApiKey)
14
14
  .region(Env.customerIORegion)
15
- .build()
15
+ {{APP_GROUP_ID_BUILDER_LINE}} .build()
16
16
  )
17
17
 
18
18
  MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
@@ -15,7 +15,7 @@ public class CIOAppPushNotificationsHandler : NSObject {
15
15
  MessagingPushAPN.initialize(
16
16
  withConfig: MessagingPushConfigBuilder()
17
17
  .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
18
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
18
+ {{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
19
19
  .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
20
20
  .build()
21
21
  )
@@ -52,7 +52,7 @@ public class CioSdkAppDelegateHandler: NSObject {
52
52
  MessagingPushFCM.initialize(
53
53
  withConfig: MessagingPushConfigBuilder()
54
54
  .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
55
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
55
+ {{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
56
56
  .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
57
57
  .build()
58
58
  )
@@ -12,7 +12,7 @@ public class NotificationServiceCioManager : NSObject {
12
12
  MessagingPushFCM.initializeForExtension(
13
13
  withConfig: MessagingPushConfigBuilder(cdpApiKey: Env.customerIOCdpApiKey)
14
14
  .region(Env.customerIORegion)
15
- .build()
15
+ {{APP_GROUP_ID_BUILDER_LINE}} .build()
16
16
  )
17
17
 
18
18
  MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
@@ -23,7 +23,7 @@ public class CIOAppPushNotificationsHandler : NSObject {
23
23
  MessagingPushFCM.initialize(
24
24
  withConfig: MessagingPushConfigBuilder()
25
25
  .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
26
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
26
+ {{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
27
27
  .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
28
28
  .build()
29
29
  )
@@ -1,4 +1,5 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
+ import { withEntitlementsPlist } from '@expo/config-plugins';
2
3
  import type {
3
4
  CustomerIOPluginOptionsIOS,
4
5
  CustomerIOPluginPushNotificationOptions,
@@ -7,6 +8,7 @@ import type {
7
8
  } from '../types/cio-types';
8
9
  import { mergeConfigWithEnvValues } from '../utils/config';
9
10
  import { logger } from '../utils/logger';
11
+ import { validatePushNotificationOptions } from '../utils/validation';
10
12
  import { isExpoVersion53OrHigher } from './utils';
11
13
  import { withAppDelegateModifications } from './withAppDelegateModifications';
12
14
  import { withCIOIosSwift } from './withCIOIosSwift';
@@ -25,6 +27,7 @@ export function withCIOIos(
25
27
  const locationEnabled = location?.enabled === true;
26
28
 
27
29
  if (platformConfig?.pushNotification) {
30
+ validatePushNotificationOptions(platformConfig.pushNotification);
28
31
  if (isSwiftProject) {
29
32
  config = withCIOIosSwift(config, sdkConfig, platformConfig, location);
30
33
  } else {
@@ -44,6 +47,19 @@ export function withCIOIos(
44
47
  },
45
48
  });
46
49
  config = withGoogleServicesJsonFile(config, platformConfig);
50
+
51
+ // Merge App Group entitlements on host only when appGroupId is explicitly set
52
+ const appGroupId = platformConfig.pushNotification?.appGroupId;
53
+ if (appGroupId) {
54
+ config = withEntitlementsPlist(config, (entitlementsConfig) => {
55
+ const entitlements = entitlementsConfig.modResults as Record<string, unknown>;
56
+ const existing = (entitlements['com.apple.security.application-groups'] as string[] | undefined) ?? [];
57
+ if (!existing.includes(appGroupId)) {
58
+ entitlements['com.apple.security.application-groups'] = [...existing, appGroupId];
59
+ }
60
+ return entitlementsConfig;
61
+ });
62
+ }
47
63
  } else if (sdkConfig && isSwiftProject) {
48
64
  config = withCIOIosSwift(config, sdkConfig, platformConfig, location);
49
65
  if (locationEnabled) {
@@ -162,6 +162,16 @@ const copyAndConfigurePushAppDelegateHandler = ({
162
162
  showPushAppInForeground.toString()
163
163
  );
164
164
 
165
+ const appGroupId = props.pushNotification?.appGroupId;
166
+ const appGroupIdBuilderLine = appGroupId
167
+ ? ` .appGroupId(${JSON.stringify(appGroupId)})\n`
168
+ : '';
169
+ handlerFileContent = replaceCodeByRegex(
170
+ handlerFileContent,
171
+ /\{\{APP_GROUP_ID_BUILDER_LINE\}\}/,
172
+ appGroupIdBuilderLine
173
+ );
174
+
165
175
  // Add auto initialization if sdkConfig is provided
166
176
  if (sdkConfig) {
167
177
  // Also copy CustomerIOSDKInitializer.swift for auto-initialization
@@ -135,6 +135,25 @@ const addRichPushXcodeProj = async (
135
135
 
136
136
  const platformSpecificFiles = ['NotificationService.swift'];
137
137
 
138
+ const nseEntitlementsFilename = 'NotificationService.entitlements';
139
+ const appGroupId = options.pushNotification?.appGroupId;
140
+
141
+ // Write NSE entitlements file only when appGroupId is explicitly configured
142
+ if (appGroupId) {
143
+ const nseEntitlementsContent = `<?xml version="1.0" encoding="UTF-8"?>
144
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
145
+ <plist version="1.0">
146
+ <dict>
147
+ <key>com.apple.security.application-groups</key>
148
+ <array>
149
+ <string>${appGroupId}</string>
150
+ </array>
151
+ </dict>
152
+ </plist>
153
+ `;
154
+ FileManagement.writeFile(`${nsePath}/${nseEntitlementsFilename}`, nseEntitlementsContent);
155
+ }
156
+
138
157
  const commonFiles = [
139
158
  PLIST_FILENAME,
140
159
  'NotificationService.h',
@@ -170,10 +189,19 @@ const addRichPushXcodeProj = async (
170
189
  infoPlistTargetFile,
171
190
  });
172
191
  updateNseEnv(getTargetFile(ENV_FILENAME), options.pushNotification?.env);
192
+ updateNseNotificationService(getTargetFile('NotificationService.swift'), options.pushNotification?.appGroupId);
193
+
194
+ // The entitlements file is generated (not copied from source), so it's listed separately
195
+ // for the Xcode group so it appears in the file navigator
196
+ const allGroupFiles = [
197
+ ...platformSpecificFiles,
198
+ ...commonFiles,
199
+ ...(appGroupId ? [nseEntitlementsFilename] : []),
200
+ ];
173
201
 
174
202
  // Create new PBXGroup for the extension
175
203
  const extGroup = xcodeProject.addPbxGroup(
176
- [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common files,
204
+ allGroupFiles,
177
205
  CIO_NOTIFICATION_TARGET_NAME,
178
206
  CIO_NOTIFICATION_TARGET_NAME
179
207
  );
@@ -247,6 +275,9 @@ const addRichPushXcodeProj = async (
247
275
  buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
248
276
  buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
249
277
  buildSettingsObj.SWIFT_VERSION = 4.2;
278
+ if (appGroupId) {
279
+ buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${CIO_NOTIFICATION_TARGET_NAME}/${nseEntitlementsFilename}`;
280
+ }
250
281
  }
251
282
  }
252
283
 
@@ -284,6 +315,20 @@ const updateNseInfoPlist = (payload: {
284
315
  FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
285
316
  };
286
317
 
318
+ const updateNseNotificationService = (
319
+ notificationServiceFile: string,
320
+ appGroupId?: string,
321
+ ) => {
322
+ const APP_GROUP_ID_BUILDER_LINE_RE = /\{\{APP_GROUP_ID_BUILDER_LINE\}\}/;
323
+
324
+ let content = FileManagement.readFile(notificationServiceFile);
325
+ const builderLine = appGroupId
326
+ ? ` .appGroupId(${JSON.stringify(appGroupId)})\n`
327
+ : '';
328
+ content = replaceCodeByRegex(content, APP_GROUP_ID_BUILDER_LINE_RE, builderLine);
329
+ FileManagement.writeFile(notificationServiceFile, content);
330
+ };
331
+
287
332
  const updateNseEnv = (
288
333
  envFileName: string,
289
334
  richPushConfig?: RichPushConfig
@@ -429,5 +474,15 @@ const updatePushFile = (
429
474
  showPushAppInForeground.toString()
430
475
  );
431
476
 
477
+ const appGroupId = options.pushNotification?.appGroupId;
478
+ const appGroupIdBuilderLine = appGroupId
479
+ ? ` .appGroupId(${JSON.stringify(appGroupId)})\n`
480
+ : '';
481
+ envFileContent = replaceCodeByRegex(
482
+ envFileContent,
483
+ /\{\{APP_GROUP_ID_BUILDER_LINE\}\}/,
484
+ appGroupIdBuilderLine
485
+ );
486
+
432
487
  FileManagement.writeFile(envFileName, envFileContent);
433
488
  };
@@ -171,4 +171,12 @@ export type CustomerIOPluginPushNotificationOptions = {
171
171
  * Optional if `config` is provided at the top level.
172
172
  */
173
173
  env?: RichPushConfig;
174
+
175
+ /**
176
+ * iOS App Group identifier shared between the host app and the Notification Service Extension.
177
+ * When set, `.appGroupId(...)` is injected into the MessagingPushConfigBuilder, the identifier
178
+ * is added to the host app entitlements, and an NSE entitlements file is written.
179
+ * When omitted, the native SDK handles group discovery on its own and no entitlements are added.
180
+ */
181
+ appGroupId?: string;
174
182
  };