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
@@ -7,6 +7,7 @@ import {
7
7
  CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET,
8
8
  CIO_PODFILE_NOTIFICATION_SNIPPET,
9
9
  CIO_PODFILE_NOTIFICATION_REGEX,
10
+ CIO_CIO_TARGET_REGEX,
10
11
  } from '../constants/ios';
11
12
  import { FileManagement } from './fileManagement';
12
13
 
@@ -14,26 +15,31 @@ export async function injectCIOPodfileCode(iosPath: string) {
14
15
  const filename = `${iosPath}/Podfile`;
15
16
  const podfile = await FileManagement.read(filename);
16
17
  const matches = podfile.match(CIO_PODFILE_REGEX);
18
+ const targetMatch = podfile.match(CIO_CIO_TARGET_REGEX);
17
19
 
18
- const lines = podfile.split('\n');
19
- const index = lines.findIndex((line) =>
20
- CIO_PODFILE_POST_INSTALL_REGEX.test(line)
21
- );
22
- let content: string[] = lines;
23
- if (index > -1) {
24
- content = [
25
- ...lines.slice(0, index - 1),
26
- !matches ? CIO_PODFILE_SNIPPET : '',
27
- CIO_PODFILE_TARGET_NAMES_SNIPPET,
28
- ...lines.slice(index - 1, index + 1),
29
- CIO_PODFILE_POST_INSTALL_SNIPPET,
30
- ...lines.slice(index + 1),
31
- ];
20
+ if (!targetMatch) {
21
+ const lines = podfile.split('\n');
22
+ const index = lines.findIndex((line) =>
23
+ CIO_PODFILE_POST_INSTALL_REGEX.test(line)
24
+ );
25
+ let content: string[] = lines;
26
+ if (index > -1) {
27
+ content = [
28
+ ...lines.slice(0, index - 1),
29
+ !matches ? CIO_PODFILE_SNIPPET : '',
30
+ CIO_PODFILE_TARGET_NAMES_SNIPPET,
31
+ ...lines.slice(index - 1, index + 1),
32
+ CIO_PODFILE_POST_INSTALL_SNIPPET,
33
+ ...lines.slice(index + 1),
34
+ ];
35
+ } else {
36
+ content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);
37
+ }
38
+
39
+ FileManagement.write(filename, content.join('\n'));
32
40
  } else {
33
- content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);
41
+ console.log('Customerio Podfile snippets already exists. Skipping...');
34
42
  }
35
-
36
- FileManagement.write(filename, content.join('\n'));
37
43
  }
38
44
 
39
45
  export async function injectCIONotificationPodfileCode(iosPath: string) {
package/src/index.ts CHANGED
@@ -1,19 +1,24 @@
1
1
  import type { ExpoConfig } from '@expo/config-types';
2
2
 
3
+ import { withAnalytics } from './analytics/injectAnalytics';
3
4
  import { withCIOAndroid } from './android/withCIOAndroid';
4
5
  import { withCIOIos } from './ios/withCIOIos';
5
- import type {
6
- CustomerIOPluginOptionsIOS,
7
- CustomerIOPluginOptionsAndroid,
8
- } from './types/cio-types';
6
+ import type { CustomerIOPluginOptions } from './types/cio-types';
9
7
 
10
8
  // Entry point for config plugin
11
9
  function withCustomerIOPlugin(
12
10
  config: ExpoConfig,
13
- props: CustomerIOPluginOptionsIOS | CustomerIOPluginOptionsAndroid
11
+ props: CustomerIOPluginOptions
14
12
  ) {
15
- config = withCIOIos(config, props as CustomerIOPluginOptionsIOS);
16
- config = withCIOAndroid(config, props as CustomerIOPluginOptionsAndroid);
13
+ if (props.ios) {
14
+ config = withCIOIos(config, props.ios);
15
+ }
16
+
17
+ if (props.android) {
18
+ config = withCIOAndroid(config, props.android);
19
+ }
20
+
21
+ config = withAnalytics(config, props);
17
22
 
18
23
  return config;
19
24
  }
@@ -30,15 +30,11 @@ const pushCodeSnippets = [
30
30
 
31
31
  const additionalMethodsForPushNotifications = `${pushCodeSnippets.join(
32
32
  '\n'
33
- )}\n`; // Join w/ newlines and ensure a newline at the end.
33
+ )}\n`; // Join newlines and ensure a newline at the end.
34
34
 
35
- const addImport = (stringContents: string) => {
35
+ const addImport = (stringContents: string, appName: string) => {
36
36
  const importRegex = /^(#import .*)\n/gm;
37
- const addedImport = `
38
- // Add swift bridge imports
39
- #import <ExpoModulesCore-Swift.h>
40
- #import <testiosapp-Swift.h>
41
- `;
37
+ const addedImport = getImportSnippet(appName);
42
38
 
43
39
  const match = stringContents.match(importRegex);
44
40
  let endOfMatchIndex: number;
@@ -128,23 +124,43 @@ export const withAppDelegateModifications: ConfigPlugin<any> = (
128
124
  ) => {
129
125
  return withAppDelegate(configOuter, async (config) => {
130
126
  let stringContents = config.modResults.contents;
131
- const headerPath = getAppDelegateHeaderFilePath(
132
- config.modRequest.projectRoot
127
+ const regex = new RegExp(
128
+ `#import <${config.modRequest.projectName}-Swift.h>`
133
129
  );
