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

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 (143) hide show
  1. package/lib/commonjs/android/withAppGoogleServices.js +16 -0
  2. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -0
  3. package/lib/commonjs/android/withCIOAndroid.js +18 -0
  4. package/lib/commonjs/android/withCIOAndroid.js.map +1 -0
  5. package/lib/commonjs/android/withGistMavenRepository.js +16 -0
  6. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -0
  7. package/lib/commonjs/android/withGoogleServicesJSON.js +30 -0
  8. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -0
  9. package/lib/commonjs/android/withProjectGoogleServices.js +16 -0
  10. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -0
  11. package/lib/commonjs/helpers/constants/android.js +19 -0
  12. package/lib/commonjs/helpers/constants/android.js.map +1 -0
  13. package/lib/commonjs/helpers/constants/globals.d.js +2 -0
  14. package/lib/commonjs/helpers/constants/globals.d.js.map +1 -0
  15. package/lib/commonjs/helpers/constants/ios.js +138 -0
  16. package/lib/commonjs/helpers/constants/ios.js.map +1 -0
  17. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService-Info.plist +0 -0
  18. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.h +0 -0
  19. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.m +0 -0
  20. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/CIONotificationService.swift +0 -0
  21. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/PushNotification.swift +0 -0
  22. package/lib/commonjs/helpers/utils/codeInjection.js +33 -0
  23. package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
  24. package/lib/commonjs/helpers/utils/fileManagement.js +44 -0
  25. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -0
  26. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +32 -0
  27. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  28. package/lib/commonjs/index.js +17 -0
  29. package/lib/commonjs/index.js.map +1 -0
  30. package/lib/commonjs/ios/withAppDelegateModifications.js +76 -0
  31. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
  32. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +96 -0
  33. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -0
  34. package/lib/commonjs/ios/withCIOIos.js +18 -0
  35. package/lib/commonjs/ios/withCIOIos.js.map +1 -0
  36. package/lib/commonjs/ios/withNotificationsXcodeProject.js +157 -0
  37. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
  38. package/lib/commonjs/ios/withXcodeProject.js +28 -0
  39. package/lib/commonjs/ios/withXcodeProject.js.map +1 -0
  40. package/lib/commonjs/types/cio-types.js +15 -0
  41. package/lib/commonjs/types/cio-types.js.map +1 -0
  42. package/lib/module/android/withAppGoogleServices.js +9 -0
  43. package/lib/module/android/withAppGoogleServices.js.map +1 -0
  44. package/lib/module/android/withCIOAndroid.js +12 -0
  45. package/lib/module/android/withCIOAndroid.js.map +1 -0
  46. package/lib/module/android/withGistMavenRepository.js +9 -0
  47. package/lib/module/android/withGistMavenRepository.js.map +1 -0
  48. package/lib/module/android/withGoogleServicesJSON.js +23 -0
  49. package/lib/module/android/withGoogleServicesJSON.js.map +1 -0
  50. package/lib/module/android/withProjectGoogleServices.js +9 -0
  51. package/lib/module/android/withProjectGoogleServices.js.map +1 -0
  52. package/lib/module/helpers/constants/android.js +7 -0
  53. package/lib/module/helpers/constants/android.js.map +1 -0
  54. package/lib/module/helpers/constants/globals.d.js +2 -0
  55. package/lib/module/helpers/constants/globals.d.js.map +1 -0
  56. package/lib/module/helpers/constants/ios.js +102 -0
  57. package/lib/module/helpers/constants/ios.js.map +1 -0
  58. package/lib/module/helpers/native-files/ios/CIONotificationService-Info.plist +31 -0
  59. package/lib/module/helpers/native-files/ios/CIONotificationService.h +5 -0
  60. package/lib/module/helpers/native-files/ios/CIONotificationService.m +30 -0
  61. package/lib/module/helpers/native-files/ios/CIONotificationService.swift +21 -0
  62. package/lib/module/helpers/native-files/ios/PushNotification.swift +56 -0
  63. package/lib/module/helpers/utils/codeInjection.js +24 -0
  64. package/lib/module/helpers/utils/codeInjection.js.map +1 -0
  65. package/lib/module/helpers/utils/fileManagement.js +37 -0
  66. package/lib/module/helpers/utils/fileManagement.js.map +1 -0
  67. package/lib/module/helpers/utils/injectCIOPodfileCode.js +25 -0
  68. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  69. package/lib/module/index.js +10 -0
  70. package/lib/module/index.js.map +1 -0
  71. package/lib/module/ios/withAppDelegateModifications.js +69 -0
  72. package/lib/module/ios/withAppDelegateModifications.js.map +1 -0
  73. package/lib/module/ios/withAppDelegateXcodeProject.js +88 -0
  74. package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -0
  75. package/lib/module/ios/withCIOIos.js +12 -0
  76. package/lib/module/ios/withCIOIos.js.map +1 -0
  77. package/lib/module/ios/withNotificationsXcodeProject.js +149 -0
  78. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
  79. package/lib/module/ios/withXcodeProject.js +21 -0
  80. package/lib/module/ios/withXcodeProject.js.map +1 -0
  81. package/lib/module/types/cio-types.js +10 -0
  82. package/lib/module/types/cio-types.js.map +1 -0
  83. package/lib/typescript/android/withAppGoogleServices.d.ts +3 -0
  84. package/lib/typescript/android/withCIOAndroid.d.ts +3 -0
  85. package/lib/typescript/android/withGistMavenRepository.d.ts +3 -0
  86. package/lib/typescript/android/withGoogleServicesJSON.d.ts +3 -0
  87. package/lib/typescript/android/withProjectGoogleServices.d.ts +3 -0
  88. package/lib/typescript/helpers/constants/android.d.ts +6 -0
  89. package/lib/typescript/helpers/constants/ios.d.ts +30 -0
  90. package/lib/typescript/helpers/utils/codeInjection.d.ts +4 -0
  91. package/lib/typescript/helpers/utils/fileManagement.d.ts +5 -0
  92. package/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -0
  93. package/lib/typescript/index.d.ts +4 -0
  94. package/lib/typescript/ios/withAppDelegateModifications.d.ts +2 -0
  95. package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +3 -0
  96. package/lib/typescript/ios/withCIOIos.d.ts +3 -0
  97. package/lib/typescript/ios/withNotificationsXcodeProject.d.ts +3 -0
  98. package/lib/typescript/ios/withXcodeProject.d.ts +3 -0
  99. package/lib/typescript/types/cio-types.d.ts +22 -0
  100. package/package.json +87 -13
  101. package/src/android/withAppGoogleServices.ts +19 -0
  102. package/src/android/withCIOAndroid.ts +19 -0
  103. package/src/android/withGistMavenRepository.ts +19 -0
  104. package/src/android/withGoogleServicesJSON.ts +30 -0
  105. package/src/android/withProjectGoogleServices.ts +19 -0
  106. package/src/helpers/constants/android.ts +12 -0
  107. package/src/helpers/constants/globals.d.ts +8 -0
  108. package/src/helpers/constants/ios.ts +116 -0
  109. package/src/helpers/native-files/ios/CIONotificationService-Info.plist +31 -0
  110. package/src/helpers/native-files/ios/CIONotificationService.h +5 -0
  111. package/src/helpers/native-files/ios/CIONotificationService.m +30 -0
  112. package/src/helpers/native-files/ios/CIONotificationService.swift +21 -0
  113. package/src/helpers/native-files/ios/PushNotification.swift +56 -0
  114. package/src/helpers/utils/codeInjection.ts +46 -0
  115. package/src/helpers/utils/fileManagement.ts +39 -0
  116. package/src/helpers/utils/injectCIOPodfileCode.ts +47 -0
  117. package/src/index.ts +21 -0
  118. package/src/ios/withAppDelegateModifications.ts +150 -0
  119. package/src/ios/withAppDelegateXcodeProject.ts +110 -0
  120. package/src/ios/withCIOIos.ts +19 -0
  121. package/src/ios/withNotificationsXcodeProject.ts +231 -0
  122. package/src/ios/withXcodeProject.ts +25 -0
  123. package/src/types/cio-types.ts +28 -0
  124. package/build/helpers/.DS_Store +0 -0
  125. package/build/helpers/ios/.DS_Store +0 -0
  126. package/build/package.json +0 -36
  127. package/build/src/android/withAppGoogleServices.js +0 -12
  128. package/build/src/android/withCIOAndroid.js +0 -15
  129. package/build/src/android/withGistMavenRepository.js +0 -12
  130. package/build/src/android/withGoogleServicesJSON.js +0 -24
  131. package/build/src/android/withProjectGoogleServices.js +0 -12
  132. package/build/src/helpers/constants/android.js +0 -9
  133. package/build/src/helpers/constants/ios.js +0 -102
  134. package/build/src/helpers/utils/codeInjection.js +0 -30
  135. package/build/src/helpers/utils/fileManagement.js +0 -40
  136. package/build/src/helpers/utils/injectCIOPodfileCode.js +0 -37
  137. package/build/src/index.js +0 -11
  138. package/build/src/ios/withAppDelegateModifications.js +0 -77
  139. package/build/src/ios/withAppDelegateXcodeProject.js +0 -78
  140. package/build/src/ios/withCIOIos.js +0 -15
  141. package/build/src/ios/withNotificationsXcodeProject.js +0 -133
  142. package/build/src/ios/withXcodeProject.js +0 -22
  143. package/build/src/types/cio-types.js +0 -8
