customerio-expo-plugin 3.4.0 → 3.5.1
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.
- package/package.json +2 -1
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +64 -59
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/commonjs/android/withAppGoogleServices.js +10 -7
- package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +18 -21
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/commonjs/android/withLocationGradleProperties.js +16 -12
- package/plugin/lib/commonjs/android/withLocationGradleProperties.js.map +1 -1
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js +19 -12
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +2 -1
- package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
- package/plugin/lib/commonjs/android/withProjectBuildGradle.js +29 -25
- package/plugin/lib/commonjs/android/withProjectBuildGradle.js.map +1 -1
- package/plugin/lib/commonjs/android/withProjectGoogleServices.js +9 -5
- package/plugin/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +63 -31
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +47 -33
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js +26 -42
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +46 -30
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +193 -123
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/android/withAndroidManifestUpdates.js +61 -58
- package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/module/android/withAppGoogleServices.js +9 -7
- package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
- package/plugin/lib/module/android/withGoogleServicesJSON.js +17 -21
- package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/module/android/withLocationGradleProperties.js +15 -12
- package/plugin/lib/module/android/withLocationGradleProperties.js.map +1 -1
- package/plugin/lib/module/android/withMainApplicationModifications.js +18 -12
- package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
- package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
- package/plugin/lib/module/android/withProjectBuildGradle.js +28 -25
- package/plugin/lib/module/android/withProjectBuildGradle.js.map +1 -1
- package/plugin/lib/module/android/withProjectGoogleServices.js +8 -5
- package/plugin/lib/module/android/withProjectGoogleServices.js.map +1 -1
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +61 -31
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/ios/withAppDelegateModifications.js +45 -33
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIosSwift.js +24 -42
- package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +45 -30
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +188 -123
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/typescript/android/withAndroidManifestUpdates.d.ts +2 -0
- package/plugin/lib/typescript/android/withAppGoogleServices.d.ts +1 -0
- package/plugin/lib/typescript/android/withGoogleServicesJSON.d.ts +1 -0
- package/plugin/lib/typescript/android/withLocationGradleProperties.d.ts +2 -0
- package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +6 -0
- package/plugin/lib/typescript/android/withNotificationChannelMetadata.d.ts +5 -0
- package/plugin/lib/typescript/android/withProjectBuildGradle.d.ts +9 -0
- package/plugin/lib/typescript/android/withProjectGoogleServices.d.ts +1 -0
- package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +14 -0
- package/plugin/lib/typescript/ios/withAppDelegateModifications.d.ts +13 -0
- package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +11 -0
- package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +14 -1
- package/plugin/lib/typescript/ios/withNotificationsXcodeProject.d.ts +53 -2
- package/plugin/src/android/withAndroidManifestUpdates.ts +83 -73
- package/plugin/src/android/withAppGoogleServices.ts +13 -11
- package/plugin/src/android/withGoogleServicesJSON.ts +30 -28
- package/plugin/src/android/withLocationGradleProperties.ts +23 -17
- package/plugin/src/android/withMainApplicationModifications.ts +25 -15
- package/plugin/src/android/withNotificationChannelMetadata.ts +1 -1
- package/plugin/src/android/withProjectBuildGradle.ts +37 -27
- package/plugin/src/android/withProjectGoogleServices.ts +14 -9
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +83 -48
- package/plugin/src/ios/withAppDelegateModifications.ts +61 -48
- package/plugin/src/ios/withCIOIosSwift.ts +33 -50
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +66 -48
- package/plugin/src/ios/withNotificationsXcodeProject.ts +258 -208
|
@@ -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,OAAO,EAAEC,YAAY,CAAC;IACtD;IAE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AxBA,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.PBXContainerItemProxy || {};\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,EAAE;MACjD,MAAMG,uBAAuB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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>;
|
|
@@ -17,5 +17,19 @@ export type InjectCIOPodfileOptions = {
|
|
|
17
17
|
* Exported for tests.
|
|
18
18
|
*/
|
|
19
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;
|
|
20
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;
|
|
21
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;
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
1
|
+
import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';
|
|
2
2
|
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
3
|
+
export type CopyGoogleServicePlistOptions = {
|
|
4
|
+
iosPath: string;
|
|
5
|
+
appName: string | undefined;
|
|
6
|
+
googleServicesFile: string | undefined;
|
|
7
|
+
expoIosGoogleServicesFileSet: boolean;
|
|
8
|
+
xcodeProject: XcodeProject;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Copies the FCM GoogleService-Info.plist into the iOS project (when needed) and registers it
|
|
12
|
+
* in the Xcode project's Resources group. Idempotent — no-ops if a plist is already present
|
|
13
|
+
* at either of the two well-known locations Expo / RN Firebase use.
|
|
14
|
+
*/
|
|
15
|
+
export declare function copyGoogleServicePlistFile({ iosPath, appName, googleServicesFile, expoIosGoogleServicesFileSet, xcodeProject, }: CopyGoogleServicePlistOptions): void;
|
|
3
16
|
export declare const withGoogleServicesJsonFile: ConfigPlugin<CustomerIOPluginOptionsIOS>;
|
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
-
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
1
|
+
import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';
|
|
2
|
+
import type { CustomerIOPluginOptionsIOS, RichPushConfig } from '../types/cio-types';
|
|
3
3
|
export declare const withCioNotificationsXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS>;
|
|
4
|
+
export type AddNseTargetToXcodeProjectOptions = {
|
|
5
|
+
appleTeamId?: string;
|
|
6
|
+
bundleIdentifier?: string;
|
|
7
|
+
iosDeploymentTarget?: string;
|
|
8
|
+
appGroupId?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Mutates the parsed XcodeProject to register the rich-push NotificationService
|
|
12
|
+
* extension target: creates a PBXGroup for its files, registers the group under
|
|
13
|
+
* the project's top-level group, adds the app_extension target, wires three
|
|
14
|
+
* build phases (Sources, Resources, Frameworks), configures the target's build
|
|
15
|
+
* settings (DEVELOPMENT_TEAM, IPHONEOS_DEPLOYMENT_TARGET, code-sign style,
|
|
16
|
+
* Swift version, and CODE_SIGN_ENTITLEMENTS when `appGroupId` is set), and
|
|
17
|
+
* stamps the development team attribute on both the new target and the
|
|
18
|
+
* project's main target attributes.
|
|
19
|
+
*
|
|
20
|
+
* Idempotent — returns the project unchanged if a target named
|
|
21
|
+
* `CIO_NOTIFICATION_TARGET_NAME` is already present.
|
|
22
|
+
*/
|
|
23
|
+
export declare function addNotificationServiceExtensionToXcodeProject(xcodeProject: XcodeProject, options: AddNseTargetToXcodeProjectOptions): XcodeProject;
|
|
24
|
+
/**
|
|
25
|
+
* Pure string transform: substitutes the `{{BUNDLE_VERSION}}` and
|
|
26
|
+
* `{{BUNDLE_SHORT_VERSION}}` placeholders in the NSE Info.plist template.
|
|
27
|
+
* Either or both may be provided; missing values leave the corresponding
|
|
28
|
+
* placeholder untouched.
|
|
29
|
+
*/
|
|
30
|
+
export declare function applyBundleVersionToNsePlist(content: string, payload: {
|
|
31
|
+
bundleVersion?: string;
|
|
32
|
+
bundleShortVersion?: string;
|
|
33
|
+
}): string;
|
|
34
|
+
/**
|
|
35
|
+
* Pure string transform: substitutes the `{{APP_GROUP_ID_BUILDER_LINE}}`
|
|
36
|
+
* placeholder in NotificationService.swift with either the configured
|
|
37
|
+
* appGroupId builder line or an empty string.
|
|
38
|
+
*/
|
|
39
|
+
export declare function applyAppGroupIdToNotificationService(content: string, appGroupId?: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Pure string transform: substitutes the `{{CDP_API_KEY}}` and `{{REGION}}`
|
|
42
|
+
* placeholders in the NSE Env.swift template. Missing or invalid region
|
|
43
|
+
* falls back to `Region.US` and logs a warning.
|
|
44
|
+
*/
|
|
45
|
+
export declare function applyRichPushConfigToEnv(content: string, richPushConfig?: RichPushConfig): string;
|
|
46
|
+
/**
|
|
47
|
+
* Pure string transform: substitutes every PushService.swift placeholder
|
|
48
|
+
* (`{{REGISTER_SNIPPET}}`, `{{CDP_API_KEY}}`, `{{REGION}}`,
|
|
49
|
+
* `{{AUTO_TRACK_PUSH_EVENTS}}`, `{{AUTO_FETCH_DEVICE_TOKEN}}`,
|
|
50
|
+
* `{{SHOW_PUSH_APP_IN_FOREGROUND}}`, `{{APP_GROUP_ID_BUILDER_LINE}}`) using
|
|
51
|
+
* the configured push-notification options. Validation of the rich-push
|
|
52
|
+
* config (cdpApiKey/region required) is the wrapper's responsibility.
|
|
53
|
+
*/
|
|
54
|
+
export declare function applyConfigToPushFile(content: string, options: CustomerIOPluginOptionsIOS): string;
|
|
@@ -9,92 +9,102 @@ import { logger } from '../utils/logger';
|
|
|
9
9
|
export const DEFAULT_LOW_PRIORITY = -10;
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const customerIOMessagingpush =
|
|
19
|
-
'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
|
|
12
|
+
export function modifyAndroidManifestApplication(
|
|
13
|
+
application: ManifestApplication[],
|
|
14
|
+
options: CustomerIOPluginOptionsAndroid
|
|
15
|
+
): ManifestApplication[] {
|
|
16
|
+
const customerIOMessagingpush =
|
|
17
|
+
'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
if (!application[0].service) {
|
|
20
|
+
application[0].service = [];
|
|
21
|
+
}
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const existingServiceIndex = application[0].service.findIndex(
|
|
24
|
+
(service) => service.$['android:name'] === customerIOMessagingpush
|
|
25
|
+
);
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
27
|
+
if (existingServiceIndex === -1) {
|
|
28
|
+
// Intent filter structure for Firebase messaging service
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
const intentFilter: any = {
|
|
31
|
+
action: [
|
|
32
|
+
{
|
|
33
|
+
$: {
|
|
34
|
+
'android:name': 'com.google.firebase.MESSAGING_EVENT',
|
|
38
35
|
},
|
|
39
|
-
],
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// Handle priority based on setHighPriorityPushHandler value
|
|
43
|
-
if (options.setHighPriorityPushHandler === true) {
|
|
44
|
-
// High priority - no priority attribute means default high priority
|
|
45
|
-
logger.info(
|
|
46
|
-
'Successfully set CustomerIO push handler as high priority in AndroidManifest.xml'
|
|
47
|
-
);
|
|
48
|
-
} else if (options.setHighPriorityPushHandler === false) {
|
|
49
|
-
// Low priority - set fixed priority
|
|
50
|
-
intentFilter.$ = {
|
|
51
|
-
'android:priority': DEFAULT_LOW_PRIORITY.toString(),
|
|
52
|
-
};
|
|
53
|
-
logger.info(
|
|
54
|
-
`Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
application[0].service.push({
|
|
59
|
-
'$': {
|
|
60
|
-
'android:name': customerIOMessagingpush,
|
|
61
|
-
'android:exported': 'false',
|
|
62
36
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
} else if (options.setHighPriorityPushHandler === true) {
|
|
66
|
-
// Service exists, need to ensure it becomes high priority (remove priority attribute)
|
|
67
|
-
const existingService = application[0].service[existingServiceIndex];
|
|
37
|
+
],
|
|
38
|
+
};
|
|
68
39
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
'Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml'
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
40
|
+
// Handle priority based on setHighPriorityPushHandler value
|
|
41
|
+
if (options.setHighPriorityPushHandler === true) {
|
|
42
|
+
// High priority - no priority attribute means default high priority
|
|
43
|
+
logger.info(
|
|
44
|
+
'Successfully set CustomerIO push handler as high priority in AndroidManifest.xml'
|
|
45
|
+
);
|
|
79
46
|
} else if (options.setHighPriorityPushHandler === false) {
|
|
80
|
-
//
|
|
81
|
-
|
|
47
|
+
// Low priority - set fixed priority
|
|
48
|
+
intentFilter.$ = {
|
|
49
|
+
'android:priority': DEFAULT_LOW_PRIORITY.toString(),
|
|
50
|
+
};
|
|
51
|
+
logger.info(
|
|
52
|
+
`Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
82
55
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
56
|
+
application[0].service.push({
|
|
57
|
+
'$': {
|
|
58
|
+
'android:name': customerIOMessagingpush,
|
|
59
|
+
'android:exported': 'false',
|
|
60
|
+
},
|
|
61
|
+
'intent-filter': [intentFilter],
|
|
62
|
+
});
|
|
63
|
+
} else if (options.setHighPriorityPushHandler === true) {
|
|
64
|
+
// Service exists, need to ensure it becomes high priority (remove priority attribute)
|
|
65
|
+
const existingService = application[0].service[existingServiceIndex];
|
|
66
|
+
|
|
67
|
+
if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
+
const intentFilter = existingService['intent-filter'][0] as any;
|
|
70
|
+
if (intentFilter.$ && intentFilter.$['android:priority']) {
|
|
71
|
+
delete intentFilter.$['android:priority'];
|
|
91
72
|
logger.info(
|
|
92
|
-
|
|
73
|
+
'Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml'
|
|
93
74
|
);
|
|
94
75
|
}
|
|
95
76
|
}
|
|
77
|
+
} else if (options.setHighPriorityPushHandler === false) {
|
|
78
|
+
// Service exists, update to low priority
|
|
79
|
+
const existingService = application[0].service[existingServiceIndex];
|
|
80
|
+
|
|
81
|
+
// Update existing service intent-filter with fixed priority
|
|
82
|
+
if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
const intentFilter = existingService['intent-filter'][0] as any;
|
|
85
|
+
if (!intentFilter.$) {
|
|
86
|
+
intentFilter.$ = {};
|
|
87
|
+
}
|
|
88
|
+
intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();
|
|
89
|
+
logger.info(
|
|
90
|
+
`Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
96
94
|
|
|
97
|
-
|
|
95
|
+
return application;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const withAndroidManifestUpdates: ConfigPlugin<
|
|
99
|
+
CustomerIOPluginOptionsAndroid
|
|
100
|
+
> = (configOuter, options) => {
|
|
101
|
+
return withAndroidManifest(configOuter, (props) => {
|
|
102
|
+
const application = props.modResults.manifest
|
|
103
|
+
.application as ManifestApplication[];
|
|
104
|
+
props.modResults.manifest.application = modifyAndroidManifestApplication(
|
|
105
|
+
application,
|
|
106
|
+
options
|
|
107
|
+
);
|
|
98
108
|
return props;
|
|
99
109
|
});
|
|
100
110
|
};
|
|
@@ -8,21 +8,23 @@ import {
|
|
|
8
8
|
import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
|
|
9
9
|
import { logger } from '../utils/logger';
|
|
10
10
|
|
|
11
|
+
export function modifyAppBuildGradle(contents: string): string {
|
|
12
|
+
const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);
|
|
13
|
+
if (regex.test(contents)) {
|
|
14
|
+
logger.info('app/build.gradle snippet already exists. Skipping...');
|
|
15
|
+
return contents;
|
|
16
|
+
}
|
|
17
|
+
return contents.replace(
|
|
18
|
+
CIO_APP_APPLY_REGEX,
|
|
19
|
+
`$1\n${CIO_APP_GOOGLE_SNIPPET}`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
11
23
|
export const withAppGoogleServices: ConfigPlugin<
|
|
12
24
|
CustomerIOPluginOptionsAndroid
|
|
13
25
|
> = (configOuter) => {
|
|
14
26
|
return withAppBuildGradle(configOuter, (props) => {
|
|
15
|
-
|
|
16
|
-
const match = props.modResults.contents.match(regex);
|
|
17
|
-
if (!match) {
|
|
18
|
-
props.modResults.contents = props.modResults.contents.replace(
|
|
19
|
-
CIO_APP_APPLY_REGEX,
|
|
20
|
-
`$1\n${CIO_APP_GOOGLE_SNIPPET}`
|
|
21
|
-
);
|
|
22
|
-
} else {
|
|
23
|
-
logger.info('app/build.gradle snippet already exists. Skipping...');
|
|
24
|
-
}
|
|
25
|
-
|
|
27
|
+
props.modResults.contents = modifyAppBuildGradle(props.modResults.contents);
|
|
26
28
|
return props;
|
|
27
29
|
});
|
|
28
30
|
};
|