134
- let headerContent = await FileManagement.read(headerPath);
135
- headerContent = addAppdelegateHeaderModification(headerContent);
136
- FileManagement.write(headerPath, headerContent);
137
-
138
- stringContents = addImport(stringContents);
139
- stringContents = addNotificationHandlerDeclaration(stringContents);
140
- stringContents = addNotificationConfiguration(stringContents);
141
- stringContents = addAdditionalMethodsForPushNotifications(stringContents);
142
- stringContents =
143
- addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
144
- stringContents =
145
- AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
146
-
147
- config.modResults.contents = stringContents;
130
+ const match = stringContents.match(regex);
131
+
132
+ if (!match) {
133
+ const headerPath = getAppDelegateHeaderFilePath(
134
+ config.modRequest.projectRoot
135
+ );
136
+ let headerContent = await FileManagement.read(headerPath);
137
+ headerContent = addAppdelegateHeaderModification(headerContent);
138
+ FileManagement.write(headerPath, headerContent);
139
+
140
+ stringContents = addImport(
141
+ stringContents,
142
+ config.modRequest.projectName as string
143
+ );
144
+ stringContents = addNotificationHandlerDeclaration(stringContents);
145
+ stringContents = addNotificationConfiguration(stringContents);
146
+ stringContents = addAdditionalMethodsForPushNotifications(stringContents);
147
+ stringContents =
148
+ addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
149
+ stringContents =
150
+ AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
151
+
152
+ config.modResults.contents = stringContents;
153
+ } else {
154
+ console.log('Customerio AppDelegate changes already exist. Skipping...');
155
+ }
156
+
148
157
  return config;
149
158
  });
150
159
  };
160
+ function getImportSnippet(appName: string) {
161
+ return `
162
+ // Add swift bridge imports
163
+ #import <ExpoModulesCore-Swift.h>
164
+ #import <${appName}-Swift.h>
165
+ `;
166
+ }
@@ -1,5 +1,4 @@
1
1
  import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';
2
- import fs from 'fs';
3
2
  import xcode from 'xcode';
4
3
 
