customerio-expo-plugin 1.0.0-alpha.1 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/lib/commonjs/analytics/injectAnalytics.js +31 -0
  2. package/lib/commonjs/analytics/injectAnalytics.js.map +1 -0
  3. package/lib/commonjs/android/withAppGoogleServices.js +7 -1
  4. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
  5. package/lib/commonjs/android/withGistMavenRepository.js +6 -1
  6. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
  7. package/lib/commonjs/android/withGoogleServicesJSON.js +10 -6
  8. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  9. package/lib/commonjs/android/withProjectGoogleServices.js +5 -1
  10. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
  11. package/lib/commonjs/helpers/constants/android.js +4 -2
  12. package/lib/commonjs/helpers/constants/android.js.map +1 -1
  13. package/lib/commonjs/helpers/constants/ios.js +5 -3
  14. package/lib/commonjs/helpers/constants/ios.js.map +1 -1
  15. package/lib/commonjs/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
  16. package/lib/commonjs/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
  17. package/lib/{module/helpers/native-files/ios/CIONotificationService.m → commonjs/helpers/native-files/ios/NotificationService.m} +2 -6
  18. package/lib/{module/helpers/native-files/ios/CIONotificationService.swift → commonjs/helpers/native-files/ios/NotificationService.swift} +0 -2
  19. package/lib/commonjs/helpers/native-files/ios/PushNotification.swift +1 -10
  20. package/lib/commonjs/helpers/utils/fileManagement.js +32 -0
  21. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
  22. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +12 -7
  23. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  24. package/lib/commonjs/index.js +8 -2
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/ios/withAppDelegateModifications.js +27 -18
  27. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  28. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +15 -32
  29. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -1
  30. package/lib/commonjs/ios/withCIOIos.js +8 -3
  31. package/lib/commonjs/ios/withCIOIos.js.map +1 -1
  32. package/lib/commonjs/ios/withNotificationsXcodeProject.js +17 -16
  33. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  34. package/lib/commonjs/types/cio-types.js +0 -13
  35. package/lib/commonjs/types/cio-types.js.map +1 -1
  36. package/lib/commonjs/version.js +9 -0
  37. package/lib/commonjs/version.js.map +1 -0
  38. package/lib/module/analytics/injectAnalytics.js +24 -0
  39. package/lib/module/analytics/injectAnalytics.js.map +1 -0
  40. package/lib/module/android/withAppGoogleServices.js +7 -1
  41. package/lib/module/android/withAppGoogleServices.js.map +1 -1
  42. package/lib/module/android/withGistMavenRepository.js +7 -2
  43. package/lib/module/android/withGistMavenRepository.js.map +1 -1
  44. package/lib/module/android/withGoogleServicesJSON.js +10 -6
  45. package/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  46. package/lib/module/android/withProjectGoogleServices.js +5 -1
  47. package/lib/module/android/withProjectGoogleServices.js.map +1 -1
  48. package/lib/module/helpers/constants/android.js +2 -1
  49. package/lib/module/helpers/constants/android.js.map +1 -1
  50. package/lib/module/helpers/constants/ios.js +3 -2
  51. package/lib/module/helpers/constants/ios.js.map +1 -1
  52. package/lib/module/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
  53. package/lib/module/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
  54. package/{src/helpers/native-files/ios/CIONotificationService.m → lib/module/helpers/native-files/ios/NotificationService.m} +2 -6
  55. package/{src/helpers/native-files/ios/CIONotificationService.swift → lib/module/helpers/native-files/ios/NotificationService.swift} +0 -2
  56. package/lib/module/helpers/native-files/ios/PushNotification.swift +1 -10
  57. package/lib/module/helpers/utils/fileManagement.js +33 -1
  58. package/lib/module/helpers/utils/fileManagement.js.map +1 -1
  59. package/lib/module/helpers/utils/injectCIOPodfileCode.js +13 -8
  60. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  61. package/lib/module/index.js +8 -2
  62. package/lib/module/index.js.map +1 -1
  63. package/lib/module/ios/withAppDelegateModifications.js +27 -18
  64. package/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  65. package/lib/module/ios/withAppDelegateXcodeProject.js +15 -32
  66. package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -1
  67. package/lib/module/ios/withCIOIos.js +8 -3
  68. package/lib/module/ios/withCIOIos.js.map +1 -1
  69. package/lib/module/ios/withNotificationsXcodeProject.js +17 -16
  70. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  71. package/lib/module/types/cio-types.js +0 -8
  72. package/lib/module/types/cio-types.js.map +1 -1
  73. package/lib/module/version.js +2 -0
  74. package/lib/module/version.js.map +1 -0
  75. package/lib/typescript/analytics/injectAnalytics.d.ts +3 -0
  76. package/lib/typescript/helpers/constants/android.d.ts +1 -0
  77. package/lib/typescript/helpers/constants/ios.d.ts +2 -1
  78. package/lib/typescript/helpers/utils/fileManagement.d.ts +7 -0
  79. package/lib/typescript/index.d.ts +2 -2
  80. package/lib/typescript/types/cio-types.d.ts +7 -4
  81. package/lib/typescript/version.d.ts +1 -0
  82. package/package.json +3 -2
  83. package/src/analytics/injectAnalytics.ts +36 -0
  84. package/src/android/withAppGoogleServices.ts +11 -4
  85. package/src/android/withGistMavenRepository.ts +11 -4
  86. package/src/android/withGoogleServicesJSON.ts +17 -11
  87. package/src/android/withProjectGoogleServices.ts +9 -4
  88. package/src/helpers/constants/android.ts +3 -1
  89. package/src/helpers/constants/ios.ts +3 -3
  90. package/src/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
  91. package/src/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
  92. package/{lib/commonjs/helpers/native-files/ios/CIONotificationService.m → src/helpers/native-files/ios/NotificationService.m} +2 -6
  93. package/{lib/commonjs/helpers/native-files/ios/CIONotificationService.swift → src/helpers/native-files/ios/NotificationService.swift} +0 -2
  94. package/src/helpers/native-files/ios/PushNotification.swift +1 -10
  95. package/src/helpers/utils/fileManagement.ts +49 -1
  96. package/src/helpers/utils/injectCIOPodfileCode.ts +23 -17
  97. package/src/index.ts +12 -7
  98. package/src/ios/withAppDelegateModifications.ts +39 -23
  99. package/src/ios/withAppDelegateXcodeProject.ts +19 -40
  100. package/src/ios/withCIOIos.ts +9 -3
  101. package/src/ios/withNotificationsXcodeProject.ts +24 -18
  102. package/src/types/cio-types.ts +7 -4
  103. package/src/version.ts +1 -0
