customerio-expo-plugin 1.0.0-beta.13 → 1.0.0-beta.15
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/lib/commonjs/helpers/constants/android.js +7 -14
- package/lib/commonjs/helpers/constants/android.js.map +1 -1
- package/lib/commonjs/helpers/constants/ios.js +55 -77
- package/lib/commonjs/helpers/constants/ios.js.map +1 -1
- package/lib/commonjs/helpers/native-files/ios/PushService.swift +14 -12
- package/lib/commonjs/helpers/utils/codeInjection.js +1 -1
- package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -1
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/commonjs/index.js +1 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ios/withAppDelegateModifications.js +16 -14
- package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/lib/commonjs/ios/withNotificationsXcodeProject.js +10 -1
- package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/commonjs/types/cio-types.js.map +1 -1
- package/lib/module/helpers/constants/ios.js +25 -15
- package/lib/module/helpers/constants/ios.js.map +1 -1
- package/lib/module/helpers/native-files/ios/PushService.swift +14 -12
- package/lib/module/helpers/utils/codeInjection.js +1 -1
- package/lib/module/helpers/utils/codeInjection.js.map +1 -1
- package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/module/ios/withAppDelegateModifications.js +17 -15
- package/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/lib/module/ios/withNotificationsXcodeProject.js +10 -1
- package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/module/types/cio-types.js.map +1 -1
- package/lib/typescript/helpers/constants/ios.d.ts +1 -3
- package/lib/typescript/helpers/utils/codeInjection.d.ts +1 -1
- package/lib/typescript/types/cio-types.d.ts +5 -0
- package/package.json +2 -2
- package/src/helpers/constants/ios.ts +35 -22
- package/src/helpers/native-files/ios/PushService.swift +14 -12
- package/src/helpers/utils/codeInjection.ts +1 -1
- package/src/helpers/utils/injectCIOPodfileCode.ts +6 -2
- package/src/ios/withAppDelegateModifications.ts +52 -41
- package/src/ios/withNotificationsXcodeProject.ts +37 -2
- package/src/types/cio-types.ts +7 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","replaceCodeByRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","console","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","pbxTargetByName","warn","nsePath","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","extGroup","addPbxGroup","groups","hash","project","objects","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","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","_options$pushNotifica2","_options$pushNotifica4","_options$pushNotifica6","SITE_ID_RE","API_KEY_RE","REGION_RE","envFileContent","env","siteId","_options$pushNotifica3","apiKey","_options$pushNotifica5","region","_options$pushNotifica7","regionMap","us","eu","toLowerCase","mappedRegion","_options$pushNotifica8","file","appPath","exists","log","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","REGISTER_RE","snippet","disableNotificationRegistration"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import {\n ConfigPlugin,\n XcodeProject,\n withXcodeProject,\n} from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\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) => {\n try {\n if (options.pushNotification) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: any) {\n console.error(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 {\n appleTeamId,\n iosDeploymentTarget,\n pushNotification,\n useFrameworks,\n } = 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 pushNotification,\n };\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults\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: any\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks);\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 console.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 files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${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(options, getTargetFile(ENV_FILENAME));\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n 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'] =\n projObjects['PBXTargetDependency'] || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.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 || '13.0';\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 options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const SITE_ID_RE = /\\{\\{SITE_ID\\}\\}/;\n const API_KEY_RE = /\\{\\{API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n if (options.pushNotification?.env?.siteId) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n SITE_ID_RE,\n options.pushNotification?.env?.siteId\n );\n }\n\n if (options.pushNotification?.env?.apiKey) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n API_KEY_RE,\n options.pushNotification?.env?.apiKey\n );\n }\n\n if (options.pushNotification?.env?.region) {\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const region = options.pushNotification?.env?.region?.toLowerCase();\n const mappedRegion = (regionMap as any)[region] || '';\n if (!mappedRegion) {\n console.warn(\n `${options.pushNotification?.env?.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`\n );\n } else {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n REGION_RE,\n mappedRegion\n );\n }\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) {\n const { iosPath, appName } = options;\n const file = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(file);\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(file))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(file)} 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}/${file}`, 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\n let snippet = '';\n if (\n options.disableNotificationRegistration !== undefined &&\n options.disableNotificationRegistration === false\n ) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AAAA,SAGEA,gBAAgB,QACX,sBAAsB;AAE7B,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,cAAc,GAAI,GAAEP,4BAA6B,aAAY;AACnE,MAAMQ,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAI,OAAM;AAEtC,MAAMC,+BAA+B,GAAG,MAAAA,CACtCC,OAAmC,EACnCC,YAA0B,KACvB;EACH,IAAI;IAAA,IAAAC,qBAAA;IACF,IAAIF,OAAO,CAACG,gBAAgB,EAAE;MAC5B,MAAMC,uBAAuB,CAACJ,OAAO,EAAEC,YAAY,CAAC;IACtD;IAEA,KAAAC,qBAAA,GAAIF,OAAO,CAACG,gBAAgB,cAAAD,qBAAA,eAAxBA,qBAAA,CAA0BG,WAAW,EAAE;MACzC,MAAMC,oBAAoB,CAACN,OAAO,EAAEC,YAAY,CAAC;IACnD;IACA,OAAOA,YAAY;EACrB,CAAC,CAAC,OAAOM,KAAU,EAAE;IACnBC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;IACpB,OAAO,IAAI;EACb;AACF,CAAC;AAED,OAAO,MAAME,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EAEzEnH,cAAc,CAACkF,SAAS,CAACC,WAAW,EAAEO,cAAc,CAAC;AACvD,CAAC"}
|
|
1
|
+
{"version":3,"names":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","replaceCodeByRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","console","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","pbxTargetByName","warn","nsePath","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","extGroup","addPbxGroup","groups","hash","project","objects","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","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","_options$pushNotifica2","_options$pushNotifica4","_options$pushNotifica6","SITE_ID_RE","API_KEY_RE","REGION_RE","envFileContent","env","siteId","_options$pushNotifica3","apiKey","_options$pushNotifica5","region","_options$pushNotifica7","regionMap","us","eu","toLowerCase","mappedRegion","_options$pushNotifica8","file","appPath","exists","log","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","REGISTER_RE","snippet","disableNotificationRegistration","toUpperCase","autoTrackPushEvents","toString","showPushAppInForeground"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import {\n ConfigPlugin,\n XcodeProject,\n withXcodeProject,\n} from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\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) => {\n try {\n if (options.pushNotification) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: any) {\n console.error(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 {\n appleTeamId,\n iosDeploymentTarget,\n pushNotification,\n useFrameworks,\n } = 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 pushNotification,\n };\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults\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: any\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks);\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 console.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 files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${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(options, getTargetFile(ENV_FILENAME));\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n 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'] =\n projObjects['PBXTargetDependency'] || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.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 || '13.4';\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 options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const SITE_ID_RE = /\\{\\{SITE_ID\\}\\}/;\n const API_KEY_RE = /\\{\\{API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n if (options.pushNotification?.env?.siteId) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n SITE_ID_RE,\n options.pushNotification?.env?.siteId\n );\n }\n\n if (options.pushNotification?.env?.apiKey) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n API_KEY_RE,\n options.pushNotification?.env?.apiKey\n );\n }\n\n if (options.pushNotification?.env?.region) {\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const region = options.pushNotification?.env?.region?.toLowerCase();\n const mappedRegion = (regionMap as any)[region] || '';\n if (!mappedRegion) {\n console.warn(\n `${options.pushNotification?.env?.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`\n );\n } else {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n REGION_RE,\n mappedRegion\n );\n }\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) {\n const { iosPath, appName } = options;\n const file = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(file);\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(file))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(file)} 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}/${file}`, 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\n let snippet = '';\n if (\n options.disableNotificationRegistration !== undefined &&\n options.disableNotificationRegistration === false\n ) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n if (options.pushNotification) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SITE_ID\\}\\}/,\n options.pushNotification.env.siteId\n );\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{API_KEY\\}\\}/,\n options.pushNotification.env.apiKey\n );\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n options.pushNotification.env.region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.autoTrackPushEvents === undefined ||\n options.autoTrackPushEvents === true;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const showPushAppInForeground =\n options.showPushAppInForeground === undefined ||\n options.showPushAppInForeground === true;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AAAA,SAGEA,gBAAgB,QACX,sBAAsB;AAE7B,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,cAAc,GAAI,GAAEP,4BAA6B,aAAY;AACnE,MAAMQ,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAI,OAAM;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AO,CAACmH,uBAAuB,KAAK,IAAI;EAC1C9B,cAAc,GAAG5F,kBAAkB,CACjC4F,cAAc,EACd,qCAAqC,EACrC8B,uBAAuB,CAACD,QAAQ,CAAC,CACnC,CAAC;EAEDvH,cAAc,CAACkF,SAAS,CAACC,WAAW,EAAEO,cAAc,CAAC;AACvD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["// properties set by the user in their app config file (e.g: app.json or app.plugin.js)\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n// Plugin options for pre-build\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 disableNotificationRegistration?: boolean;\n handleNotificationClick?:boolean;\n handleDeeplinkInKilledState?:boolean;\n useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n useRichPush: boolean;\n env: {\n siteId: string;\n apiKey: string;\n region: string;\n };\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["// properties set by the user in their app config file (e.g: app.json or app.plugin.js)\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n// Plugin options for pre-build\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 disableNotificationRegistration?: boolean;\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 showPushAppInForeground?: boolean;\n autoTrackPushEvents?: boolean;\n handleDeeplinkInKilledState?: boolean;\n useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n useRichPush: boolean;\n env: {\n siteId: string;\n apiKey: string;\n region: string;\n };\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":""}
|
|
@@ -26,8 +26,6 @@ export declare const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = "\nreturn [supe
|
|
|
26
26
|
export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = "\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n";
|
|
27
27
|
export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = "\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n";
|
|
28
28
|
export declare const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = "\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n";
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const CIO_INITIALIZECIOSDK_SNIPPET = " \n [pnHandlerObj initializeCioSdk];\n\n// Code to make the CIO SDK compatible with expo-notifications package.\n// \n// The CIO SDK and expo-notifications both need to handle when a push gets clicked. However, iOS only allows one click handler to be set per app.\n// To get around this limitation, we set the CIO SDK as the click handler. The CIO SDK sets itself up so that when another SDK or host iOS app \n// sets itself as the click handler, the CIO SDK will still be able to handle when the push gets clicked, even though it's not the designated \n// click handler in iOS at runtime. \n// \n// This should work for most SDKs. However, expo-notifications is unique in it's implementation. It will not setup push click handling it if detects \n// that another SDK or host iOS app has already set itself as the click handler:\n// https://github.com/expo/expo/blob/1b29637bec0b9888e8bc8c310476293a3e2d9786/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L31-L37\n// ...to get around this, we must manually set it as the click handler after the CIO SDK. That's what this code block does.\n//\n// Note: Initialize the native iOS SDK and setup SDK push click handling before running this code. \n# if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n // Creating a new instance, as the comments in expo-notifications suggests, does not work. With this code, if you send a CIO push to device and click on it,\n // no push metrics reporting will occur.\n // EXNotificationCenterDelegate *notificationCenterDelegate = [[EXNotificationCenterDelegate alloc] init];\n\n // ...instead, get the singleton reference from Expo. \n id<UNUserNotificationCenterDelegate> notificationCenterDelegate = (id<UNUserNotificationCenterDelegate>) [EXModuleRegistryProvider getSingletonModuleForClass:[EXNotificationCenterDelegate class]];\n UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];\n center.delegate = notificationCenterDelegate;\n# endif\n";
|
|
30
30
|
export declare const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = "\n// Deep link workaround for app killed state start\nNSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];\n if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {\n NSDictionary *pushContent = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];\n if (pushContent[@\"CIO\"] && pushContent[@\"CIO\"][@\"push\"] && pushContent[@\"CIO\"][@\"push\"][@\"link\"]) {\n NSString *initialURL = pushContent[@\"CIO\"][@\"push\"][@\"link\"];\n if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {\n modifiedLaunchOptions[UIApplicationLaunchOptionsURLKey] = [NSURL URLWithString:initialURL];\n }\n }\n }\n//Deep link workaround for app killed state ends\n";
|
|
31
|
-
export declare const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = "\n- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {\n [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];\n}";
|
|
32
|
-
export declare const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = "\n// show push when the app is in foreground\n- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {\n completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);\n}";
|
|
33
31
|
export declare const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = "\n@objc(registerPushNotification)\n public func registerPushNotification() {\n\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }";
|
|
@@ -4,4 +4,4 @@ export declare function injectCodeBeforeMultiLineRegex(fileContent: string, line
|
|
|
4
4
|
export declare function replaceCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
5
5
|
export declare function matchRegexExists(fileContent: string, regex: RegExp): boolean;
|
|
6
6
|
export declare function injectCodeByMultiLineRegexAndReplaceLine(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
7
|
-
export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string
|
|
7
|
+
export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string;
|
|
@@ -12,7 +12,12 @@ export type CustomerIOPluginOptionsIOS = {
|
|
|
12
12
|
appleTeamId?: string;
|
|
13
13
|
appName?: string;
|
|
14
14
|
disableNotificationRegistration?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.
|
|
17
|
+
*/
|
|
15
18
|
handleNotificationClick?: boolean;
|
|
19
|
+
showPushAppInForeground?: boolean;
|
|
20
|
+
autoTrackPushEvents?: boolean;
|
|
16
21
|
handleDeeplinkInKilledState?: boolean;
|
|
17
22
|
useFrameworks?: 'static' | 'dynamic';
|
|
18
23
|
pushNotification?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "customerio-expo-plugin",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.15",
|
|
4
4
|
"description": "Expo config plugin for the Customer IO React Native SDK",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"registry": "https://registry.npmjs.org/"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"customerio-reactnative": "
|
|
43
|
+
"customerio-reactnative": ">=3.4.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@expo/config-plugins": "^4.1.4",
|
|
@@ -9,7 +9,7 @@ pluginPackageRoot = path.dirname(pluginPackageRoot);
|
|
|
9
9
|
export const LOCAL_PATH_TO_RN_SDK = path.join(
|
|
10
10
|
pluginPackageRoot,
|
|
11
11
|
'../customerio-reactnative'
|
|
12
|
-
)
|
|
12
|
+
);
|
|
13
13
|
|
|
14
14
|
export const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(
|
|
15
15
|
pluginPackageRoot,
|
|
@@ -42,20 +42,22 @@ export const CIO_APPDELEGATEDECLARATION_REGEX =
|
|
|
42
42
|
export const CIO_APPDELEGATEHEADER_REGEX =
|
|
43
43
|
/(@interface AppDelegate\s*:\s*EXAppDelegateWrapper\s*)(<([^>]+)>)?/;
|
|
44
44
|
|
|
45
|
-
export const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX =
|
|
46
|
-
/^\s*RCTBridge\s*\*\s*\w+\s*=\s*\[\s*self\.reactDelegate\s+createBridgeWithDelegate:self\s+launchOptions:launchOptions\s*\];\s*$/gm;
|
|
45
|
+
export const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX =
|
|
46
|
+
/^\s*RCTBridge\s*\*\s*\w+\s*=\s*\[\s*self\.reactDelegate\s+createBridgeWithDelegate:self\s+launchOptions:launchOptions\s*\];\s*$/gm;
|
|
47
47
|
|
|
48
|
-
export const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX =
|
|
49
|
-
/^\s*return\s\[\s*super\s*application:\s*application\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\];/gm;
|
|
48
|
+
export const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX =
|
|
49
|
+
/^\s*return\s\[\s*super\s*application:\s*application\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\];/gm;
|
|
50
50
|
|
|
51
|
-
export const CIO_DEEPLINK_COMMENT_REGEX =
|
|
51
|
+
export const CIO_DEEPLINK_COMMENT_REGEX =
|
|
52
|
+
/\sDeep link workaround for app killed state start/gm;
|
|
52
53
|
export const DEFAULT_BUNDLE_VERSION = '1';
|
|
53
54
|
export const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
|
|
54
55
|
export const CIO_TARGET_NAME = 'CustomerIOSDK';
|
|
55
56
|
export const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';
|
|
56
57
|
|
|
57
58
|
export const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;
|
|
58
|
-
export const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET =
|
|
59
|
+
export const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET =
|
|
60
|
+
'UNUserNotificationCenterDelegate';
|
|
59
61
|
export const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `
|
|
60
62
|
CIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];
|
|
61
63
|
`;
|
|
@@ -64,7 +66,7 @@ RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOpti
|
|
|
64
66
|
`;
|
|
65
67
|
|
|
66
68
|
export const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `
|
|
67
|
-
return [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions]
|
|
69
|
+
return [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`;
|
|
68
70
|
|
|
69
71
|
export const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `
|
|
70
72
|
[super application:application didFailToRegisterForRemoteNotificationsWithError:error];
|
|
@@ -81,9 +83,32 @@ export const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `
|
|
|
81
83
|
[pnHandlerObj registerPushNotification];
|
|
82
84
|
`;
|
|
83
85
|
|
|
84
|
-
export const
|
|
86
|
+
export const CIO_INITIALIZECIOSDK_SNIPPET = `
|
|
87
|
+
[pnHandlerObj initializeCioSdk];
|
|
88
|
+
|
|
89
|
+
// Code to make the CIO SDK compatible with expo-notifications package.
|
|
90
|
+
//
|
|
91
|
+
// The CIO SDK and expo-notifications both need to handle when a push gets clicked. However, iOS only allows one click handler to be set per app.
|
|
92
|
+
// To get around this limitation, we set the CIO SDK as the click handler. The CIO SDK sets itself up so that when another SDK or host iOS app
|
|
93
|
+
// sets itself as the click handler, the CIO SDK will still be able to handle when the push gets clicked, even though it's not the designated
|
|
94
|
+
// click handler in iOS at runtime.
|
|
95
|
+
//
|
|
96
|
+
// This should work for most SDKs. However, expo-notifications is unique in it's implementation. It will not setup push click handling it if detects
|
|
97
|
+
// that another SDK or host iOS app has already set itself as the click handler:
|
|
98
|
+
// https://github.com/expo/expo/blob/1b29637bec0b9888e8bc8c310476293a3e2d9786/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L31-L37
|
|
99
|
+
// ...to get around this, we must manually set it as the click handler after the CIO SDK. That's what this code block does.
|
|
100
|
+
//
|
|
101
|
+
// Note: Initialize the native iOS SDK and setup SDK push click handling before running this code.
|
|
102
|
+
# if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)
|
|
103
|
+
// Creating a new instance, as the comments in expo-notifications suggests, does not work. With this code, if you send a CIO push to device and click on it,
|
|
104
|
+
// no push metrics reporting will occur.
|
|
105
|
+
// EXNotificationCenterDelegate *notificationCenterDelegate = [[EXNotificationCenterDelegate alloc] init];
|
|
106
|
+
|
|
107
|
+
// ...instead, get the singleton reference from Expo.
|
|
108
|
+
id<UNUserNotificationCenterDelegate> notificationCenterDelegate = (id<UNUserNotificationCenterDelegate>) [EXModuleRegistryProvider getSingletonModuleForClass:[EXNotificationCenterDelegate class]];
|
|
85
109
|
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
86
|
-
center.delegate =
|
|
110
|
+
center.delegate = notificationCenterDelegate;
|
|
111
|
+
# endif
|
|
87
112
|
`;
|
|
88
113
|
|
|
89
114
|
export const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `
|
|
@@ -101,18 +126,6 @@ NSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWith
|
|
|
101
126
|
//Deep link workaround for app killed state ends
|
|
102
127
|
`;
|
|
103
128
|
|
|
104
|
-
// Enable push handling - notification response
|
|
105
|
-
export const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `
|
|
106
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
|
|
107
|
-
[pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
|
|
108
|
-
}`;
|
|
109
|
-
|
|
110
|
-
// Foreground push handling
|
|
111
|
-
export const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `
|
|
112
|
-
// show push when the app is in foreground
|
|
113
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
|
|
114
|
-
completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);
|
|
115
|
-
}`;
|
|
116
129
|
export const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `
|
|
117
130
|
@objc(registerPushNotification)
|
|
118
131
|
public func registerPushNotification() {
|
|
@@ -11,6 +11,20 @@ public class CIOAppPushNotificationsHandler : NSObject {
|
|
|
11
11
|
|
|
12
12
|
{{REGISTER_SNIPPET}}
|
|
13
13
|
|
|
14
|
+
@objc(initializeCioSdk)
|
|
15
|
+
public func initializeCioSdk() {
|
|
16
|
+
// Must initialize Customer.io before initializing MessagingPushAPN.
|
|
17
|
+
CustomerIO.initialize(siteId: "{{SITE_ID}}", apiKey: "{{API_KEY}}", region: .{{REGION}}) { config in
|
|
18
|
+
// Must configure auto track push events before initializing MessagingPushAPN.
|
|
19
|
+
// This is because after AppDelegate.didFinishLaunching is called, the app will start handling push click events.
|
|
20
|
+
// Configuring auto track push events after this point will not work.
|
|
21
|
+
config.autoTrackPushEvents = {{AUTO_TRACK_PUSH_EVENTS}}
|
|
22
|
+
}
|
|
23
|
+
MessagingPushAPN.initialize { config in
|
|
24
|
+
config.showPushAppInForeground = {{SHOW_PUSH_APP_IN_FOREGROUND}}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
@objc(application:deviceToken:)
|
|
15
29
|
public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
16
30
|
MessagingPush.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
|
|
@@ -20,16 +34,4 @@ public class CIOAppPushNotificationsHandler : NSObject {
|
|
|
20
34
|
public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
|
21
35
|
MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
|
|
22
36
|
}
|
|
23
|
-
|
|
24
|
-
@objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)
|
|
25
|
-
public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
|
26
|
-
let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
|
|
27
|
-
withCompletionHandler: completionHandler)
|
|
28
|
-
|
|
29
|
-
// If the Customer.io SDK does not handle the push, it's up to you to handle it and call the
|
|
30
|
-
// completion handler. If the SDK did handle it, it called the completion handler for you.
|
|
31
|
-
if !handled {
|
|
32
|
-
completionHandler()
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
37
|
}
|
|
@@ -19,7 +19,9 @@ export async function injectCIOPodfileCode(iosPath: string) {
|
|
|
19
19
|
|
|
20
20
|
const snippetToInjectInPodfile = `
|
|
21
21
|
${blockStart}
|
|
22
|
-
pod 'customerio-reactnative/apn', :path => '${getRelativePathToRNSDK(
|
|
22
|
+
pod 'customerio-reactnative/apn', :path => '${getRelativePathToRNSDK(
|
|
23
|
+
filename
|
|
24
|
+
)}'
|
|
23
25
|
${blockEnd}
|
|
24
26
|
`.trim();
|
|
25
27
|
|
|
@@ -53,7 +55,9 @@ export async function injectCIONotificationPodfileCode(
|
|
|
53
55
|
${blockStart}
|
|
54
56
|
target 'NotificationService' do
|
|
55
57
|
${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}
|
|
56
|
-
pod 'customerio-reactnative-richpush/apn', :path => '${getRelativePathToRNSDK(
|
|
58
|
+
pod 'customerio-reactnative-richpush/apn', :path => '${getRelativePathToRNSDK(
|
|
59
|
+
filename
|
|
60
|
+
)}'
|
|
57
61
|
end
|
|
58
62
|
${blockEnd}
|
|
59
63
|
`.trim();
|
|
@@ -7,22 +7,19 @@ import {
|
|
|
7
7
|
CIO_APPDELEGATEHEADER_REGEX,
|
|
8
8
|
CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET,
|
|
9
9
|
CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,
|
|
10
|
-
CIO_CONFIGURECIOSDKUSERNOTIFICATIONCENTER_SNIPPET,
|
|
11
10
|
CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,
|
|
12
|
-
CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,
|
|
13
11
|
CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX,
|
|
14
12
|
CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,
|
|
15
13
|
CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,
|
|
16
14
|
CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,
|
|
17
|
-
CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,
|
|
18
15
|
CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,
|
|
19
16
|
CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,
|
|
20
17
|
CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX,
|
|
21
18
|
CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,
|
|
22
|
-
CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,
|
|
23
19
|
CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET,
|
|
24
20
|
CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET,
|
|
25
21
|
CIO_DEEPLINK_COMMENT_REGEX,
|
|
22
|
+
CIO_INITIALIZECIOSDK_SNIPPET,
|
|
26
23
|
} from '../helpers/constants/ios';
|
|
27
24
|
import {
|
|
28
25
|
injectCodeBeforeMultiLineRegex,
|
|
@@ -30,20 +27,11 @@ import {
|
|
|
30
27
|
injectCodeByMultiLineRegex,
|
|
31
28
|
injectCodeByMultiLineRegexAndReplaceLine,
|
|
32
29
|
replaceCodeByRegex,
|
|
33
|
-
matchRegexExists
|
|
30
|
+
matchRegexExists,
|
|
34
31
|
} from '../helpers/utils/codeInjection';
|
|
35
32
|
import { FileManagement } from '../helpers/utils/fileManagement';
|
|
36
33
|
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
37
34
|
|
|
38
|
-
const pushCodeSnippets = [
|
|
39
|
-
CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,
|
|
40
|
-
CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
const additionalMethodsForPushNotifications = `${pushCodeSnippets.join(
|
|
44
|
-
'\n'
|
|
45
|
-
)}\n`; // Join newlines and ensure a newline at the end.
|
|
46
|
-
|
|
47
35
|
const addImport = (stringContents: string, appName: string) => {
|
|
48
36
|
const importRegex = /^(#import .*)\n/gm;
|
|
49
37
|
const addedImport = getImportSnippet(appName);
|
|
@@ -62,7 +50,7 @@ const addImport = (stringContents: string, appName: string) => {
|
|
|
62
50
|
stringContents,
|
|
63
51
|
endOfMatchIndex,
|
|
64
52
|
addedImport
|
|
65
|
-
)
|
|
53
|
+
);
|
|
66
54
|
|
|
67
55
|
return stringContents;
|
|
68
56
|
};
|
|
@@ -87,17 +75,20 @@ const addNotificationConfiguration = (stringContents: string) => {
|
|
|
87
75
|
return stringContents;
|
|
88
76
|
};
|
|
89
77
|
|
|
90
|
-
const
|
|
78
|
+
const addInitializeNativeCioSdk = (stringContents: string) => {
|
|
91
79
|
stringContents = injectCodeBeforeMultiLineRegex(
|
|
92
80
|
stringContents,
|
|
93
81
|
CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,
|
|
94
|
-
|
|
82
|
+
CIO_INITIALIZECIOSDK_SNIPPET
|
|
95
83
|
);
|
|
96
84
|
|
|
97
85
|
return stringContents;
|
|
98
86
|
};
|
|
99
87
|
|
|
100
|
-
const addHandleDeeplinkInKilledStateConfiguration = (
|
|
88
|
+
const addHandleDeeplinkInKilledStateConfiguration = (
|
|
89
|
+
stringContents: string,
|
|
90
|
+
regex: RegExp
|
|
91
|
+
) => {
|
|
101
92
|
stringContents = injectCodeBeforeMultiLineRegex(
|
|
102
93
|
stringContents,
|
|
103
94
|
regex,
|
|
@@ -131,11 +122,17 @@ const addDidRegisterForRemoteNotificationsWithDeviceToken = (
|
|
|
131
122
|
return stringContents;
|
|
132
123
|
};
|
|
133
124
|
|
|
134
|
-
|
|
135
|
-
|
|
125
|
+
// Adds required import for Expo Notifications package in AppDelegate.
|
|
126
|
+
// Required to call functions from the package.
|
|
127
|
+
const addExpoNotificationsHeaderModification = (stringContents: string) => {
|
|
128
|
+
stringContents = injectCodeByLineNumber(
|
|
136
129
|
stringContents,
|
|
137
|
-
|
|
138
|
-
|
|
130
|
+
0,
|
|
131
|
+
`
|
|
132
|
+
#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)
|
|
133
|
+
#import <EXNotifications/EXNotificationCenterDelegate.h>
|
|
134
|
+
#endif
|
|
135
|
+
`
|
|
139
136
|
);
|
|
140
137
|
|
|
141
138
|
return stringContents;
|
|
@@ -146,7 +143,12 @@ const addAppdelegateHeaderModification = (stringContents: string) => {
|
|
|
146
143
|
stringContents = stringContents.replace(
|
|
147
144
|
CIO_APPDELEGATEHEADER_REGEX,
|
|
148
145
|
(match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {
|
|
149
|
-
if (
|
|
146
|
+
if (
|
|
147
|
+
existingDelegates &&
|
|
148
|
+
existingDelegates.includes(
|
|
149
|
+
CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET
|
|
150
|
+
)
|
|
151
|
+
) {
|
|
150
152
|
// The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it
|
|
151
153
|
return match;
|
|
152
154
|
} else if (existingDelegates) {
|
|
@@ -169,26 +171,38 @@ ${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER
|
|
|
169
171
|
const addHandleDeeplinkInKilledState = (stringContents: string) => {
|
|
170
172
|
// Find if the deep link code snippet is already present
|
|
171
173
|
if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {
|
|
172
|
-
return stringContents
|
|
174
|
+
return stringContents;
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
// Check if the app delegate is using RCTBridge or LaunchOptions
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
178
|
+
let snippet = undefined;
|
|
179
|
+
let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
180
|
+
if (
|
|
181
|
+
matchRegexExists(
|
|
182
|
+
stringContents,
|
|
183
|
+
CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX
|
|
184
|
+
)
|
|
185
|
+
) {
|
|
179
186
|
snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;
|
|
180
187
|
regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
181
|
-
}
|
|
182
|
-
|
|
188
|
+
} else if (
|
|
189
|
+
matchRegexExists(
|
|
190
|
+
stringContents,
|
|
191
|
+
CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX
|
|
192
|
+
)
|
|
193
|
+
) {
|
|
183
194
|
snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;
|
|
184
195
|
}
|
|
185
196
|
// Add code only if the app delegate is using RCTBridge or LaunchOptions
|
|
186
197
|
if (snippet !== undefined) {
|
|
187
|
-
|
|
188
|
-
|
|
198
|
+
stringContents = addHandleDeeplinkInKilledStateConfiguration(
|
|
199
|
+
stringContents,
|
|
200
|
+
regex
|
|
201
|
+
);
|
|
202
|
+
stringContents = replaceCodeByRegex(stringContents, regex, snippet);
|
|
189
203
|
}
|
|
190
|
-
return stringContents
|
|
191
|
-
}
|
|
204
|
+
return stringContents;
|
|
205
|
+
};
|
|
192
206
|
|
|
193
207
|
export const withAppDelegateModifications: ConfigPlugin<
|
|
194
208
|
CustomerIOPluginOptionsIOS
|
|
@@ -221,12 +235,8 @@ export const withAppDelegateModifications: ConfigPlugin<
|
|
|
221
235
|
) {
|
|
222
236
|
stringContents = addNotificationConfiguration(stringContents);
|
|
223
237
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
props.handleNotificationClick === true
|
|
227
|
-
) {
|
|
228
|
-
stringContents = addUserNotificationCenterConfiguration(stringContents);
|
|
229
|
-
}
|
|
238
|
+
|
|
239
|
+
stringContents = addInitializeNativeCioSdk(stringContents);
|
|
230
240
|
|
|
231
241
|
if (
|
|
232
242
|
props.handleDeeplinkInKilledState !== undefined &&
|
|
@@ -234,13 +244,14 @@ export const withAppDelegateModifications: ConfigPlugin<
|
|
|
234
244
|
) {
|
|
235
245
|
stringContents = addHandleDeeplinkInKilledState(stringContents);
|
|
236
246
|
}
|
|
237
|
-
|
|
238
|
-
stringContents = addAdditionalMethodsForPushNotifications(stringContents);
|
|
247
|
+
|
|
239
248
|
stringContents =
|
|
240
249
|
addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
|
|
241
250
|
stringContents =
|
|
242
251
|
addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
|
|
243
252
|
|
|
253
|
+
stringContents = addExpoNotificationsHeaderModification(stringContents);
|
|
254
|
+
|
|
244
255
|
config.modResults.contents = stringContents;
|
|
245
256
|
} else {
|
|
246
257
|
console.log('Customerio AppDelegate changes already exist. Skipping...');
|
|
@@ -234,7 +234,7 @@ const addRichPushXcodeProj = async (
|
|
|
234
234
|
const buildSettingsObj = configurations[key].buildSettings;
|
|
235
235
|
buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
|
|
236
236
|
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =
|
|
237
|
-
iosDeploymentTarget || '13.
|
|
237
|
+
iosDeploymentTarget || '13.4';
|
|
238
238
|
buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
|
|
239
239
|
buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
|
|
240
240
|
buildSettingsObj.SWIFT_VERSION = 4.2;
|
|
@@ -374,8 +374,43 @@ const updatePushFile = (
|
|
|
374
374
|
) {
|
|
375
375
|
snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;
|
|
376
376
|
}
|
|
377
|
-
|
|
378
377
|
envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);
|
|
379
378
|
|
|
379
|
+
if (options.pushNotification) {
|
|
380
|
+
envFileContent = replaceCodeByRegex(
|
|
381
|
+
envFileContent,
|
|
382
|
+
/\{\{SITE_ID\}\}/,
|
|
383
|
+
options.pushNotification.env.siteId
|
|
384
|
+
);
|
|
385
|
+
envFileContent = replaceCodeByRegex(
|
|
386
|
+
envFileContent,
|
|
387
|
+
/\{\{API_KEY\}\}/,
|
|
388
|
+
options.pushNotification.env.apiKey
|
|
389
|
+
);
|
|
390
|
+
envFileContent = replaceCodeByRegex(
|
|
391
|
+
envFileContent,
|
|
392
|
+
/\{\{REGION\}\}/,
|
|
393
|
+
options.pushNotification.env.region.toUpperCase()
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const autoTrackPushEvents =
|
|
398
|
+
options.autoTrackPushEvents === undefined ||
|
|
399
|
+
options.autoTrackPushEvents === true;
|
|
400
|
+
envFileContent = replaceCodeByRegex(
|
|
401
|
+
envFileContent,
|
|
402
|
+
/\{\{AUTO_TRACK_PUSH_EVENTS\}\}/,
|
|
403
|
+
autoTrackPushEvents.toString()
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
const showPushAppInForeground =
|
|
407
|
+
options.showPushAppInForeground === undefined ||
|
|
408
|
+
options.showPushAppInForeground === true;
|
|
409
|
+
envFileContent = replaceCodeByRegex(
|
|
410
|
+
envFileContent,
|
|
411
|
+
/\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/,
|
|
412
|
+
showPushAppInForeground.toString()
|
|
413
|
+
);
|
|
414
|
+
|
|
380
415
|
FileManagement.writeFile(envFileName, envFileContent);
|
|
381
416
|
};
|
package/src/types/cio-types.ts
CHANGED
|
@@ -16,8 +16,13 @@ export type CustomerIOPluginOptionsIOS = {
|
|
|
16
16
|
appleTeamId?: string;
|
|
17
17
|
appName?: string;
|
|
18
18
|
disableNotificationRegistration?: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.
|
|
21
|
+
*/
|
|
22
|
+
handleNotificationClick?: boolean;
|
|
23
|
+
showPushAppInForeground?: boolean;
|
|
24
|
+
autoTrackPushEvents?: boolean;
|
|
25
|
+
handleDeeplinkInKilledState?: boolean;
|
|
21
26
|
useFrameworks?: 'static' | 'dynamic';
|
|
22
27
|
pushNotification?: {
|
|
23
28
|
useRichPush: boolean;
|