5
4
  import {
@@ -7,56 +6,36 @@ import {
7
6
  LOCAL_PATH_TO_CIO_NSE_FILES,
8
7
  } from '../helpers/constants/ios';
9
8
  import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
9
+ import { FileManagement } from './../helpers/utils/fileManagement';
10
10
 
11
- const addNotificationServiceExtensionFile = async (
11
+ const addNotificationSwiftFile = async (
12
12
  options: CustomerIOPluginOptionsIOS
13
13
  ) => {
14
14
  const { iosPath, appName } = options;
15
-
16
15
  const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
17
-
18
16
  const xcodeProject = xcode.project(projPath);
19
17
 
20
18
  xcodeProject.parse(async function (err: Error) {
21
- if (err) {
22
- throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
23
- }
24
-
25
- fs.mkdirSync(`${iosPath}/${appName}`, {
26
- recursive: true,
27
- });
28
-
29
19
  const file = 'PushNotification.swift';
30
-
31
20
  const getTargetFile = (filename: string) =>
32
21
  `${iosPath}/${appName}/${filename}`;
22
+ if (err) {
23
+ throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
24
+ }
33
25
 
34
- const targetFile = getTargetFile(file);
35
- fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
36
-
37
- // Create new PBXGroup for the extension
38
- const extGroup = xcodeProject.addPbxGroup([file], appName, appName);
39
-
40
- // Add the new PBXGroup to the top level group. This makes the
41
- // files / folder appear in the file explorer in Xcode.
42
- const groups = xcodeProject.hash.project.objects['PBXGroup'];
43
- Object.keys(groups).forEach((key) => {
44
- if (groups[key].name === undefined) {
45
- xcodeProject.addToPbxGroup(extGroup.uuid, key);
46
- }
47
- });
48
-
49
- // WORK AROUND for codeProject.addTarget BUG
50
- // Xcode projects don't contain these if there is only one target
51
- // An upstream fix should be made to the code referenced in this link:
52
- // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
53
- const projObjects = xcodeProject.hash.project.objects;
54
- projObjects['PBXTargetDependency'] =
55
- projObjects['PBXTargetDependency'] || {};
56
- projObjects['PBXContainerItemProxy'] =
57
- projObjects['PBXTargetDependency'] || {};
26
+ if (!FileManagement.exists(getTargetFile(file))) {
27
+ FileManagement.mkdir(`${iosPath}/${appName}`, {
28
+ recursive: true,
29
+ });
58
30
 
59
- fs.writeFileSync(projPath, xcodeProject.writeSync());
31
+ const targetFile = getTargetFile(file);
32
+ FileManagement.copyFile(
33
+ `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,
34
+ targetFile
35
+ );
36
+ } else {
37
+ console.log(`${getTargetFile(file)} already exists. Skipping...`);
38
+ }
60
39
  });
61
40
  };
62
41
 
@@ -97,13 +76,13 @@ export const withCioAppdelegateXcodeProject: ConfigPlugin<
97
76
  appleTeamId,
98
77
  bundleIdentifier,
99
78
  bundleShortVersion,
100
- bundleVersion: buildNumber ?? DEFAULT_BUNDLE_VERSION,
79
+ bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,
101
80
  iosPath: platformProjectRoot,
102
81
  appName: projectName,
103
82
  iosDeploymentTarget,
104
83
  };
105
84
 
106
- await addNotificationServiceExtensionFile(options);
85
+ await addNotificationSwiftFile(options);
107
86
 
108
87
  return config;
109
88
  });
@@ -10,10 +10,16 @@ export function withCIOIos(
10
10
  config: ExpoConfig,
11
11
  props: CustomerIOPluginOptionsIOS
12
12
  ) {
13
- config = withCioNotificationsXcodeProject(config, props);
14
- config = withAppDelegateModifications(config, props);
13
+ if (props.pushNotification?.useRichPush) {
14
+ config = withCioNotificationsXcodeProject(config, props);
15
+ }
16
+
17
+ if (props.pushNotification) {
18
+ config = withAppDelegateModifications(config, props);
19
+ config = withCioAppdelegateXcodeProject(config, props);
20
+ }
21
+
15
22
  config = withCioXcodeProject(config, props);
16
- config = withCioAppdelegateXcodeProject(config, props);
17
23
 
18
24
  return config;
19
25
  }
@@ -1,5 +1,4 @@
1
1
  import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';
2
- import fs from 'fs';
3
2
  import xcode from 'xcode';
4
3
 
5
4
  import {
@@ -7,8 +6,10 @@ import {
7
6
  DEFAULT_BUNDLE_VERSION,
8
7
  LOCAL_PATH_TO_CIO_NSE_FILES,
9
8
  } from '../helpers/constants/ios';
9
+ import { injectCodeByMultiLineRegex } from '../helpers/utils/codeInjection';
10
10
  import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
11
11
  import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
12
+ import { FileManagement } from './../helpers/utils/fileManagement';
12
13
 
13
14
  const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
14
15
 
@@ -38,15 +39,15 @@ const addNotificationServiceExtension = async (
38
39
 
39
40
  await injectCIONotificationPodfileCode(iosPath);
40
41
 
41
- fs.mkdirSync(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {
42
+ FileManagement.mkdir(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {
42
43
  recursive: true,
43
44
  });
44
45
 
45
46
  const files = [
46
47
  PLIST_FILENAME,
47
- 'CIONotificationService.h',
48
- 'CIONotificationService.swift',
49
- 'CIONotificationService.m',
48
+ 'NotificationService.h',
49
+ 'NotificationService.swift',
50
+ 'NotificationService.m',
50
51
  ];
51
52
 
52
53
  const getTargetFile = (filename: string) =>
@@ -54,7 +55,10 @@ const addNotificationServiceExtension = async (
54
55
 
55
56
  files.forEach((filename) => {
56
57
  const targetFile = getTargetFile(filename);
57
- fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
58
+ FileManagement.copyFile(
59
+ `${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,
60
+ targetFile
61
+ );
58
62
  });
59
63
 
60
64
  /* MODIFY COPIED EXTENSION FILES */
@@ -109,7 +113,7 @@ const addNotificationServiceExtension = async (
109
113
 
110
114
  // Add build phases to the new target
111
115
  xcodeProject.addBuildPhase(
112
- ['CIONotificationService.m', 'CIONotificationService.swift'],
116
+ ['NotificationService.m', 'NotificationService.swift'],
113
117
  'PBXSourcesBuildPhase',
114
118
  'Sources',
115
119
  nseTarget.uuid
@@ -139,7 +143,7 @@ const addNotificationServiceExtension = async (
139
143
  const buildSettingsObj = configurations[key].buildSettings;
140
144
  buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
141
145
  buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =
142
- iosDeploymentTarget ?? '13.0';
146
+ iosDeploymentTarget || '13.0';
143
147
  buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
144
148
  buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
145
149
  buildSettingsObj.SWIFT_VERSION = 4.2;
@@ -150,7 +154,7 @@ const addNotificationServiceExtension = async (
150
154
  xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
151
155
  xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
152
156
 
153
- fs.writeFileSync(projPath, xcodeProject.writeSync());
157
+ FileManagement.writeFile(projPath, xcodeProject.writeSync());
154
158
  });
155
159
  };
156
160
 
@@ -163,7 +167,7 @@ export const withCioNotificationsXcodeProject: ConfigPlugin<
163
167
 
164
168
  if (ios === undefined)
165
169
  throw new Error(
166
- 'Adding NotificationServiceExtension failed: ios config missing from app.config.js.'
170
+ 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'
167
171
  );
168
172
 
169
173
  const { projectName, platformProjectRoot } = modRequest;
@@ -171,19 +175,19 @@ export const withCioNotificationsXcodeProject: ConfigPlugin<
171
175
 
172
176
  if (bundleShortVersion === undefined) {
173
177
  throw new Error(
174
- 'Adding NotificationServiceExtension failed: version missing from app.config.js'
178
+ 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'
175
179
  );
176
180
  }
177
181
 
178
182
  if (bundleIdentifier === undefined) {
179
183
  throw new Error(
180
- 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js'
184
+ 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'
181
185
  );
182
186
  }
183
187
 
184
188
  if (projectName === undefined) {
185
189
  throw new Error(
186
- 'Adding NotificationServiceExtension failed: name missing from app.config.js'
190
+ 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'
187
191
  );
188
192
  }
189
193
 
@@ -191,7 +195,7 @@ export const withCioNotificationsXcodeProject: ConfigPlugin<
191
195
  appleTeamId,
192
196
  bundleIdentifier,
193
197
  bundleShortVersion,
194
- bundleVersion: buildNumber ?? DEFAULT_BUNDLE_VERSION,
198
+ bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,
195
199
  iosPath: platformProjectRoot,
196
200
  appName: projectName,
197
201
  iosDeploymentTarget,
@@ -211,21 +215,23 @@ const updateNseInfoPlist = (payload: {
211
215
  const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
212
216
  const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
213
217
 
214
- let plistFileString = fs.readFileSync(payload.infoPlistTargetFile, 'utf-8');
218
+ let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);
215
219
 
216
220
  if (payload.bundleVersion) {
217
- plistFileString = plistFileString.replace(
221
+ plistFileString = injectCodeByMultiLineRegex(
222
+ plistFileString,
218
223
  BUNDLE_VERSION_RE,
219
224
  payload.bundleVersion
220
225
  );
221
226
  }
222
227
 
223
228
  if (payload.bundleShortVersion) {
224
- plistFileString = plistFileString.replace(
229
+ plistFileString = injectCodeByMultiLineRegex(
230
+ plistFileString,
225
231
  BUNDLE_SHORT_VERSION_RE,
226
232
  payload.bundleShortVersion
227
233
  );
228
234
  }
229
235
 
230
- fs.writeFileSync(payload.infoPlistTargetFile, plistFileString);
236
+ FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
231
237
  };
@@ -15,6 +15,9 @@ export type CustomerIOPluginOptionsIOS = {
15
15
  iosDeploymentTarget?: string;
16
16
  appleTeamId?: string;
17
17
  appName?: string;
18
+ pushNotification?: {
19
+ useRichPush: boolean;
20
+ };
18
21
  };
19
22
 
20
23
  export type CustomerIOPluginOptionsAndroid = {
@@ -22,7 +25,7 @@ export type CustomerIOPluginOptionsAndroid = {
22
25
  googleServicesFilePath?: string;
23
26
  };
24
27
 
25
- export enum Mode {
26
- Dev = 'development',
27
- Prod = 'production',
28
- }
28
+ export type CustomerIOPluginOptions = {
29
+ android: CustomerIOPluginOptionsAndroid;
30
+ ios: CustomerIOPluginOptionsIOS;
31
+ };
package/src/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const LIB_VERSION = "1.0.0-alpha.3";