@@ -0,0 +1,19 @@
1
+ import type { ExpoConfig } from '@expo/config-types';
2
+
3
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
4
+ import { withAppDelegateModifications } from './withAppDelegateModifications';
5
+ import { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';
6
+ import { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';
7
+ import { withCioXcodeProject } from './withXcodeProject';
8
+
9
+ export function withCIOIos(
10
+ config: ExpoConfig,
11
+ props: CustomerIOPluginOptionsIOS
12
+ ) {
13
+ config = withCioNotificationsXcodeProject(config, props);
14
+ config = withAppDelegateModifications(config, props);
15
+ config = withCioXcodeProject(config, props);
16
+ config = withCioAppdelegateXcodeProject(config, props);
17
+
18
+ return config;
19
+ }
@@ -0,0 +1,231 @@
1
+ import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';
2
+ import fs from 'fs';
3
+ import xcode from 'xcode';
4
+
5
+ import {
6
+ CIO_NOTIFICATION_TARGET_NAME,
7
+ DEFAULT_BUNDLE_VERSION,
8
+ LOCAL_PATH_TO_CIO_NSE_FILES,
9
+ } from '../helpers/constants/ios';
10
+ import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
11
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
12
+
13
+ const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
14
+
15
+ const TARGETED_DEVICE_FAMILY = `"1,2"`;
16
+
17
+ const addNotificationServiceExtension = async (
18
+ options: CustomerIOPluginOptionsIOS
19
+ ) => {
20
+ const {
21
+ appleTeamId,
22
+ bundleIdentifier,
23
+ bundleShortVersion,
24
+ bundleVersion,
25
+ iosPath,
26
+ appName,
27
+ iosDeploymentTarget,
28
+ } = options;
29
+
30
+ const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
31
+
32
+ const xcodeProject = xcode.project(projPath);
33
+
34
+ xcodeProject.parse(async function (err: Error) {
35
+ if (err) {
36
+ throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
37
+ }
38
+
39
+ await injectCIONotificationPodfileCode(iosPath);
40
+
41
+ fs.mkdirSync(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {
42
+ recursive: true,
43
+ });
44
+
45
+ const files = [
46
+ PLIST_FILENAME,
47
+ 'CIONotificationService.h',
48
+ 'CIONotificationService.swift',
49
+ 'CIONotificationService.m',
50
+ ];
51
+
52
+ const getTargetFile = (filename: string) =>
53
+ `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${filename}`;
54
+
55
+ files.forEach((filename) => {
56
+ const targetFile = getTargetFile(filename);
57
+ fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
58
+ });
59
+
60
+ /* MODIFY COPIED EXTENSION FILES */
61
+ const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);
62
+ updateNseInfoPlist({
63
+ bundleVersion,
64
+ bundleShortVersion,
65
+ infoPlistTargetFile,
66
+ });
67
+
68
+ // Create new PBXGroup for the extension
69
+ const extGroup = xcodeProject.addPbxGroup(
70
+ files,
71
+ CIO_NOTIFICATION_TARGET_NAME,
72
+ CIO_NOTIFICATION_TARGET_NAME
73
+ );
74
+
75
+ // Add the new PBXGroup to the top level group. This makes the
76
+ // files / folder appear in the file explorer in Xcode.
77
+ const groups = xcodeProject.hash.project.objects['PBXGroup'];
78
+ Object.keys(groups).forEach((key) => {
79
+ if (groups[key].name === undefined) {
80
+ xcodeProject.addToPbxGroup(extGroup.uuid, key);
81
+ }
82
+ });
83
+
84
+ // WORK AROUND for codeProject.addTarget BUG
85
+ // Xcode projects don't contain these if there is only one target
86
+ // An upstream fix should be made to the code referenced in this link:
87
+ // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
88
+ const projObjects = xcodeProject.hash.project.objects;
89
+ projObjects['PBXTargetDependency'] =
90
+ projObjects['PBXTargetDependency'] || {};
91
+ projObjects['PBXContainerItemProxy'] =
92
+ projObjects['PBXTargetDependency'] || {};
93
+
94
+ if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
95
+ console.warn(
96
+ `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`
97
+ );
98
+ return;
99
+ }
100
+
101
+ // Add the NSE target
102
+ // This also adds PBXTargetDependency and PBXContainerItemProxy
103
+ const nseTarget = xcodeProject.addTarget(
104
+ CIO_NOTIFICATION_TARGET_NAME,
105
+ 'app_extension',
106
+ CIO_NOTIFICATION_TARGET_NAME,
107
+ `${bundleIdentifier}.richpush`
108
+ );
109
+
110
+ // Add build phases to the new target
111
+ xcodeProject.addBuildPhase(
112
+ ['CIONotificationService.m', 'CIONotificationService.swift'],
113
+ 'PBXSourcesBuildPhase',
114
+ 'Sources',
115
+ nseTarget.uuid
116
+ );
117
+ xcodeProject.addBuildPhase(
118
+ [],
119
+ 'PBXResourcesBuildPhase',
120
+ 'Resources',
121
+ nseTarget.uuid
122
+ );
123
+
124
+ xcodeProject.addBuildPhase(
125
+ [],
126
+ 'PBXFrameworksBuildPhase',
127
+ 'Frameworks',
128
+ nseTarget.uuid
129
+ );
130
+
131
+ // Edit the Deployment info of the target
132
+ const configurations = xcodeProject.pbxXCBuildConfigurationSection();
133
+ for (const key in configurations) {
134
+ if (
135
+ typeof configurations[key].buildSettings !== 'undefined' &&
136
+ configurations[key].buildSettings.PRODUCT_NAME ===
137
+ `"${CIO_NOTIFICATION_TARGET_NAME}"`
138
+ ) {
139
+ const buildSettingsObj = configurations[key].buildSettings;
140
+ buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
141
+ buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =
142
+ iosDeploymentTarget ?? '13.0';
143
+ buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
144
+ buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
145
+ buildSettingsObj.SWIFT_VERSION = 4.2;
146
+ }
147
+ }
148
+
149
+ // Add development team to the target & the main
150
+ xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
151
+ xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
152
+
153
+ fs.writeFileSync(projPath, xcodeProject.writeSync());
154
+ });
155
+ };
156
+
157
+ export const withCioNotificationsXcodeProject: ConfigPlugin<
158
+ CustomerIOPluginOptionsIOS
159
+ > = (configOuter, props) => {
160
+ return withXcodeProject(configOuter, async (config) => {
161
+ const { modRequest, ios, version: bundleShortVersion } = config;
162
+ const { appleTeamId, iosDeploymentTarget } = props;
163
+
164
+ if (ios === undefined)
165
+ throw new Error(
166
+ 'Adding NotificationServiceExtension failed: ios config missing from app.config.js.'
167
+ );
168
+
169
+ const { projectName, platformProjectRoot } = modRequest;
170
+ const { bundleIdentifier, buildNumber } = ios;
171
+
172
+ if (bundleShortVersion === undefined) {
173
+ throw new Error(
174
+ 'Adding NotificationServiceExtension failed: version missing from app.config.js'
175
+ );
176
+ }
177
+
178
+ if (bundleIdentifier === undefined) {
179
+ throw new Error(
180
+ 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js'
181
+ );
182
+ }
183
+
184
+ if (projectName === undefined) {
185
+ throw new Error(
186
+ 'Adding NotificationServiceExtension failed: name missing from app.config.js'
187
+ );
188
+ }
189
+
190
+ const options = {
191
+ appleTeamId,
192
+ bundleIdentifier,
193
+ bundleShortVersion,
194
+ bundleVersion: buildNumber ?? DEFAULT_BUNDLE_VERSION,
195
+ iosPath: platformProjectRoot,
196
+ appName: projectName,
197
+ iosDeploymentTarget,
198
+ };
199
+
200
+ await addNotificationServiceExtension(options);
201
+
202
+ return config;
203
+ });
204
+ };
205
+
206
+ const updateNseInfoPlist = (payload: {
207
+ bundleVersion?: string;
208
+ bundleShortVersion?: string;
209
+ infoPlistTargetFile: string;
210
+ }) => {
211
+ const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
212
+ const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
213
+
214
+ let plistFileString = fs.readFileSync(payload.infoPlistTargetFile, 'utf-8');
215
+
216
+ if (payload.bundleVersion) {
217
+ plistFileString = plistFileString.replace(
218
+ BUNDLE_VERSION_RE,
219
+ payload.bundleVersion
220
+ );
221
+ }
222
+
223
+ if (payload.bundleShortVersion) {
224
+ plistFileString = plistFileString.replace(
225
+ BUNDLE_SHORT_VERSION_RE,
226
+ payload.bundleShortVersion
227
+ );
228
+ }
229
+
230
+ fs.writeFileSync(payload.infoPlistTargetFile, plistFileString);
231
+ };
@@ -0,0 +1,25 @@
1
+ import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';
2
+
3
+ import { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
4
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
5
+
6
+ export const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (
7
+ config,
8
+ cioProps
9
+ ) => {
10
+ return withXcodeProject(config, async (props) => {
11
+ const options: CustomerIOPluginOptionsIOS = {
12
+ iosPath: props.modRequest.platformProjectRoot,
13
+ bundleIdentifier: props.ios?.bundleIdentifier,
14
+ devTeam: cioProps?.devTeam,
15
+ bundleVersion: props.ios?.buildNumber,
16
+ bundleShortVersion: props?.version,
17
+ iosDeploymentTarget: cioProps?.iosDeploymentTarget,
18
+ };
19
+ const { iosPath } = options;
20
+
21
+ await injectCIOPodfileCode(iosPath);
22
+
23
+ return props;
24
+ });
25
+ };
@@ -0,0 +1,28 @@
1
+ // properties set by the user in their app config file (e.g: app.json or app.plugin.js)
2
+ export type CustomerIOPluginProperties = {
3
+ // (iOS only) Environment name and bundle identifier
4
+ devTeam: string;
5
+ iosDeploymentTarget: string;
6
+ };
7
+
8
+ // Plugin options for pre-build
9
+ export type CustomerIOPluginOptionsIOS = {
10
+ iosPath: string;
11
+ devTeam?: string;
12
+ bundleVersion?: string;
13
+ bundleShortVersion?: string;
14
+ bundleIdentifier?: string;
15
+ iosDeploymentTarget?: string;
16
+ appleTeamId?: string;
17
+ appName?: string;
18
+ };
19
+
20
+ export type CustomerIOPluginOptionsAndroid = {
21
+ androidPath: string;
22
+ googleServicesFilePath?: string;
23
+ };
24
+
25
+ export enum Mode {
26
+ Dev = 'development',
27
+ Prod = 'production',
28
+ }
Binary file
Binary file
@@ -1,36 +0,0 @@
1
- {
2
- "name": "customerio-expo-plugin",
3
- "version": "0.0.5",
4
- "description": "Expo config plugin for the Customer IO React Native SDK",
5
- "main": "build/src/index.js",
6
- "types": "build/index.d.ts",
7
- "license": "MIT",
8
- "files": [
9
- "build/**/*"
10
- ],
11
- "scripts": {
12
- "copy-native-files": "cp -r src/helpers/native-files build/helpers/",
13
- "build": "rm -rf build && tsc && npm run copy-native-files",
14
- "build:watch": "npm run build && tsc --watch",
15
- "clean": "rm -rf build",
16
- "expo-module": "expo-module",
17
- "lint": "eslint .",
18
- "tc": "tsc --noEmit",
19
- "prepare": "npm run clean && npm run build",
20
- "prepublishOnly": "npm run tc && npm run lint"
21
- },
22
- "devDependencies": {
23
- "@expo/config-plugins": "^4.1.4",
24
- "@expo/config-types": "^44.0.0",
25
- "@typescript-eslint/eslint-plugin": "^5.21.0",
26
- "@typescript-eslint/parser": "^5.21.0",
27
- "eslint": "^8.14.0",
28
- "eslint-config-prettier": "^8.5.0",
29
- "eslint-plugin-prettier": "^4.0.0",
30
- "expo-module-scripts": "^2.0.0",
31
- "expo-build-properties": "^0.2.0",
32
- "prettier": "^2.6.2",
33
- "typescript": "^4.6.4",
34
- "xcode": "^3.0.1"
35
- }
36
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withAppGoogleServices = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
5
- const android_1 = require("../helpers/constants/android");
6
- const withAppGoogleServices = (configOuter) => {
7
- return (0, config_plugins_1.withAppBuildGradle)(configOuter, (props) => {
8
- props.modResults.contents = props.modResults.contents.replace(android_1.CIO_APP_APPLY_REGEX, `$1\n${android_1.CIO_APP_GOOGLE_SNIPPET}`);
9
- return props;
10
- });
11
- };
12
- exports.withAppGoogleServices = withAppGoogleServices;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withCIOAndroid = void 0;
4
- const withAppGoogleServices_1 = require("./withAppGoogleServices");
5
- const withGistMavenRepository_1 = require("./withGistMavenRepository");
6
- const withGoogleServicesJSON_1 = require("./withGoogleServicesJSON");
7
- const withProjectGoogleServices_1 = require("./withProjectGoogleServices");
8
- function withCIOAndroid(config, props) {
9
- config = (0, withGistMavenRepository_1.withGistMavenRepository)(config, props);
10
- config = (0, withProjectGoogleServices_1.withProjectGoogleServices)(config, props);
11
- config = (0, withAppGoogleServices_1.withAppGoogleServices)(config, props);
12
- config = (0, withGoogleServicesJSON_1.withGoogleServicesJSON)(config, props);
13
- return config;
14
- }
15
- exports.withCIOAndroid = withCIOAndroid;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withGistMavenRepository = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
5
- const android_1 = require("../helpers/constants/android");
6
- const withGistMavenRepository = (configOuter) => {
7
- return (0, config_plugins_1.withProjectBuildGradle)(configOuter, (props) => {
8
- props.modResults.contents = props.modResults.contents.replace(android_1.CIO_PROJECT_ALLPROJECTS_REGEX, `$1\n${android_1.CIO_PROJECT_GIST_MAVEN_SNIPPET}`);
9
- return props;
10
- });
11
- };
12
- exports.withGistMavenRepository = withGistMavenRepository;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withGoogleServicesJSON = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
5
- const fs_1 = require("fs");
6
- const withGoogleServicesJSON = (configOuter, cioProps) => {
7
- return (0, config_plugins_1.withProjectBuildGradle)(configOuter, (props) => {
8
- const options = {
9
- androidPath: props.modRequest.platformProjectRoot,
10
- googleServicesFilePath: cioProps === null || cioProps === void 0 ? void 0 : cioProps.googleServicesFilePath,
11
- };
12
- const { androidPath, googleServicesFilePath } = options;
13
- if (googleServicesFilePath) {
14
- try {
15
- (0, fs_1.copyFileSync)(`${googleServicesFilePath}google-services.json`, `${androidPath}/app/google-services.json`);
16
- }
17
- catch (e) {
18
- console.log('There was an error copying your google-services.json file.');
19
- }
20
- }
21
- return props;
22
- });
23
- };
24
- exports.withGoogleServicesJSON = withGoogleServicesJSON;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withProjectGoogleServices = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
5
- const android_1 = require("./../helpers/constants/android");
6
- const withProjectGoogleServices = (configOuter) => {
7
- return (0, config_plugins_1.withProjectBuildGradle)(configOuter, (props) => {
8
- props.modResults.contents = props.modResults.contents.replace(android_1.CIO_PROJECT_BUILDSCRIPTS_REGEX, `$1\n${android_1.CIO_PROJECT_GOOGLE_SNIPPET}`);
9
- return props;
10
- });
11
- };
12
- exports.withProjectGoogleServices = withProjectGoogleServices;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CIO_PROJECT_GOOGLE_SNIPPET = exports.CIO_APP_GOOGLE_SNIPPET = exports.CIO_PROJECT_GIST_MAVEN_SNIPPET = exports.CIO_PROJECT_ALLPROJECTS_REGEX = exports.CIO_APP_APPLY_REGEX = exports.CIO_PROJECT_BUILDSCRIPTS_REGEX = void 0;
4
- exports.CIO_PROJECT_BUILDSCRIPTS_REGEX = /(buildscript\s*\{(.|\n)*dependencies\s*\{)/;
5
- exports.CIO_APP_APPLY_REGEX = /(apply plugin: "com.android.application")/;
6
- exports.CIO_PROJECT_ALLPROJECTS_REGEX = /(allprojects\s*\{(.|\n)*repositories\s*\{)/;
7
- exports.CIO_PROJECT_GIST_MAVEN_SNIPPET = ' maven { url "https://maven.gist.build" }';
8
- exports.CIO_APP_GOOGLE_SNIPPET = 'apply plugin: "com.google.gms.google-services" // Google Services plugin';
9
- exports.CIO_PROJECT_GOOGLE_SNIPPET = ' classpath "com.google.gms:google-services:4.3.13" // Google Services plugin';
@@ -1,102 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = exports.CIO_PODFILE_POST_INSTALL_SNIPPET = exports.CIO_PODFILE_TARGET_NAMES_SNIPPET = exports.CIO_PODFILE_SNIPPET = exports.CIO_PODFILE_NOTIFICATION_SNIPPET = exports.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = exports.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_APPDELEGATEHEADER_SNIPPET = exports.CIO_NOTIFICATION_TARGET_NAME = exports.CIO_TARGET_NAME = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.DEFAULT_BUNDLE_VERSION = exports.CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEDECLARATION_REGEX = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_PODFILE_POST_INSTALL_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.CIO_PODFILE_NOTIFICATION_REGEX = exports.CIO_PODFILE_REGEX = exports.IOS_DEPLOYMENT_TARGET = exports.LOCAL_PATH_TO_CIO_NSE_FILES = void 0;
4
- const package_json_1 = require("../../../package.json");
5
- exports.LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/${package_json_1.name}/build/helpers/ios`;
6
- exports.IOS_DEPLOYMENT_TARGET = '13.0';
7
- exports.CIO_PODFILE_REGEX = /pod 'RCT-Folly'/;
8
- exports.CIO_PODFILE_NOTIFICATION_REGEX = /target 'CIONotificationService' do/;
9
- exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
10
- exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
11
- exports.BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
12
- exports.CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \|installer\|/;
13
- exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = /(- \(BOOL\)application:\(UIApplication \*\)application didFinishLaunchingWithOptions:\(NSDictionary \*\)launchOptions(\s|\n)*?\{)((.|\n)*)\[super(\s)application:application(\s)didFinishLaunchingWithOptions:launchOptions\];/;
14
- exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = /return \[super application:application didFailToRegisterForRemoteNotificationsWithError:error\];/;
15
- exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = /(- \(void\)application:\(UIApplication \*\)application didFailToRegisterForRemoteNotificationsWithError:\(NSError \*\)error(\s|\n)*?\{)(.|\n){2}.*\n\}/;
16
- exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = /return \[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\];/;
17
- exports.CIO_APPDELEGATEDECLARATION_REGEX = /@implementation AppDelegate(.|\n)/;
18
- exports.CIO_APPDELEGATEHEADER_REGEX = /@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate>/;
19
- exports.DEFAULT_BUNDLE_VERSION = '1';
20
- exports.DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
21
- exports.CIO_TARGET_NAME = 'CustomerIOSDK';
22
- exports.CIO_NOTIFICATION_TARGET_NAME = 'CIONotificationService';
23
- exports.CIO_APPDELEGATEHEADER_SNIPPET = `
24
- #import <UserNotifications/UserNotifications.h>
25
-
26
- @interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>
27
- `;
28
- exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `
29
- CIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];
30
- `;
31
- exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `
32
- [pnHandlerObj application:application error:error];
33
- `;
34
- exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `
35
- return [pnHandlerObj application:application deviceToken:deviceToken];
36
- `;
37
- // Configure Customerio push notifications SDK by adding to application:didFinishLaunchingWithOptions: delegate method
38
- // From Braze docs: https://www.customer.io/docs/sdk/react-native/push/#obj-c-push
39
- exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `
40
- // Register for push notifications
41
- [pnHandlerObj registerPushNotification:self];
42
- `;
43
- // Enable push handling - notification response
44
- exports.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `
45
- - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
46
- [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
47
- }`;
48
- // Foreground push handling
49
- exports.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `
50
- // show push when the app is in foreground
51
- - (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
52
- completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);
53
- }`;
54
- exports.CIO_PODFILE_NOTIFICATION_SNIPPET = `
55
- target '${exports.CIO_NOTIFICATION_TARGET_NAME}' do
56
- pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'
57
- end`;
58
- exports.CIO_PODFILE_SNIPPET = `
59
- pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec'
60
- pod 'boost', :podspec => '../node_modules/react-native/third-party-podspecs/boost.podspec'
61
- pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'`;
62
- exports.CIO_PODFILE_TARGET_NAMES_SNIPPET = `
63
- cio_target_names = [
64
- 'CustomerIOTracking',
65
- 'CustomerIOCommon',
66
- 'CustomerIOMessagingPushAPN',
67
- 'CustomerIOMessagingPush'
68
- ]`;
69
- exports.CIO_PODFILE_POST_INSTALL_SNIPPET = `
70
- installer.pods_project.targets.each do |target|
71
- if cio_target_names.include? target.name
72
- puts "Modifying target #{target.name}"
73
-
74
- target.build_configurations.each do |config|
75
- puts "Setting build config settings for #{target.name}"
76
- config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'
77
- end
78
- end
79
- end`;
80
- exports.CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = `
81
- cio_target_names = [
82
- 'CustomerIOTracking',
83
- 'CustomerIOCommon',
84
- 'CustomerIOMessagingPushAPN',
85
- 'CustomerIOMessagingPush'
86
- ]
87
-
88
- post_install do |installer|
89
-
90
- installer.pods_project.targets.each do |target|
91
- if cio_target_names.include? target.name
92
- puts "Modifying target #{target.name}"
93
-
94
- target.build_configurations.each do |config|
95
- puts "Setting build config settings for #{target.name}"
96
- config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'
97
- end
98
- end
99
- end
100
- react_native_post_install(installer)
101
- __apply_Xcode_12_5_M1_post_install_workaround(installer)
102
- end`;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectCodeByLineNumber = exports.injectCodeByMultiLineRegexAndReplaceLine = exports.injectCodeByMultiLineRegex = exports.injectCodeByRegex = void 0;
4
- function injectCodeByRegex(fileContent, lineRegex, snippet) {
5
- const lines = fileContent.split('\n');
6
- const index = lines.findIndex((line) => lineRegex.test(line));
7
- let content = lines;
8
- if (index > -1) {
9
- content = [...lines.slice(0, index), snippet, ...lines.slice(index)];
10
- }
11
- return content;
12
- }
13
- exports.injectCodeByRegex = injectCodeByRegex;
14
- function injectCodeByMultiLineRegex(fileContent, lineRegex, snippet) {
15
- return fileContent.replace(lineRegex, `$&\n${snippet}`);
16
- }
17
- exports.injectCodeByMultiLineRegex = injectCodeByMultiLineRegex;
18
- function injectCodeByMultiLineRegexAndReplaceLine(fileContent, lineRegex, snippet) {
19
- return fileContent.replace(lineRegex, `${snippet}`);
20
- }
21
- exports.injectCodeByMultiLineRegexAndReplaceLine = injectCodeByMultiLineRegexAndReplaceLine;
22
- function injectCodeByLineNumber(fileContent, index, snippet) {
23
- const lines = fileContent.split('\n');
24
- let content = lines;
25
- if (index > -1) {
26
- content = [...lines.slice(0, index), snippet, ...lines.slice(index)];
27
- }
28
- return content;
29
- }
30
- exports.injectCodeByLineNumber = injectCodeByLineNumber;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileManagement = void 0;
4
- const fs_1 = require("fs");
5
- class FileManagement {
6
- static async read(path) {
7
- return new Promise((resolve, reject) => {
8
- (0, fs_1.readFile)(path, 'utf8', (err, data) => {
9
- if (err || !data) {
10
- reject(err);
11
- return;
12
- }
13
- resolve(data);
14
- });
15
- });
16
- }
17
- static async write(path, contents) {
18
- return new Promise((resolve, reject) => {
19
- (0, fs_1.writeFile)(path, contents, 'utf8', (err) => {
20
- if (err) {
21
- reject(err);
22
- return;
23
- }
24
- resolve();
25
- });
26
- });
27
- }
28
- static async append(path, contents) {
29
- return new Promise((resolve, reject) => {
30
- (0, fs_1.appendFile)(path, contents, 'utf8', (err) => {
31
- if (err) {
32
- reject(err);
33
- return;
34
- }
35
- resolve();
36
- });
37
- });
38
- }
39
- }
40
- exports.FileManagement = FileManagement;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.injectCIONotificationPodfileCode = exports.injectCIOPodfileCode = void 0;
4
- const ios_1 = require("../constants/ios");
5
- const fileManagement_1 = require("./fileManagement");
6
- async function injectCIOPodfileCode(iosPath) {
7
- const filename = `${iosPath}/Podfile`;
8
- const podfile = await fileManagement_1.FileManagement.read(filename);
9
- const matches = podfile.match(ios_1.CIO_PODFILE_REGEX);
10
- const lines = podfile.split('\n');
11
- const index = lines.findIndex((line) => ios_1.CIO_PODFILE_POST_INSTALL_REGEX.test(line));
12
- let content = lines;
13
- if (index > -1) {
14
- content = [
15
- ...lines.slice(0, index - 1),
16
- !matches ? ios_1.CIO_PODFILE_SNIPPET : '',
17
- ios_1.CIO_PODFILE_TARGET_NAMES_SNIPPET,
18
- ...lines.slice(index - 1, index + 1),
19
- ios_1.CIO_PODFILE_POST_INSTALL_SNIPPET,
20
- ...lines.slice(index + 1),
21
- ];
22
- }
23
- else {
24
- content.push(ios_1.CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);
25
- }
26
- fileManagement_1.FileManagement.write(filename, content.join('\n'));
27
- }
28
- exports.injectCIOPodfileCode = injectCIOPodfileCode;
29
- async function injectCIONotificationPodfileCode(iosPath) {
30
- const filename = `${iosPath}/Podfile`;
31
- const podfile = await fileManagement_1.FileManagement.read(filename);
32
- const matches = podfile.match(ios_1.CIO_PODFILE_NOTIFICATION_REGEX);
33
- if (!matches) {
34
- fileManagement_1.FileManagement.append(filename, ios_1.CIO_PODFILE_NOTIFICATION_SNIPPET);
35
- }
36
- }
37
- exports.injectCIONotificationPodfileCode = injectCIONotificationPodfileCode;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const withCIOAndroid_1 = require("./android/withCIOAndroid");
4
- const withCIOIos_1 = require("./ios/withCIOIos");
5
- // Entry point for config plugin
6
- function withCustomerIOPlugin(config, props) {
7
- config = (0, withCIOIos_1.withCIOIos)(config, props);
8
- config = (0, withCIOAndroid_1.withCIOAndroid)(config, props);
9
- return config;
10
- }
11
- exports.default = withCustomerIOPlugin;