@@ -1,8 +1,9 @@
1
1
  import { withXcodeProject } from '@expo/config-plugins';
2
- import fs from 'fs';
3
2
  import xcode from 'xcode';
4
3
  import { CIO_NOTIFICATION_TARGET_NAME, DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
4
+ import { injectCodeByMultiLineRegex } from '../helpers/utils/codeInjection';
5
5
  import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
6
+ import { FileManagement } from './../helpers/utils/fileManagement';
6
7
  const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
7
8
  const TARGETED_DEVICE_FAMILY = `"1,2"`;
8
9
  const addNotificationServiceExtension = async options => {
@@ -22,14 +23,14 @@ const addNotificationServiceExtension = async options => {
22
23
  throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
23
24
  }
24
25
  await injectCIONotificationPodfileCode(iosPath);
25
- fs.mkdirSync(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {
26
+ FileManagement.mkdir(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {
26
27
  recursive: true
27
28
  });
28
- const files = [PLIST_FILENAME, 'CIONotificationService.h', 'CIONotificationService.swift', 'CIONotificationService.m'];
29
+ const files = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.swift', 'NotificationService.m'];
29
30
  const getTargetFile = filename => `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${filename}`;
30
31
  files.forEach(filename => {
31
32
  const targetFile = getTargetFile(filename);
32
- fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
33
+ FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
33
34
  });
34
35
 
35
36
  /* MODIFY COPIED EXTENSION FILES */
@@ -69,7 +70,7 @@ const addNotificationServiceExtension = async options => {
69
70
  const nseTarget = xcodeProject.addTarget(CIO_NOTIFICATION_TARGET_NAME, 'app_extension', CIO_NOTIFICATION_TARGET_NAME, `${bundleIdentifier}.richpush`);
70
71
 
71
72
  // Add build phases to the new target
72
- xcodeProject.addBuildPhase(['CIONotificationService.m', 'CIONotificationService.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
73
+ xcodeProject.addBuildPhase(['NotificationService.m', 'NotificationService.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
73
74
  xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
74
75
  xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
75
76
 
@@ -79,7 +80,7 @@ const addNotificationServiceExtension = async options => {
79
80
  if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${CIO_NOTIFICATION_TARGET_NAME}"`) {
80
81
  const buildSettingsObj = configurations[key].buildSettings;
81
82
  buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
82
- buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget ?? '13.0';
83
+ buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
83
84
  buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
84
85
  buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
85
86
  buildSettingsObj.SWIFT_VERSION = 4.2;
@@ -89,7 +90,7 @@ const addNotificationServiceExtension = async options => {
89
90
  // Add development team to the target & the main
90
91
  xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
91
92
  xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
92
- fs.writeFileSync(projPath, xcodeProject.writeSync());
93
+ FileManagement.writeFile(projPath, xcodeProject.writeSync());
93
94
  });
94
95
  };
95
96
  export const withCioNotificationsXcodeProject = (configOuter, props) => {
@@ -103,7 +104,7 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
103
104
  appleTeamId,
104
105
  iosDeploymentTarget
105
106
  } = props;
106
- if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
107
+ if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.');
107
108
  const {
108
109
  projectName,
109
110
  platformProjectRoot
@@ -113,19 +114,19 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
113
114
  buildNumber
114
115
  } = ios;
115
116
  if (bundleShortVersion === undefined) {
116
- throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
117
+ throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js or app.json');
117
118
  }
118
119
  if (bundleIdentifier === undefined) {
119
- throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
120
+ throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json');
120
121
  }
121
122
  if (projectName === undefined) {
122
- throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
123
+ throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js or app.json');
123
124
  }
124
125
  const options = {
125
126
  appleTeamId,
126
127
  bundleIdentifier,
127
128
  bundleShortVersion,
128
- bundleVersion: buildNumber ?? DEFAULT_BUNDLE_VERSION,
129
+ bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,
129
130
  iosPath: platformProjectRoot,
130
131
  appName: projectName,
131
132
  iosDeploymentTarget
@@ -137,13 +138,13 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
137
138
  const updateNseInfoPlist = payload => {
138
139
  const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
139
140
  const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
140
- let plistFileString = fs.readFileSync(payload.infoPlistTargetFile, 'utf-8');
141
+ let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);
141
142
  if (payload.bundleVersion) {
142
- plistFileString = plistFileString.replace(BUNDLE_VERSION_RE, payload.bundleVersion);
143
+ plistFileString = injectCodeByMultiLineRegex(plistFileString, BUNDLE_VERSION_RE, payload.bundleVersion);
143
144
  }
144
145
  if (payload.bundleShortVersion) {
145
- plistFileString = plistFileString.replace(BUNDLE_SHORT_VERSION_RE, payload.bundleShortVersion);
146
+ plistFileString = injectCodeByMultiLineRegex(plistFileString, BUNDLE_SHORT_VERSION_RE, payload.bundleShortVersion);
146
147
  }
147
- fs.writeFileSync(payload.infoPlistTargetFile, plistFileString);
148
+ FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
148
149
  };
149
150
  //# sourceMappingURL=withNotificationsXcodeProject.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withXcodeProject","fs","xcode","CIO_NOTIFICATION_TARGET_NAME","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","injectCIONotificationPodfileCode","PLIST_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","appleTeamId","bundleIdentifier","bundleShortVersion","bundleVersion","iosPath","appName","iosDeploymentTarget","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","mkdirSync","recursive","files","getTargetFile","filename","forEach","targetFile","copyFileSync","infoPlistTargetFile","updateNseInfoPlist","extGroup","addPbxGroup","groups","hash","objects","Object","keys","key","name","undefined","addToPbxGroup","uuid","projObjects","pbxTargetByName","console","warn","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","writeFileSync","writeSync","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","projectName","platformProjectRoot","buildNumber","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFileSync","replace"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport fs from 'fs';\nimport xcode from 'xcode';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n appName,\n iosDeploymentTarget,\n } = options;\n\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n await injectCIONotificationPodfileCode(iosPath);\n\n fs.mkdirSync(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'CIONotificationService.h',\n 'CIONotificationService.swift',\n 'CIONotificationService.m',\n ];\n\n const getTargetFile = (filename: string) =>\n `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\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) {\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'] =\n 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 ['CIONotificationService.m', 'CIONotificationService.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 fs.writeFileSync(projPath, xcodeProject.writeSync());\n });\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js.'\n );\n\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'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js'\n );\n }\n\n const options = {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber ?? DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n iosDeploymentTarget,\n };\n\n await addNotificationServiceExtension(options);\n\n return config;\n });\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 = fs.readFileSync(payload.infoPlistTargetFile, 'utf-8');\n\n if (payload.bundleVersion) {\n plistFileString = plistFileString.replace(\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = plistFileString.replace(\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n fs.writeFileSync(payload.infoPlistTargetFile, plistFileString);\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,4BAA4B,EAC5BC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,gCAAgC,QAAQ,uCAAuC;AAGxF,MAAMC,cAAc,GAAI,GAAEJ,4BAA6B,aAAY;AAEnE,MAAMK,sBAAsB,GAAI,OAAM;AAEtC,MAAMC,+BAA+B,GAAG,M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code","CIO_NOTIFICATION_TARGET_NAME","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","injectCodeByMultiLineRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","appleTeamId","bundleIdentifier","bundleShortVersion","bundleVersion","iosPath","appName","iosDeploymentTarget","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","extGroup","addPbxGroup","groups","hash","objects","Object","keys","key","name","undefined","addToPbxGroup","uuid","projObjects","pbxTargetByName","console","warn","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","writeFile","writeSync","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","projectName","platformProjectRoot","buildNumber","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport xcode from 'xcode';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { injectCodeByMultiLineRegex } 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`;\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n appName,\n iosDeploymentTarget,\n } = options;\n\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n await injectCIONotificationPodfileCode(iosPath);\n\n FileManagement.mkdir(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ];\n\n const getTargetFile = (filename: string) =>\n `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${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\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) {\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'] =\n 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'],\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 FileManagement.writeFile(projPath, xcodeProject.writeSync());\n });\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget } = 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 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 appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n iosDeploymentTarget,\n };\n\n await addNotificationServiceExtension(options);\n\n return config;\n });\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 = injectCodeByMultiLineRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = injectCodeByMultiLineRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFile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a,EAAE;IACzBkE,eAAe,GAAG5E,0BAA0B,CAC1C4E,eAAe,EACfD,iBAAiB,EACjBF,OAAO,CAAC/D,aAAa,CACtB;EACH;EAEA,IAAI+D,OAAO,CAAChE,kBAAkB,EAAE;IAC9BmE,eAAe,GAAG5E,0BAA0B,CAC1C4E,eAAe,EACfF,uBAAuB,EACvBD,OAAO,CAAChE,kBAAkB,CAC3B;EACH;EAEAP,cAAc,CAAC2D,SAAS,CAACY,OAAO,CAAC3C,mBAAmB,EAAE8C,eAAe,CAAC;AACxE,CAAC"}
@@ -1,10 +1,2 @@
1
- // properties set by the user in their app config file (e.g: app.json or app.plugin.js)
2
1
 
3
- // Plugin options for pre-build
4
-
5
- export let Mode;
6
- (function (Mode) {
7
- Mode["Dev"] = "development";
8
- Mode["Prod"] = "production";
9
- })(Mode || (Mode = {}));
10
2
  //# sourceMappingURL=cio-types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Mode"],"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};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFilePath?: string;\n};\n\nexport enum Mode {\n Dev = 'development',\n Prod = 'production',\n}\n"],"mappings":"AAAA;;AAOA;;AAiBA,WAAYA,IAAI;AAGf,WAHWA,IAAI;EAAJA,IAAI;EAAJA,IAAI;AAAA,GAAJA,IAAI,KAAJA,IAAI"}
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 pushNotification?: {\n useRichPush: boolean;\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFilePath?: string;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export const LIB_VERSION = "1.0.0-alpha.3";
2
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LIB_VERSION"],"sources":["version.ts"],"sourcesContent":["export const LIB_VERSION = \"1.0.0-alpha.3\";\n"],"mappings":"AAAA,OAAO,MAAMA,WAAW,GAAG,eAAe"}
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptions } from '../types/cio-types';
3
+ export declare const withAnalytics: ConfigPlugin<CustomerIOPluginOptions>;
@@ -1,5 +1,6 @@
1
1
  export declare const CIO_PROJECT_BUILDSCRIPTS_REGEX: RegExp;
2
2
  export declare const CIO_APP_APPLY_REGEX: RegExp;
3
+ export declare const CIO_GIST_MAVEN_REGEX: RegExp;
3
4
  export declare const CIO_PROJECT_ALLPROJECTS_REGEX: RegExp;
4
5
  export declare const CIO_PROJECT_GIST_MAVEN_SNIPPET = " maven { url \"https://maven.gist.build\" }";
5
6
  export declare const CIO_APP_GOOGLE_SNIPPET = "apply plugin: \"com.google.gms.google-services\" // Google Services plugin";
@@ -1,6 +1,7 @@
1
1
  export declare const LOCAL_PATH_TO_CIO_NSE_FILES = "node_modules/customerio-expo-plugin/src/helpers/native-files/ios";
2
2
  export declare const IOS_DEPLOYMENT_TARGET = "13.0";
3
3
  export declare const CIO_PODFILE_REGEX: RegExp;
4
+ export declare const CIO_CIO_TARGET_REGEX: RegExp;
4
5
  export declare const CIO_PODFILE_NOTIFICATION_REGEX: RegExp;
5
6
  export declare const GROUP_IDENTIFIER_TEMPLATE_REGEX: RegExp;
6
7
  export declare const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX: RegExp;
@@ -15,7 +16,7 @@ export declare const CIO_APPDELEGATEHEADER_REGEX: RegExp;
15
16
  export declare const DEFAULT_BUNDLE_VERSION = "1";
16
17
  export declare const DEFAULT_BUNDLE_SHORT_VERSION = "1.0";
17
18
  export declare const CIO_TARGET_NAME = "CustomerIOSDK";
18
- export declare const CIO_NOTIFICATION_TARGET_NAME = "CIONotificationService";
19
+ export declare const CIO_NOTIFICATION_TARGET_NAME = "NotificationService";
19
20
  export declare const CIO_APPDELEGATEHEADER_SNIPPET = "\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n";
20
21
  export declare const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = "\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n";
21
22
  export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = "\n [pnHandlerObj application:application error:error];\n";
@@ -1,5 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { MakeDirectoryOptions } from 'fs';
1
3
  export declare class FileManagement {
2
4
  static read(path: string): Promise<string>;
3
5
  static write(path: string, contents: string): Promise<void>;
4
6
  static append(path: string, contents: string): Promise<void>;
7
+ static exists(path: string): boolean;
8
+ static copyFile(src: string, dest: string): void;
9
+ static mkdir(path: string, options: MakeDirectoryOptions): void;
10
+ static writeFile(path: string, data: string): void;
11
+ static readFile(path: string): string;
5
12
  }
@@ -1,4 +1,4 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
- import type { CustomerIOPluginOptionsIOS, CustomerIOPluginOptionsAndroid } from './types/cio-types';
3
- declare function withCustomerIOPlugin(config: ExpoConfig, props: CustomerIOPluginOptionsIOS | CustomerIOPluginOptionsAndroid): ExpoConfig;
2
+ import type { CustomerIOPluginOptions } from './types/cio-types';
3
+ declare function withCustomerIOPlugin(config: ExpoConfig, props: CustomerIOPluginOptions): ExpoConfig;
4
4
  export default withCustomerIOPlugin;
@@ -11,12 +11,15 @@ export declare type CustomerIOPluginOptionsIOS = {
11
11
  iosDeploymentTarget?: string;
12
12
  appleTeamId?: string;
13
13
  appName?: string;
14
+ pushNotification?: {
15
+ useRichPush: boolean;
16
+ };
14
17
  };
15
18
  export declare type CustomerIOPluginOptionsAndroid = {
16
19
  androidPath: string;
17
20
  googleServicesFilePath?: string;
18
21
  };
19
- export declare enum Mode {
20
- Dev = "development",
21
- Prod = "production"
22
- }
22
+ export declare type CustomerIOPluginOptions = {
23
+ android: CustomerIOPluginOptionsAndroid;
24
+ ios: CustomerIOPluginOptionsIOS;
25
+ };
@@ -0,0 +1 @@
1
+ export declare const LIB_VERSION = "1.0.0-alpha.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customerio-expo-plugin",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.3",
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",
@@ -14,7 +14,8 @@
14
14
  ],
15
15
  "scripts": {
16
16
  "build": "npm run clean && tsc",
17
- "clean": "rm -rf lib",
17
+ "prebuild": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
18
+ "clean": "rm -rf lib && npm run prebuild",
18
19
  "expo-module": "expo-module",
19
20
  "lint": "eslint . --fix",
20
21
  "typescript": "tsc --noEmit",
@@ -0,0 +1,36 @@
1
+ import { LIB_VERSION } from './../version';
2
+ import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';
3
+ import { FileManagement } from '../helpers/utils/fileManagement';
4
+ import type { CustomerIOPluginOptions } from '../types/cio-types';
5
+
6
+
7
+ export const withAnalytics: ConfigPlugin<CustomerIOPluginOptions> = (config) => {
8
+ return withXcodeProject(config, async (props) => {
9
+ const expoVersionSnippet = `"expoVersion": "${LIB_VERSION}"`;
10
+ let versionRegEx = new RegExp(expoVersionSnippet);
11
+ const filename = `node_modules/customerio-reactnative/package.json`;
12
+ if (FileManagement.exists(filename)) {
13
+ const pJsonFile = await FileManagement.read(filename);
14
+ const lines = pJsonFile.split('\n');
15
+ const missingMmatch = pJsonFile.match(versionRegEx);
16
+ const expoVersionRegex = /"expoVersion": ".*"/;
17
+ const existatch = pJsonFile.match(expoVersionRegex);
18
+
19
+ if (existatch && !missingMmatch) {
20
+ const index = lines.findIndex((line) =>
21
+ expoVersionRegex.test(line)
22
+ );
23
+
24
+ const content = [
25
+ ...lines.slice(0, index),
26
+ ` ${expoVersionSnippet},`,
27
+ ...lines.slice(index + 1),
28
+ ];
29
+
30
+ FileManagement.write(filename, content.join('\n'));
31
+ }
32
+ }
33
+
34
+ return props;
35
+ });
36
+ };
@@ -10,10 +10,17 @@ export const withAppGoogleServices: ConfigPlugin<
10
10
  CustomerIOPluginOptionsAndroid
11
11
  > = (configOuter) => {
12
12
  return withAppBuildGradle(configOuter, (props) => {
13
- props.modResults.contents = props.modResults.contents.replace(
14
- CIO_APP_APPLY_REGEX,
15
- `$1\n${CIO_APP_GOOGLE_SNIPPET}`
16
- );
13
+ const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);
14
+ const match = props.modResults.contents.match(regex);
15
+ if (!match) {
16
+ props.modResults.contents = props.modResults.contents.replace(
17
+ CIO_APP_APPLY_REGEX,
18
+ `$1\n${CIO_APP_GOOGLE_SNIPPET}`
19
+ );
20
+ } else {
21
+ console.log('app/build.gradle snippet already exists. Skipping...');
22
+ }
23
+
17
24
  return props;
18
25
  });
19
26
  };
@@ -1,6 +1,7 @@
1
1
  import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';
2
2
 
3
3
  import {
4
+ CIO_GIST_MAVEN_REGEX,
4
5
  CIO_PROJECT_ALLPROJECTS_REGEX,
5
6
  CIO_PROJECT_GIST_MAVEN_SNIPPET,
6
7
  } from '../helpers/constants/android';
@@ -10,10 +11,16 @@ export const withGistMavenRepository: ConfigPlugin<
10
11
  CustomerIOPluginOptionsAndroid
11
12
  > = (configOuter) => {
12
13
  return withProjectBuildGradle(configOuter, (props) => {
13
- props.modResults.contents = props.modResults.contents.replace(
14
- CIO_PROJECT_ALLPROJECTS_REGEX,
15
- `$1\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`
16
- );
14
+ const targetMatch = props.modResults.contents.match(CIO_GIST_MAVEN_REGEX);
15
+ if (!targetMatch) {
16
+ props.modResults.contents = props.modResults.contents.replace(
17
+ CIO_PROJECT_ALLPROJECTS_REGEX,
18
+ `$1\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`
19
+ );
20
+ } else {
21
+ console.log('build.gradle snippet alreade exists. Skipping...');
22
+ }
23
+
17
24
  return props;
18
25
  });
19
26
  };
@@ -1,6 +1,6 @@
1
1
  import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';
2
- import { copyFileSync } from 'fs';
3
2
 
3
+ import { FileManagement } from './../helpers/utils/fileManagement';
4
4
  import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
5
5
 
6
6
  export const withGoogleServicesJSON: ConfigPlugin<
@@ -12,17 +12,23 @@ export const withGoogleServicesJSON: ConfigPlugin<
12
12
  googleServicesFilePath: cioProps?.googleServicesFilePath,
13
13
  };
14
14
  const { androidPath, googleServicesFilePath } = options;
15
- if (googleServicesFilePath) {
16
- try {
17
- copyFileSync(
18
- `${googleServicesFilePath}google-services.json`,
19
- `${androidPath}/app/google-services.json`
20
- );
21
- } catch (e) {
22
- console.log(
23
- 'There was an error copying your google-services.json file.'
24
- );
15
+ if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {
16
+ if (googleServicesFilePath) {
17
+ try {
18
+ FileManagement.copyFile(
19
+ `${googleServicesFilePath}google-services.json`,
20
+ `${androidPath}/app/google-services.json`
21
+ );
22
+ } catch (e) {
23
+ console.log(
24
+ `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/`
25
+ );
26
+ }
25
27
  }
28
+ } else {
29
+ console.log(
30
+ `File already exists: ${androidPath}/app/google-services.json. Skipping...`
31
+ );
26
32
  }
27
33
 
28
34
  return props;
@@ -10,10 +10,15 @@ export const withProjectGoogleServices: ConfigPlugin<
10
10
  CustomerIOPluginOptionsAndroid
11
11
  > = (configOuter) => {
12
12
  return withProjectBuildGradle(configOuter, (props) => {
13
- props.modResults.contents = props.modResults.contents.replace(
14
- CIO_PROJECT_BUILDSCRIPTS_REGEX,
15
- `$1\n${CIO_PROJECT_GOOGLE_SNIPPET}`
16
- );
13
+ const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);
14
+ const match = props.modResults.contents.match(regex);
15
+ if (!match) {
16
+ props.modResults.contents = props.modResults.contents.replace(
17
+ CIO_PROJECT_BUILDSCRIPTS_REGEX,
18
+ `$1\n${CIO_PROJECT_GOOGLE_SNIPPET}`
19
+ );
20
+ }
21
+
17
22
  return props;
18
23
  });
19
24
  };
@@ -1,8 +1,10 @@
1
1
  export const CIO_PROJECT_BUILDSCRIPTS_REGEX =
2
2
  /(buildscript\s*\{(.|\n)*dependencies\s*\{)/;
3
3
  export const CIO_APP_APPLY_REGEX = /(apply plugin: "com.android.application")/;
4
+ export const CIO_GIST_MAVEN_REGEX =
5
+ /maven { url "https:\/\/maven.gist.build" }/;
4
6
  export const CIO_PROJECT_ALLPROJECTS_REGEX =
5
- /(allprojects\s*\{(.|\n)*repositories\s*\{)/;
7
+ /(allprojects\s*\{(.|\n){1,500}repositories\s*\{)/;
6
8
 
7
9
  export const CIO_PROJECT_GIST_MAVEN_SNIPPET =
8
10
  ' maven { url "https://maven.gist.build" }';
@@ -1,8 +1,8 @@
1
1
  export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;
2
2
  export const IOS_DEPLOYMENT_TARGET = '13.0';
3
3
  export const CIO_PODFILE_REGEX = /pod 'RCT-Folly'/;
4
- export const CIO_PODFILE_NOTIFICATION_REGEX =
5
- /target 'CIONotificationService' do/;
4
+ export const CIO_CIO_TARGET_REGEX = /cio_target_names/;
5
+ export const CIO_PODFILE_NOTIFICATION_REGEX = /target 'NotificationService' do/;
6
6
  export const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
7
7
  export const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
8
8
  export const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
@@ -27,7 +27,7 @@ export const CIO_APPDELEGATEHEADER_REGEX =
27
27
  export const DEFAULT_BUNDLE_VERSION = '1';
28
28
  export const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
29
29
  export const CIO_TARGET_NAME = 'CustomerIOSDK';
30
- export const CIO_NOTIFICATION_TARGET_NAME = 'CIONotificationService';
30
+ export const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';
31
31
  export const CIO_APPDELEGATEHEADER_SNIPPET = `
32
32
  #import <UserNotifications/UserNotifications.h>
33
33
 
@@ -9,7 +9,7 @@
9
9
  <key>CFBundleDevelopmentRegion</key>
10
10
  <string>$(DEVELOPMENT_LANGUAGE)</string>
11
11
  <key>CFBundleDisplayName</key>
12
- <string>CIONotificationServiceExtension</string>
12
+ <string>NotificationServiceExtension</string>
13
13
  <key>CFBundleExecutable</key>
14
14
  <string>$(EXECUTABLE_NAME)</string>
15
15
  <key>CFBundleIdentifier</key>
@@ -25,7 +25,7 @@
25
25
  <key>NSExtensionPointIdentifier</key>
26
26
  <string>com.apple.usernotifications.service</string>
27
27
  <key>NSExtensionPrincipalClass</key>
28
- <string>CIONotificationService</string>
28
+ <string>NotificationService</string>
29
29
  </dict>
30
30
  </dict>
31
31
  </plist>
@@ -1,8 +1,6 @@
1
1
 
2
- #import "CIONotificationService.h"
3
- // MARK: - CIO-TECH-ASSISTANCE
4
- // Import "Your-target-name-Swift.h" file
5
- #import "CIONotificationService-Swift.h"
2
+ #import "NotificationService.h"
3
+ #import "NotificationService-Swift.h"
6
4
 
7
5
  @interface NotificationService ()
8
6
 
@@ -14,7 +12,6 @@
14
12
  @implementation NotificationService
15
13
 
16
14
  - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
17
- // MARK: - CIO-TECH-ASSISTANCE
18
15
  NotificationServiceCioManager* cioManagerObj = [[NotificationServiceCioManager alloc] init];
19
16
  [cioManagerObj didReceive:request withContentHandler:contentHandler];
20
17
  }
@@ -22,7 +19,6 @@
22
19
  - (void)serviceExtensionTimeWillExpire {
23
20
  // Called just before the extension will be terminated by the system.
24
21
  // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
25
- // MARK: - CIO-TECH-ASSISTANCE
26
22
  NotificationServiceCioManager* cioManagerObj = [[NotificationServiceCioManager alloc] init];
27
23
  [cioManagerObj serviceExtensionTimeWillExpire];
28
24
  }
@@ -2,8 +2,6 @@ import Foundation
2
2
  import UserNotifications
3
3
  import CioMessagingPush
4
4
 
5
- // MARK: - CIO-TECH-ASSISTANCE
6
- // This is another example of handling ObjC calls for Swift CustomerIO SDK
7
5
  @objc
8
6
  public class NotificationServiceCioManager : NSObject {
9
7
 
@@ -1,10 +1,3 @@
1
- //
2
- // PushNotification.swift
3
- // testandroidapp
4
- //
5
- // Created by Segun Xtreem on 10/09/2022.
6
- //
7
-
8
1
  import Foundation
9
2
  import CioMessagingPushAPN
10
3
  import CioTracking
@@ -16,12 +9,11 @@ public class CIOAppPushNotificationsHandler : NSObject {
16
9
 
17
10
  public override init() {}
18
11
 
19
- // MARK: - ObjCNEW
20
12
  @objc(registerPushNotification:)
21
13
  public func registerPushNotification(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {
22
14
 
23
15
  let center = UNUserNotificationCenter.current()
24
- center.delegate = notificationDelegate // MARK: - ObjCNEW
16
+ center.delegate = notificationDelegate
25
17
  center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
26
18
  if error == nil{
27
19
  DispatchQueue.main.async {
@@ -41,7 +33,6 @@ public class CIOAppPushNotificationsHandler : NSObject {
41
33
  MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
42
34
  }
43
35
 
44
- // MARK: - ObjCNEW
45
36
  @objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)
46
37
  public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
47
38
  let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
@@ -1,4 +1,14 @@
1
- import { readFile, writeFile, appendFile } from 'fs';
1
+ import {
2
+ readFile,
3
+ writeFile,
4
+ appendFile,
5
+ existsSync,
6
+ copyFileSync,
7
+ mkdirSync,
8
+ writeFileSync,
9
+ readFileSync,
10
+ MakeDirectoryOptions,
11
+ } from 'fs';
2
12
 
3
13
  export class FileManagement {
4
14
  static async read(path: string): Promise<string> {
@@ -36,4 +46,42 @@ export class FileManagement {
36
46
  });
37
47
  });
38
48
  }
49
+
50
+ static exists(path: string) {
51
+ return existsSync(path);
52
+ }
53
+
54
+ static copyFile(src: string, dest: string) {
55
+ try {
56
+ copyFileSync(src, dest);
57
+ } catch (err) {
58
+ console.log(`Error copying file from ${src} to ${dest}: `, err);
59
+ }
60
+ }
61
+
62
+ static mkdir(path: string, options: MakeDirectoryOptions) {
63
+ try {
64
+ mkdirSync(path, options);
65
+ } catch (err) {
66
+ console.log(`Error creating directory ${path}: `, err);
67
+ }
68
+ }
69
+
70
+ static writeFile(path: string, data: string) {
71
+ try {
72
+ writeFileSync(path, data);
73
+ } catch (err) {
74
+ console.log(`Error writing to file ${path}: `, err);
75
+ }
76
+ }
77
+
78
+ static readFile(path: string) {
79
+ try {
80
+ return readFileSync(path, 'utf-8');
81
+ } catch (err) {
82
+ console.log(`Error reading file ${path}: `, err);
83
+ }
84
+
85
+ return '';
86
+ }
39
87
  }