customerio-expo-plugin 2.0.0-beta.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -5
- package/plugin/{src/helpers/native-files/ios → lib/commonjs/helpers/native-files/ios/apn}/PushService.swift +1 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/fcm/PushService.swift +59 -0
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +4 -4
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/ios/utils.js +17 -0
- package/plugin/lib/commonjs/ios/utils.js.map +1 -0
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +8 -0
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js +2 -0
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +68 -0
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -0
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +29 -11
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js +2 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
- package/plugin/lib/{commonjs/helpers/native-files/ios → module/helpers/native-files/ios/apn}/PushService.swift +1 -0
- package/plugin/lib/module/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
- package/plugin/lib/module/helpers/native-files/ios/fcm/PushService.swift +59 -0
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +4 -4
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/ios/utils.js +10 -0
- package/plugin/lib/module/ios/utils.js.map +1 -0
- package/plugin/lib/module/ios/withAppDelegateModifications.js +8 -0
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIos.js +2 -0
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +61 -0
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -0
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +29 -11
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/ios/withXcodeProject.js +2 -1
- package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/module/types/cio-types.js.map +1 -1
- package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -2
- package/plugin/lib/typescript/ios/utils.d.ts +7 -0
- package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +3 -0
- package/plugin/lib/typescript/types/cio-types.d.ts +3 -0
- package/plugin/{lib/module/helpers/native-files/ios → src/helpers/native-files/ios/apn}/PushService.swift +1 -0
- package/plugin/src/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
- package/plugin/src/helpers/native-files/ios/fcm/PushService.swift +59 -0
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +5 -4
- package/plugin/src/ios/utils.ts +10 -0
- package/plugin/src/ios/withAppDelegateModifications.ts +15 -0
- package/plugin/src/ios/withCIOIos.ts +2 -0
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +97 -0
- package/plugin/src/ios/withNotificationsXcodeProject.ts +40 -12
- package/plugin/src/ios/withXcodeProject.ts +2 -1
- package/plugin/src/types/cio-types.ts +3 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService.swift → apn/NotificationService.swift} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{Env.swift → common/Env.swift} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService-Info.plist → common/NotificationService-Info.plist} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService.h → common/NotificationService.h} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService.m → common/NotificationService.m} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService.swift → apn/NotificationService.swift} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{Env.swift → common/Env.swift} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService-Info.plist → common/NotificationService-Info.plist} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService.h → common/NotificationService.h} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService.m → common/NotificationService.m} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService.swift → apn/NotificationService.swift} +0 -0
- /package/plugin/src/helpers/native-files/ios/{Env.swift → common/Env.swift} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService-Info.plist → common/NotificationService-Info.plist} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService.h → common/NotificationService.h} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService.m → common/NotificationService.m} +0 -0
|
@@ -3,6 +3,7 @@ import { CIO_NOTIFICATION_TARGET_NAME, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET, DE
|
|
|
3
3
|
import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
|
|
4
4
|
import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
|
|
5
5
|
import { FileManagement } from './../helpers/utils/fileManagement';
|
|
6
|
+
import { isFcmPushProvider } from './utils';
|
|
6
7
|
const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
|
|
7
8
|
const ENV_FILENAME = 'Env.swift';
|
|
8
9
|
const TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
@@ -83,7 +84,8 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
83
84
|
iosDeploymentTarget,
|
|
84
85
|
useFrameworks
|
|
85
86
|
} = options;
|
|
86
|
-
|
|
87
|
+
const isFcmProvider = isFcmPushProvider(options);
|
|
88
|
+
await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);
|
|
87
89
|
|
|
88
90
|
// Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project
|
|
89
91
|
// If true then skip creating a new group to avoid duplicate folders
|
|
@@ -95,11 +97,19 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
95
97
|
FileManagement.mkdir(nsePath, {
|
|
96
98
|
recursive: true
|
|
97
99
|
});
|
|
98
|
-
const
|
|
100
|
+
const platformSpecificFiles = ['NotificationService.swift'];
|
|
101
|
+
const commonFiles = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.m', ENV_FILENAME];
|
|
99
102
|
const getTargetFile = filename => `${nsePath}/${filename}`;
|
|
100
|
-
|
|
103
|
+
// Copy platform-specific files
|
|
104
|
+
platformSpecificFiles.forEach(filename => {
|
|
101
105
|
const targetFile = getTargetFile(filename);
|
|
102
|
-
FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
|
|
106
|
+
FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${isFcmProvider ? "fcm" : "apn"}/${filename}`, targetFile);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Copy common files
|
|
110
|
+
commonFiles.forEach(filename => {
|
|
111
|
+
const targetFile = getTargetFile(filename);
|
|
112
|
+
FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/common/${filename}`, targetFile);
|
|
103
113
|
});
|
|
104
114
|
|
|
105
115
|
/* MODIFY COPIED EXTENSION FILES */
|
|
@@ -112,7 +122,9 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
112
122
|
updateNseEnv(options, getTargetFile(ENV_FILENAME));
|
|
113
123
|
|
|
114
124
|
// Create new PBXGroup for the extension
|
|
115
|
-
const extGroup = xcodeProject.addPbxGroup(
|
|
125
|
+
const extGroup = xcodeProject.addPbxGroup([...platformSpecificFiles, ...commonFiles],
|
|
126
|
+
// Combine platform-specific and common files,
|
|
127
|
+
CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
|
|
116
128
|
|
|
117
129
|
// Add the new PBXGroup to the top level group. This makes the
|
|
118
130
|
// files / folder appear in the file explorer in Xcode.
|
|
@@ -200,24 +212,28 @@ const updateNseEnv = (options, envFileName) => {
|
|
|
200
212
|
FileManagement.writeFile(envFileName, envFileContent);
|
|
201
213
|
};
|
|
202
214
|
async function addPushNotificationFile(options, xcodeProject) {
|
|
215
|
+
// Maybe copy a different file with FCM config based on config
|
|
203
216
|
const {
|
|
204
217
|
iosPath,
|
|
205
218
|
appName
|
|
206
219
|
} = options;
|
|
207
|
-
const
|
|
220
|
+
const isFcmProvider = isFcmPushProvider(options);
|
|
221
|
+
// PushService.swift is platform-specific and always lives in the platform folder
|
|
222
|
+
const sourceFile = `${isFcmProvider ? "fcm" : "apn"}/PushService.swift`;
|
|
223
|
+
const targetFileName = 'PushService.swift';
|
|
208
224
|
const appPath = `${iosPath}/${appName}`;
|
|
209
225
|
const getTargetFile = filename => `${appPath}/${filename}`;
|
|
210
|
-
const targetFile = getTargetFile(
|
|
226
|
+
const targetFile = getTargetFile(targetFileName);
|
|
211
227
|
|
|
212
228
|
// Check whether {file} exists in the project. If false, then add the file
|
|
213
229
|
// If {file} exists then skip and return
|
|
214
|
-
if (!FileManagement.exists(getTargetFile(
|
|
230
|
+
if (!FileManagement.exists(getTargetFile(targetFileName))) {
|
|
215
231
|
FileManagement.mkdir(appPath, {
|
|
216
232
|
recursive: true
|
|
217
233
|
});
|
|
218
|
-
FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${
|
|
234
|
+
FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${sourceFile}`, targetFile);
|
|
219
235
|
} else {
|
|
220
|
-
console.log(`${getTargetFile(
|
|
236
|
+
console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);
|
|
221
237
|
return;
|
|
222
238
|
}
|
|
223
239
|
updatePushFile(options, targetFile);
|
|
@@ -226,7 +242,7 @@ async function addPushNotificationFile(options, xcodeProject) {
|
|
|
226
242
|
name: `${appName}`
|
|
227
243
|
});
|
|
228
244
|
xcodeProject.addToPbxGroup(group, classesKey);
|
|
229
|
-
xcodeProject.addSourceFile(`${appName}/${
|
|
245
|
+
xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);
|
|
230
246
|
}
|
|
231
247
|
const updatePushFile = (options, envFileName) => {
|
|
232
248
|
const REGISTER_RE = /\{\{REGISTER_SNIPPET\}\}/;
|
|
@@ -242,6 +258,8 @@ const updatePushFile = (options, envFileName) => {
|
|
|
242
258
|
}
|
|
243
259
|
const autoTrackPushEvents = options.autoTrackPushEvents === undefined || options.autoTrackPushEvents === true;
|
|
244
260
|
envFileContent = replaceCodeByRegex(envFileContent, /\{\{AUTO_TRACK_PUSH_EVENTS\}\}/, autoTrackPushEvents.toString());
|
|
261
|
+
const autoFetchDeviceToken = options.autoFetchDeviceToken === undefined || options.autoFetchDeviceToken === true;
|
|
262
|
+
envFileContent = replaceCodeByRegex(envFileContent, /\{\{AUTO_FETCH_DEVICE_TOKEN\}\}/, autoFetchDeviceToken.toString());
|
|
245
263
|
const showPushAppInForeground = options.showPushAppInForeground === undefined || options.showPushAppInForeground === true;
|
|
246
264
|
envFileContent = replaceCodeByRegex(envFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
|
|
247
265
|
FileManagement.writeFile(envFileName, envFileContent);
|
|
@@ -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","CDP_API_KEY_RE","REGION_RE","envFileContent","env","cdpApiKey","_options$pushNotifica3","region","_options$pushNotifica5","regionMap","us","eu","toLowerCase","mappedRegion","_options$pushNotifica6","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 || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n if (options.pushNotification?.env?.cdpApiKey) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n options.pushNotification?.env?.cdpApiKey\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 /\\{\\{CDP_API_KEY\\}\\}/,\n options.pushNotification.env.cdpApiKey\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,GAAG,GAAGP,4BAA4B,aAAa;AACnE,MAAMQ,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAG,OAAO;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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mBAAmB,KAAKzF,SAAS,IACzCpB,OAAO,CAAC6G,mBAAmB,KAAK,IAAI;EACtC1B,cAAc,GAAG1F,kBAAkB,CACjC0F,cAAc,EACd,gCAAgC,EAChC0B,mBAAmB,CAACC,QAAQ,CAAC,CAC/B,CAAC;EAED,MAAMC,uBAAuB,GAC3B/G,OAAO,CAAC+G,uBAAuB,KAAK3F,SAAS,IAC7CpB,OAAO,CAAC+G,uBAAuB,KAAK,IAAI;EAC1C5B,cAAc,GAAG1F,kBAAkB,CACjC0F,cAAc,EACd,qCAAqC,EACrC4B,uBAAuB,CAACD,QAAQ,CAAC,CACnC,CAAC;EAEDnH,cAAc,CAACkF,SAAS,CAACC,WAAW,EAAEK,cAAc,CAAC;AACvD,CAAC","ignoreList":[]}
|
|
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","isFcmPushProvider","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","isFcmProvider","pbxTargetByName","warn","nsePath","mkdir","recursive","platformSpecificFiles","commonFiles","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","CDP_API_KEY_RE","REGION_RE","envFileContent","env","cdpApiKey","_options$pushNotifica3","region","_options$pushNotifica5","regionMap","us","eu","toLowerCase","mappedRegion","_options$pushNotifica6","sourceFile","targetFileName","appPath","exists","log","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","REGISTER_RE","snippet","disableNotificationRegistration","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","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';\nimport { isFcmPushProvider } from './utils';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) => {\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 const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n 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 platformSpecificFiles = [\n 'NotificationService.swift',\n ];\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${isFcmProvider ? \"fcm\" : \"apn\"}/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/common/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(options, getTargetFile(ENV_FILENAME));\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};\n projObjects['PBXContainerItemProxy'] =\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 || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n if (options.pushNotification?.env?.cdpApiKey) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n options.pushNotification?.env?.cdpApiKey\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 // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? \"fcm\" : \"apn\"}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${sourceFile}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\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 /\\{\\{CDP_API_KEY\\}\\}/,\n options.pushNotification.env.cdpApiKey\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 autoFetchDeviceToken = \n options.autoFetchDeviceToken === undefined ||\n options.autoFetchDeviceToken === true;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.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;AAClE,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,MAAMC,cAAc,GAAG,GAAGR,4BAA4B,aAAa;AACnE,MAAMS,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAG,OAAO;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,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C,CACnC,CAAC;EAEDvH,cAAc,CAACqF,SAAS,CAACC,WAAW,EAAEK,cAAc,CAAC;AACvD,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { withXcodeProject } from '@expo/config-plugins';
|
|
2
2
|
import { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
|
|
3
|
+
import { isFcmPushProvider } from './utils';
|
|
3
4
|
export const withCioXcodeProject = (config, cioProps) => {
|
|
4
5
|
return withXcodeProject(config, async props => {
|
|
5
6
|
var _props$ios, _props$ios2;
|
|
@@ -14,7 +15,7 @@ export const withCioXcodeProject = (config, cioProps) => {
|
|
|
14
15
|
const {
|
|
15
16
|
iosPath
|
|
16
17
|
} = options;
|
|
17
|
-
await injectCIOPodfileCode(iosPath);
|
|
18
|
+
await injectCIOPodfileCode(iosPath, isFcmPushProvider(cioProps));
|
|
18
19
|
return props;
|
|
19
20
|
});
|
|
20
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withXcodeProject","injectCIOPodfileCode","withCioXcodeProject","config","cioProps","props","_props$ios","_props$ios2","options","iosPath","modRequest","platformProjectRoot","bundleIdentifier","ios","devTeam","bundleVersion","buildNumber","bundleShortVersion","version","iosDeploymentTarget"],"sources":["withXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\n\nimport { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nexport const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n config,\n cioProps\n) => {\n return withXcodeProject(config, async (props) => {\n const options: CustomerIOPluginOptionsIOS = {\n iosPath: props.modRequest.platformProjectRoot,\n bundleIdentifier: props.ios?.bundleIdentifier,\n devTeam: cioProps?.devTeam,\n bundleVersion: props.ios?.buildNumber,\n bundleShortVersion: props?.version,\n iosDeploymentTarget: cioProps?.iosDeploymentTarget,\n };\n const { iosPath } = options;\n\n await injectCIOPodfileCode(iosPath);\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AAErE,SAASC,oBAAoB,QAAQ,uCAAuC;
|
|
1
|
+
{"version":3,"names":["withXcodeProject","injectCIOPodfileCode","isFcmPushProvider","withCioXcodeProject","config","cioProps","props","_props$ios","_props$ios2","options","iosPath","modRequest","platformProjectRoot","bundleIdentifier","ios","devTeam","bundleVersion","buildNumber","bundleShortVersion","version","iosDeploymentTarget"],"sources":["withXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\n\nimport { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\n\nexport const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n config,\n cioProps\n) => {\n return withXcodeProject(config, async (props) => {\n const options: CustomerIOPluginOptionsIOS = {\n iosPath: props.modRequest.platformProjectRoot,\n bundleIdentifier: props.ios?.bundleIdentifier,\n devTeam: cioProps?.devTeam,\n bundleVersion: props.ios?.buildNumber,\n bundleShortVersion: props?.version,\n iosDeploymentTarget: cioProps?.iosDeploymentTarget,\n };\n const { iosPath } = options;\n\n await injectCIOPodfileCode(iosPath, isFcmPushProvider(cioProps));\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AAErE,SAASC,oBAAoB,QAAQ,uCAAuC;AAE5E,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,OAAO,MAAMC,mBAA6D,GAAGA,CAC3EC,MAAM,EACNC,QAAQ,KACL;EACH,OAAOL,gBAAgB,CAACI,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA,IAAAC,UAAA,EAAAC,WAAA;IAC/C,MAAMC,OAAmC,GAAG;MAC1CC,OAAO,EAAEJ,KAAK,CAACK,UAAU,CAACC,mBAAmB;MAC7CC,gBAAgB,GAAAN,UAAA,GAAED,KAAK,CAACQ,GAAG,cAAAP,UAAA,uBAATA,UAAA,CAAWM,gBAAgB;MAC7CE,OAAO,EAAEV,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEU,OAAO;MAC1BC,aAAa,GAAAR,WAAA,GAAEF,KAAK,CAACQ,GAAG,cAAAN,WAAA,uBAATA,WAAA,CAAWS,WAAW;MACrCC,kBAAkB,EAAEZ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEa,OAAO;MAClCC,mBAAmB,EAAEf,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEe;IACjC,CAAC;IACD,MAAM;MAAEV;IAAQ,CAAC,GAAGD,OAAO;IAE3B,MAAMR,oBAAoB,CAACS,OAAO,EAAER,iBAAiB,CAACG,QAAQ,CAAC,CAAC;IAEhE,OAAOC,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -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 /**\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 cdpApiKey: 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":"","ignoreList":[]}
|
|
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 autoFetchDeviceToken?: boolean;\n handleDeeplinkInKilledState?: boolean;\n useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n provider?: 'apn' | 'fcm';\n googleServicesFile?: string;\n useRichPush: boolean;\n env: {\n cdpApiKey: 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":"","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';
|
|
2
|
-
export declare function injectCIOPodfileCode(iosPath: string): Promise<void>;
|
|
3
|
-
export declare function injectCIONotificationPodfileCode(iosPath: string, useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']): Promise<void>;
|
|
2
|
+
export declare function injectCIOPodfileCode(iosPath: string, isFcmPushProvider: boolean): Promise<void>;
|
|
3
|
+
export declare function injectCIONotificationPodfileCode(iosPath: string, useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'], isFcmPushProvider: boolean): Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns t
|
|
4
|
+
* @param iosOptions The plugin iOS configuration options
|
|
5
|
+
* @returns true if FCM is configured to be used as push provider
|
|
6
|
+
*/
|
|
7
|
+
export declare const isFcmPushProvider: (iosOptions?: CustomerIOPluginOptionsIOS) => boolean;
|
|
@@ -18,9 +18,12 @@ export type CustomerIOPluginOptionsIOS = {
|
|
|
18
18
|
handleNotificationClick?: boolean;
|
|
19
19
|
showPushAppInForeground?: boolean;
|
|
20
20
|
autoTrackPushEvents?: boolean;
|
|
21
|
+
autoFetchDeviceToken?: boolean;
|
|
21
22
|
handleDeeplinkInKilledState?: boolean;
|
|
22
23
|
useFrameworks?: 'static' | 'dynamic';
|
|
23
24
|
pushNotification?: {
|
|
25
|
+
provider?: 'apn' | 'fcm';
|
|
26
|
+
googleServicesFile?: string;
|
|
24
27
|
useRichPush: boolean;
|
|
25
28
|
env: {
|
|
26
29
|
cdpApiKey: string;
|
|
@@ -14,6 +14,7 @@ public class CIOAppPushNotificationsHandler : NSObject {
|
|
|
14
14
|
public func initializeCioSdk() {
|
|
15
15
|
MessagingPushAPN.initialize(
|
|
16
16
|
withConfig: MessagingPushConfigBuilder()
|
|
17
|
+
.autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
|
|
17
18
|
.showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
18
19
|
.autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
|
|
19
20
|
.build()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UserNotifications
|
|
3
|
+
import CioMessagingPushFCM
|
|
4
|
+
|
|
5
|
+
@objc
|
|
6
|
+
public class NotificationServiceCioManager : NSObject {
|
|
7
|
+
|
|
8
|
+
public override init() {}
|
|
9
|
+
|
|
10
|
+
@objc(didReceive:withContentHandler:)
|
|
11
|
+
public func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
|
12
|
+
MessagingPushFCM.initializeForExtension(
|
|
13
|
+
withConfig: MessagingPushConfigBuilder(cdpApiKey: Env.customerIOCdpApiKey)
|
|
14
|
+
.region(Env.customerIORegion)
|
|
15
|
+
.build()
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@objc(serviceExtensionTimeWillExpire)
|
|
22
|
+
public func serviceExtensionTimeWillExpire() {
|
|
23
|
+
MessagingPush.shared.serviceExtensionTimeWillExpire()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import CioMessagingPushFCM
|
|
3
|
+
import FirebaseCore
|
|
4
|
+
import FirebaseMessaging
|
|
5
|
+
import UserNotifications
|
|
6
|
+
import UIKit
|
|
7
|
+
|
|
8
|
+
@objc
|
|
9
|
+
public class CIOAppPushNotificationsHandler : NSObject {
|
|
10
|
+
|
|
11
|
+
public override init() {}
|
|
12
|
+
|
|
13
|
+
{{REGISTER_SNIPPET}}
|
|
14
|
+
|
|
15
|
+
@objc(initializeCioSdk)
|
|
16
|
+
public func initializeCioSdk() {
|
|
17
|
+
if (FirebaseApp.app() == nil) {
|
|
18
|
+
FirebaseApp.configure()
|
|
19
|
+
}
|
|
20
|
+
Messaging.messaging().delegate = self
|
|
21
|
+
UIApplication.shared.registerForRemoteNotifications()
|
|
22
|
+
|
|
23
|
+
MessagingPushFCM.initialize(
|
|
24
|
+
withConfig: MessagingPushConfigBuilder()
|
|
25
|
+
.autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
|
|
26
|
+
.showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
27
|
+
.autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
|
|
28
|
+
.build()
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@objc(application:deviceToken:)
|
|
33
|
+
public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
34
|
+
// Do nothing for FCM version
|
|
35
|
+
// This is not needed for FCM but keeping it to prevent modification or breaking compatibility with older versions
|
|
36
|
+
// of Expo plugin
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@objc(application:error:)
|
|
40
|
+
public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
|
41
|
+
// Do nothing for FCM version
|
|
42
|
+
// This is not needed for FCM but keeping it to prevent modification or breaking compatibility with older versions
|
|
43
|
+
// of Expo plugin
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
extension CIOAppPushNotificationsHandler: MessagingDelegate {
|
|
48
|
+
public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
|
|
49
|
+
MessagingPush.shared.messaging(messaging, didReceiveRegistrationToken: fcmToken)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
func userNotificationCenter(
|
|
53
|
+
_ center: UNUserNotificationCenter,
|
|
54
|
+
willPresent notification: UNNotification,
|
|
55
|
+
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
|
|
56
|
+
) {
|
|
57
|
+
completionHandler([.list, .banner, .badge, .sound])
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -3,7 +3,7 @@ import { getRelativePathToRNSDK } from '../constants/ios';
|
|
|
3
3
|
import { injectCodeByRegex } from './codeInjection';
|
|
4
4
|
import { FileManagement } from './fileManagement';
|
|
5
5
|
|
|
6
|
-
export async function injectCIOPodfileCode(iosPath: string) {
|
|
6
|
+
export async function injectCIOPodfileCode(iosPath: string, isFcmPushProvider: boolean) {
|
|
7
7
|
const blockStart = '# --- CustomerIO Host App START ---';
|
|
8
8
|
const blockEnd = '# --- CustomerIO Host App END ---';
|
|
9
9
|
|
|
@@ -19,7 +19,7 @@ export async function injectCIOPodfileCode(iosPath: string) {
|
|
|
19
19
|
|
|
20
20
|
const snippetToInjectInPodfile = `
|
|
21
21
|
${blockStart}
|
|
22
|
-
pod 'customerio-reactnative
|
|
22
|
+
pod 'customerio-reactnative/${isFcmPushProvider ? "fcm" : "apn"}', :path => '${getRelativePathToRNSDK(
|
|
23
23
|
iosPath
|
|
24
24
|
)}'
|
|
25
25
|
${blockEnd}
|
|
@@ -40,7 +40,8 @@ ${blockEnd}
|
|
|
40
40
|
|
|
41
41
|
export async function injectCIONotificationPodfileCode(
|
|
42
42
|
iosPath: string,
|
|
43
|
-
useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']
|
|
43
|
+
useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],
|
|
44
|
+
isFcmPushProvider: boolean
|
|
44
45
|
) {
|
|
45
46
|
const filename = `${iosPath}/Podfile`;
|
|
46
47
|
const podfile = await FileManagement.read(filename);
|
|
@@ -55,7 +56,7 @@ export async function injectCIONotificationPodfileCode(
|
|
|
55
56
|
${blockStart}
|
|
56
57
|
target 'NotificationService' do
|
|
57
58
|
${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}
|
|
58
|
-
pod 'customerio-reactnative-richpush
|
|
59
|
+
pod 'customerio-reactnative-richpush/${isFcmPushProvider ? "fcm" : "apn"}', :path => '${getRelativePathToRNSDK(
|
|
59
60
|
iosPath
|
|
60
61
|
)}'
|
|
61
62
|
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns t
|
|
5
|
+
* @param iosOptions The plugin iOS configuration options
|
|
6
|
+
* @returns true if FCM is configured to be used as push provider
|
|
7
|
+
*/
|
|
8
|
+
export const isFcmPushProvider = (iosOptions?: CustomerIOPluginOptionsIOS): boolean => {
|
|
9
|
+
return iosOptions?.pushNotification?.provider === "fcm";
|
|
10
|
+
};
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from '../helpers/utils/codeInjection';
|
|
32
32
|
import { FileManagement } from '../helpers/utils/fileManagement';
|
|
33
33
|
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
34
|
+
import { isFcmPushProvider } from './utils';
|
|
34
35
|
|
|
35
36
|
const addImport = (stringContents: string, appName: string) => {
|
|
36
37
|
const importRegex = /^(#import .*)\n/gm;
|
|
@@ -138,6 +139,16 @@ const addExpoNotificationsHeaderModification = (stringContents: string) => {
|
|
|
138
139
|
return stringContents;
|
|
139
140
|
};
|
|
140
141
|
|
|
142
|
+
const addFirebaseDelegateForwardDeclarationIfNeeded = (stringContents: string) => {
|
|
143
|
+
stringContents = injectCodeByLineNumber(
|
|
144
|
+
stringContents,
|
|
145
|
+
0,
|
|
146
|
+
'@protocol FIRMessagingDelegate;'
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
return stringContents;
|
|
150
|
+
};
|
|
151
|
+
|
|
141
152
|
const addAppdelegateHeaderModification = (stringContents: string) => {
|
|
142
153
|
// Add UNUserNotificationCenterDelegate if needed
|
|
143
154
|
stringContents = stringContents.replace(
|
|
@@ -250,6 +261,10 @@ export const withAppDelegateModifications: ConfigPlugin<
|
|
|
250
261
|
stringContents =
|
|
251
262
|
addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
|
|
252
263
|
|
|
264
|
+
if (isFcmPushProvider(props)) {
|
|
265
|
+
stringContents = addFirebaseDelegateForwardDeclarationIfNeeded(stringContents);
|
|
266
|
+
}
|
|
267
|
+
|
|
253
268
|
stringContents = addExpoNotificationsHeaderModification(stringContents);
|
|
254
269
|
|
|
255
270
|
config.modResults.contents = stringContents;
|
|
@@ -4,6 +4,7 @@ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
|
4
4
|
import { withAppDelegateModifications } from './withAppDelegateModifications';
|
|
5
5
|
import { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';
|
|
6
6
|
import { withCioXcodeProject } from './withXcodeProject';
|
|
7
|
+
import { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';
|
|
7
8
|
|
|
8
9
|
export function withCIOIos(
|
|
9
10
|
config: ExpoConfig,
|
|
@@ -13,6 +14,7 @@ export function withCIOIos(
|
|
|
13
14
|
config = withAppDelegateModifications(config, props);
|
|
14
15
|
config = withCioNotificationsXcodeProject(config, props);
|
|
15
16
|
config = withCioXcodeProject(config, props);
|
|
17
|
+
config = withGoogleServicesJsonFile(config, props);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
return config;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withXcodeProject,
|
|
3
|
+
IOSConfig,
|
|
4
|
+
ConfigPlugin,
|
|
5
|
+
} from '@expo/config-plugins';
|
|
6
|
+
|
|
7
|
+
import { FileManagement } from './../helpers/utils/fileManagement';
|
|
8
|
+
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
9
|
+
import { isFcmPushProvider } from './utils';
|
|
10
|
+
|
|
11
|
+
export const withGoogleServicesJsonFile: ConfigPlugin<
|
|
12
|
+
CustomerIOPluginOptionsIOS
|
|
13
|
+
> = (config, cioProps) => {
|
|
14
|
+
return withXcodeProject(config, async (props) => {
|
|
15
|
+
const useFcm = isFcmPushProvider(cioProps);
|
|
16
|
+
if (!useFcm) {
|
|
17
|
+
// Nothing to do, for providers other than FCM, the Google services JSON file isn't needed
|
|
18
|
+
return props;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
console.log(
|
|
22
|
+
'Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' +
|
|
23
|
+
' GoogleService-Info.plist as part of Firebase integration'
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// googleServicesFile
|
|
27
|
+
const iosPath = props.modRequest.platformProjectRoot;
|
|
28
|
+
const googleServicesFile = cioProps.pushNotification?.googleServicesFile;
|
|
29
|
+
const appName = props.modRequest.projectName;
|
|
30
|
+
|
|
31
|
+
if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {
|
|
32
|
+
console.log(
|
|
33
|
+
`File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`
|
|
34
|
+
);
|
|
35
|
+
return props;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (
|
|
39
|
+
FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)
|
|
40
|
+
) {
|
|
41
|
+
// This is where RN Firebase potentially copies GoogleService-Info.plist
|
|
42
|
+
// Do not copy if it's already done by Firebase to avoid conflict in Resources
|
|
43
|
+
console.log(
|
|
44
|
+
`File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`
|
|
45
|
+
);
|
|
46
|
+
return props;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
|
|
50
|
+
if (config.ios?.googleServicesFile) {
|
|
51
|
+
console.warn(
|
|
52
|
+
'Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' +
|
|
53
|
+
' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile'
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
FileManagement.copyFile(
|
|
59
|
+
googleServicesFile,
|
|
60
|
+
`${iosPath}/GoogleService-Info.plist`
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');
|
|
64
|
+
} catch (e) {
|
|
65
|
+
console.error(
|
|
66
|
+
`There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
console.error(
|
|
71
|
+
`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return props;
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function addFileToXcodeProject(project: any, fileName: string) {
|
|
80
|
+
const groupName = 'Resources';
|
|
81
|
+
const filepath = fileName;
|
|
82
|
+
|
|
83
|
+
if (!IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {
|
|
84
|
+
console.error(
|
|
85
|
+
`Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`
|
|
86
|
+
);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Add GoogleService-Info.plist to the Xcode project
|
|
91
|
+
IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
92
|
+
project,
|
|
93
|
+
filepath,
|
|
94
|
+
groupName,
|
|
95
|
+
isBuildFile: true,
|
|
96
|
+
});
|
|
97
|
+
}
|