customerio-expo-plugin 1.0.0-beta.12 → 1.0.0-beta.14
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 +74 -66
- 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 +9 -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 +63 -9
- package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/lib/commonjs/ios/withNotificationsXcodeProject.js +9 -0
- 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 +54 -22
- 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 +7 -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 +65 -11
- package/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/lib/module/ios/withNotificationsXcodeProject.js +9 -0
- 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 +11 -5
- package/lib/typescript/helpers/utils/codeInjection.d.ts +3 -1
- package/lib/typescript/types/cio-types.d.ts +7 -0
- package/package.json +2 -2
- package/src/helpers/constants/ios.ts +67 -24
- package/src/helpers/native-files/ios/PushService.swift +14 -12
- package/src/helpers/utils/codeInjection.ts +12 -1
- package/src/helpers/utils/injectCIOPodfileCode.ts +6 -2
- package/src/ios/withAppDelegateModifications.ts +118 -23
- package/src/ios/withNotificationsXcodeProject.ts +36 -1
- package/src/types/cio-types.ts +7 -0
|
@@ -241,6 +241,15 @@ const updatePushFile = (options, envFileName) => {
|
|
|
241
241
|
snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;
|
|
242
242
|
}
|
|
243
243
|
envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);
|
|
244
|
+
if (options.pushNotification) {
|
|
245
|
+
envFileContent = replaceCodeByRegex(envFileContent, /\{\{SITE_ID\}\}/, options.pushNotification.env.siteId);
|
|
246
|
+
envFileContent = replaceCodeByRegex(envFileContent, /\{\{API_KEY\}\}/, options.pushNotification.env.apiKey);
|
|
247
|
+
envFileContent = replaceCodeByRegex(envFileContent, /\{\{REGION\}\}/, options.pushNotification.env.region.toUpperCase());
|
|
248
|
+
}
|
|
249
|
+
const autoTrackPushEvents = options.autoTrackPushEvents === undefined || options.autoTrackPushEvents === true;
|
|
250
|
+
envFileContent = replaceCodeByRegex(envFileContent, /\{\{AUTO_TRACK_PUSH_EVENTS\}\}/, autoTrackPushEvents.toString());
|
|
251
|
+
const showPushAppInForeground = options.showPushAppInForeground === undefined || options.showPushAppInForeground === true;
|
|
252
|
+
envFileContent = replaceCodeByRegex(envFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
|
|
244
253
|
FileManagement.writeFile(envFileName, envFileContent);
|
|
245
254
|
};
|
|
246
255
|
//# sourceMappingURL=withNotificationsXcodeProject.js.map
|
|
@@ -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(envFile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AAE,GAAEjE,aAAa,CAAC8D,IAAI,CAAE,8BAA6B,CAAC;IACjE;EACF;EAEAI,cAAc,CAACvG,OAAO,EAAEwC,UAAU,CAAC;EAEnC,MAAMgE,KAAK,GAAGvG,YAAY,CAACwG,cAAc,CAAC,yBAAyB,CAAC;EACpE,MAAMC,UAAU,GAAGzG,YAAY,CAAC0G,eAAe,CAAC;IAAErD,IAAI,EAAG,GAAE1B,OAAQ;EAAE,CAAC,CAAC;EACvE3B,YAAY,CAACuD,aAAa,CAACgD,KAAK,EAAEE,UAAU,CAAC;EAE7CzG,YAAY,CAAC2G,aAAa,CAAE,GAAEhF,OAAQ,IAAGuE,IAAK,EAAC,EAAE,IAAI,EAAEK,KAAK,CAAC;AAC/D;AAEA,MAAMD,cAAc,GAAGA,CACrBvG,OAAmC,EACnC8E,WAAmB,KAChB;EACH,MAAM+B,WAAW,GAAG,0BAA0B;EAE9C,IAAIxB,cAAc,GAAG1F,cAAc,CAACiF,QAAQ,CAACE,WAAW,CAAC;EAEzD,IAAIgC,OAAO,GAAG,EAAE;EAChB,IACE9G,OAAO,CAAC+G,+BAA+B,KAAK3F,SAAS,IACrDpB,OAAO,CAAC+G,+BAA+B,KAAK,KAAK,EACjD;IACAD,OAAO,GAAGxH,qCAAqC;EACjD;EAEA+F,cAAc,GAAG5F,kBAAkB,CAAC4F,cAAc,EAAEwB,WAAW,EAAEC,OAAO,CAAC;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.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 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;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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,CAAC+G,+BAA+B,KAAK,KAAK,EACjD;IACAD,OAAO,GAAGxH,qCAAqC;EACjD;EACA+F,cAAc,GAAG5F,kBAAkB,CAAC4F,cAAc,EAAEwB,WAAW,EAAEC,OAAO,CAAC;EAEzE,IAAI9G,OAAO,CAACG,gBAAgB,EAAE;IAC5BkF,cAAc,GAAG5F,kBAAkB,CACjC4F,cAAc,EACd,iBAAiB,EACjBrF,OAAO,CAACG,gBAAgB,CAACmF,GAAG,CAACC,MAC/B,CAAC;IACDF,cAAc,GAAG5F,kBAAkB,CACjC4F,cAAc,EACd,iBAAiB,EACjBrF,OAAO,CAACG,gBAAgB,CAACmF,GAAG,CAACG,MAC/B,CAAC;IACDJ,cAAc,GAAG5F,kBAAkB,CACjC4F,cAAc,EACd,gBAAgB,EAChBrF,OAAO,CAACG,gBAAgB,CAACmF,GAAG,CAACK,MAAM,CAACqB,WAAW,CAAC,CAClD,CAAC;EACH;EAEA,MAAMC,mBAAmB,GACvBjH,OAAO,CAACiH,mBAAmB,KAAK7F,SAAS,IACzCpB,OAAO,CAACiH,mBAAmB,KAAK,IAAI;EACtC5B,cAAc,GAAG5F,kBAAkB,CACjC4F,cAAc,EACd,gCAAgC,EAChC4B,mBAAmB,CAACC,QAAQ,CAAC,CAC/B,CAAC;EAED,MAAMC,uBAAuB,GAC3BnH,OAAO,CAACmH,uBAAuB,KAAK/F,SAAS,IAC7CpB,OAAO,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 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":""}
|
|
@@ -11,15 +11,21 @@ export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_RE
|
|
|
11
11
|
export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX: RegExp;
|
|
12
12
|
export declare const CIO_APPDELEGATEDECLARATION_REGEX: RegExp;
|
|
13
13
|
export declare const CIO_APPDELEGATEHEADER_REGEX: RegExp;
|
|
14
|
+
export declare const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX: RegExp;
|
|
15
|
+
export declare const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX: RegExp;
|
|
16
|
+
export declare const CIO_DEEPLINK_COMMENT_REGEX: RegExp;
|
|
14
17
|
export declare const DEFAULT_BUNDLE_VERSION = "1";
|
|
15
18
|
export declare const DEFAULT_BUNDLE_SHORT_VERSION = "1.0";
|
|
16
19
|
export declare const CIO_TARGET_NAME = "CustomerIOSDK";
|
|
17
20
|
export declare const CIO_NOTIFICATION_TARGET_NAME = "NotificationService";
|
|
18
|
-
export declare const
|
|
21
|
+
export declare const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = "#import <UserNotifications/UserNotifications.h>";
|
|
22
|
+
export declare const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = "UNUserNotificationCenterDelegate";
|
|
19
23
|
export declare const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = "\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n";
|
|
24
|
+
export declare const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = "\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n";
|
|
25
|
+
export declare const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = "\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];";
|
|
20
26
|
export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = "\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n";
|
|
21
27
|
export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = "\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n";
|
|
22
|
-
export declare const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = "\n // Register for push notifications\n [pnHandlerObj registerPushNotification
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const
|
|
25
|
-
export declare const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = "\n@objc(registerPushNotification
|
|
28
|
+
export declare const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = "\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n";
|
|
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
|
+
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_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 }";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare function injectCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string[];
|
|
2
2
|
export declare function injectCodeByMultiLineRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
3
|
+
export declare function injectCodeBeforeMultiLineRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
3
4
|
export declare function replaceCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
5
|
+
export declare function matchRegexExists(fileContent: string, regex: RegExp): boolean;
|
|
4
6
|
export declare function injectCodeByMultiLineRegexAndReplaceLine(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
5
|
-
export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string
|
|
7
|
+
export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string;
|
|
@@ -12,6 +12,13 @@ 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
|
+
*/
|
|
18
|
+
handleNotificationClick?: boolean;
|
|
19
|
+
showPushAppInForeground?: boolean;
|
|
20
|
+
autoTrackPushEvents?: boolean;
|
|
21
|
+
handleDeeplinkInKilledState?: boolean;
|
|
15
22
|
useFrameworks?: 'static' | 'dynamic';
|
|
16
23
|
pushNotification?: {
|
|
17
24
|
useRichPush: boolean;
|
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.14",
|
|
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,
|
|
@@ -25,7 +25,7 @@ export const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
|
|
|
25
25
|
export const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
|
|
26
26
|
export const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
|
|
27
27
|
export const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =
|
|
28
|
-
|
|
28
|
+
/.*\[super(\s)application:application(\s)didFinishLaunchingWithOptions:launchOptions\];/;
|
|
29
29
|
|
|
30
30
|
export const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =
|
|
31
31
|
/return \[super application:application didFailToRegisterForRemoteNotificationsWithError:error\];/;
|
|
@@ -40,20 +40,33 @@ export const CIO_APPDELEGATEDECLARATION_REGEX =
|
|
|
40
40
|
/@implementation AppDelegate(.|\n)/;
|
|
41
41
|
|
|
42
42
|
export const CIO_APPDELEGATEHEADER_REGEX =
|
|
43
|
-
|
|
43
|
+
/(@interface AppDelegate\s*:\s*EXAppDelegateWrapper\s*)(<([^>]+)>)?/;
|
|
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;
|
|
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;
|
|
50
|
+
|
|
51
|
+
export const CIO_DEEPLINK_COMMENT_REGEX =
|
|
52
|
+
/\sDeep link workaround for app killed state start/gm;
|
|
44
53
|
export const DEFAULT_BUNDLE_VERSION = '1';
|
|
45
54
|
export const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
|
|
46
55
|
export const CIO_TARGET_NAME = 'CustomerIOSDK';
|
|
47
56
|
export const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';
|
|
48
|
-
export const CIO_APPDELEGATEHEADER_SNIPPET = `
|
|
49
|
-
#import <UserNotifications/UserNotifications.h>
|
|
50
|
-
|
|
51
|
-
@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>
|
|
52
|
-
`;
|
|
53
57
|
|
|
58
|
+
export const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;
|
|
59
|
+
export const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET =
|
|
60
|
+
'UNUserNotificationCenterDelegate';
|
|
54
61
|
export const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `
|
|
55
62
|
CIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];
|
|
56
63
|
`;
|
|
64
|
+
export const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `
|
|
65
|
+
RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
export const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `
|
|
69
|
+
return [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`;
|
|
57
70
|
|
|
58
71
|
export const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `
|
|
59
72
|
[super application:application didFailToRegisterForRemoteNotificationsWithError:error];
|
|
@@ -67,27 +80,57 @@ export const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `
|
|
|
67
80
|
|
|
68
81
|
export const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `
|
|
69
82
|
// Register for push notifications
|
|
70
|
-
[pnHandlerObj registerPushNotification
|
|
83
|
+
[pnHandlerObj registerPushNotification];
|
|
84
|
+
`;
|
|
85
|
+
|
|
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]];
|
|
109
|
+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
110
|
+
center.delegate = notificationCenterDelegate;
|
|
111
|
+
# endif
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
export const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `
|
|
115
|
+
// Deep link workaround for app killed state start
|
|
116
|
+
NSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];
|
|
117
|
+
if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
|
118
|
+
NSDictionary *pushContent = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
|
|
119
|
+
if (pushContent[@"CIO"] && pushContent[@"CIO"][@"push"] && pushContent[@"CIO"][@"push"][@"link"]) {
|
|
120
|
+
NSString *initialURL = pushContent[@"CIO"][@"push"][@"link"];
|
|
121
|
+
if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {
|
|
122
|
+
modifiedLaunchOptions[UIApplicationLaunchOptionsURLKey] = [NSURL URLWithString:initialURL];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//Deep link workaround for app killed state ends
|
|
71
127
|
`;
|
|
72
128
|
|
|
73
|
-
// Enable push handling - notification response
|
|
74
|
-
export const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `
|
|
75
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
|
|
76
|
-
[pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
|
|
77
|
-
}`;
|
|
78
|
-
|
|
79
|
-
// Foreground push handling
|
|
80
|
-
export const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `
|
|
81
|
-
// show push when the app is in foreground
|
|
82
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
|
|
83
|
-
completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);
|
|
84
|
-
}`;
|
|
85
129
|
export const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `
|
|
86
|
-
@objc(registerPushNotification
|
|
87
|
-
public func registerPushNotification(
|
|
130
|
+
@objc(registerPushNotification)
|
|
131
|
+
public func registerPushNotification() {
|
|
88
132
|
|
|
89
133
|
let center = UNUserNotificationCenter.current()
|
|
90
|
-
center.delegate = notificationDelegate
|
|
91
134
|
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
|
|
92
135
|
if error == nil{
|
|
93
136
|
DispatchQueue.main.async {
|
|
@@ -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
|
}
|
|
@@ -22,6 +22,14 @@ export function injectCodeByMultiLineRegex(
|
|
|
22
22
|
return fileContent.replace(lineRegex, `$&\n${snippet}`);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export function injectCodeBeforeMultiLineRegex(
|
|
26
|
+
fileContent: string,
|
|
27
|
+
lineRegex: RegExp,
|
|
28
|
+
snippet: string
|
|
29
|
+
) {
|
|
30
|
+
return fileContent.replace(lineRegex, `${snippet}\n$&`);
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
export function replaceCodeByRegex(
|
|
26
34
|
fileContent: string,
|
|
27
35
|
lineRegex: RegExp,
|
|
@@ -30,6 +38,9 @@ export function replaceCodeByRegex(
|
|
|
30
38
|
return fileContent.replace(lineRegex, snippet);
|
|
31
39
|
}
|
|
32
40
|
|
|
41
|
+
export function matchRegexExists(fileContent: string, regex: RegExp) {
|
|
42
|
+
return regex.test(fileContent);
|
|
43
|
+
}
|
|
33
44
|
export function injectCodeByMultiLineRegexAndReplaceLine(
|
|
34
45
|
fileContent: string,
|
|
35
46
|
lineRegex: RegExp,
|
|
@@ -50,5 +61,5 @@ export function injectCodeByLineNumber(
|
|
|
50
61
|
content = [...lines.slice(0, index), snippet, ...lines.slice(index)];
|
|
51
62
|
}
|
|
52
63
|
|
|
53
|
-
return content;
|
|
64
|
+
return content.join('\n');
|
|
54
65
|
}
|
|
@@ -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();
|