customerio-expo-plugin 3.3.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/package.json +8 -1
  2. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +64 -59
  3. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
  4. package/plugin/lib/commonjs/android/withAppGoogleServices.js +10 -7
  5. package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
  6. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +18 -21
  7. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  8. package/plugin/lib/commonjs/android/withLocationGradleProperties.js +16 -12
  9. package/plugin/lib/commonjs/android/withLocationGradleProperties.js.map +1 -1
  10. package/plugin/lib/commonjs/android/withMainApplicationModifications.js +19 -12
  11. package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
  12. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +2 -1
  13. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
  14. package/plugin/lib/commonjs/android/withProjectBuildGradle.js +29 -25
  15. package/plugin/lib/commonjs/android/withProjectBuildGradle.js.map +1 -1
  16. package/plugin/lib/commonjs/android/withProjectGoogleServices.js +9 -5
  17. package/plugin/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
  18. package/plugin/lib/commonjs/helpers/constants/ios.js +76 -8
  19. package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
  20. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +76 -31
  21. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  22. package/plugin/lib/commonjs/index.js +7 -0
  23. package/plugin/lib/commonjs/index.js.map +1 -1
  24. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +47 -33
  25. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  26. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +44 -54
  27. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  28. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +46 -30
  29. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
  30. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +192 -122
  31. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  32. package/plugin/lib/commonjs/postInstallHelper.js +58 -11
  33. package/plugin/lib/commonjs/postInstallHelper.js.map +1 -1
  34. package/plugin/lib/commonjs/utils/resolveRNSDK.js +97 -0
  35. package/plugin/lib/commonjs/utils/resolveRNSDK.js.map +1 -0
  36. package/plugin/lib/commonjs/utils/writeExpoVersion.js +56 -0
  37. package/plugin/lib/commonjs/utils/writeExpoVersion.js.map +1 -0
  38. package/plugin/lib/module/android/withAndroidManifestUpdates.js +61 -58
  39. package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
  40. package/plugin/lib/module/android/withAppGoogleServices.js +9 -7
  41. package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
  42. package/plugin/lib/module/android/withGoogleServicesJSON.js +17 -21
  43. package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  44. package/plugin/lib/module/android/withLocationGradleProperties.js +15 -12
  45. package/plugin/lib/module/android/withLocationGradleProperties.js.map +1 -1
  46. package/plugin/lib/module/android/withMainApplicationModifications.js +18 -12
  47. package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
  48. package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
  49. package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
  50. package/plugin/lib/module/android/withProjectBuildGradle.js +28 -25
  51. package/plugin/lib/module/android/withProjectBuildGradle.js.map +1 -1
  52. package/plugin/lib/module/android/withProjectGoogleServices.js +8 -5
  53. package/plugin/lib/module/android/withProjectGoogleServices.js.map +1 -1
  54. package/plugin/lib/module/helpers/constants/ios.js +75 -8
  55. package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
  56. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +74 -31
  57. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  58. package/plugin/lib/module/index.js +7 -0
  59. package/plugin/lib/module/index.js.map +1 -1
  60. package/plugin/lib/module/ios/withAppDelegateModifications.js +45 -33
  61. package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  62. package/plugin/lib/module/ios/withCIOIosSwift.js +42 -54
  63. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  64. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +45 -30
  65. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
  66. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +187 -122
  67. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  68. package/plugin/lib/module/postInstallHelper.js +58 -11
  69. package/plugin/lib/module/postInstallHelper.js.map +1 -1
  70. package/plugin/lib/module/utils/resolveRNSDK.js +88 -0
  71. package/plugin/lib/module/utils/resolveRNSDK.js.map +1 -0
  72. package/plugin/lib/module/utils/writeExpoVersion.js +48 -0
  73. package/plugin/lib/module/utils/writeExpoVersion.js.map +1 -0
  74. package/plugin/lib/typescript/android/withAndroidManifestUpdates.d.ts +2 -0
  75. package/plugin/lib/typescript/android/withAppGoogleServices.d.ts +1 -0
  76. package/plugin/lib/typescript/android/withGoogleServicesJSON.d.ts +1 -0
  77. package/plugin/lib/typescript/android/withLocationGradleProperties.d.ts +2 -0
  78. package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +6 -0
  79. package/plugin/lib/typescript/android/withNotificationChannelMetadata.d.ts +5 -0
  80. package/plugin/lib/typescript/android/withProjectBuildGradle.d.ts +9 -0
  81. package/plugin/lib/typescript/android/withProjectGoogleServices.d.ts +1 -0
  82. package/plugin/lib/typescript/helpers/constants/ios.d.ts +18 -0
  83. package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +25 -1
  84. package/plugin/lib/typescript/ios/withAppDelegateModifications.d.ts +13 -0
  85. package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +11 -0
  86. package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +14 -1
  87. package/plugin/lib/typescript/ios/withNotificationsXcodeProject.d.ts +53 -2
  88. package/plugin/lib/typescript/utils/resolveRNSDK.d.ts +7 -0
  89. package/plugin/lib/typescript/utils/writeExpoVersion.d.ts +3 -0
  90. package/plugin/src/android/withAndroidManifestUpdates.ts +83 -73
  91. package/plugin/src/android/withAppGoogleServices.ts +13 -11
  92. package/plugin/src/android/withGoogleServicesJSON.ts +30 -28
  93. package/plugin/src/android/withLocationGradleProperties.ts +23 -17
  94. package/plugin/src/android/withMainApplicationModifications.ts +25 -15
  95. package/plugin/src/android/withNotificationChannelMetadata.ts +1 -1
  96. package/plugin/src/android/withProjectBuildGradle.ts +37 -27
  97. package/plugin/src/android/withProjectGoogleServices.ts +14 -9
  98. package/plugin/src/helpers/constants/ios.ts +87 -8
  99. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +97 -50
  100. package/plugin/src/index.ts +7 -0
  101. package/plugin/src/ios/withAppDelegateModifications.ts +61 -48
  102. package/plugin/src/ios/withCIOIosSwift.ts +58 -62
  103. package/plugin/src/ios/withGoogleServicesJsonFile.ts +66 -48
  104. package/plugin/src/ios/withNotificationsXcodeProject.ts +257 -207
  105. package/plugin/src/postInstallHelper.js +75 -17
  106. package/plugin/src/utils/resolveRNSDK.ts +118 -0
  107. package/plugin/src/utils/writeExpoVersion.ts +62 -0
@@ -6,6 +6,65 @@ import { logger } from '../utils/logger';
6
6
  import { FileManagement } from './../helpers/utils/fileManagement';
7
7
  import { isFcmPushProvider } from './utils';
8
8
 
9
+ export type CopyGoogleServicePlistOptions = {
10
+ iosPath: string;
11
+ appName: string | undefined;
12
+ googleServicesFile: string | undefined;
13
+ expoIosGoogleServicesFileSet: boolean;
14
+ xcodeProject: XcodeProject;
15
+ };
16
+
17
+ /**
18
+ * Copies the FCM GoogleService-Info.plist into the iOS project (when needed) and registers it
19
+ * in the Xcode project's Resources group. Idempotent — no-ops if a plist is already present
20
+ * at either of the two well-known locations Expo / RN Firebase use.
21
+ */
22
+ export function copyGoogleServicePlistFile({
23
+ iosPath,
24
+ appName,
25
+ googleServicesFile,
26
+ expoIosGoogleServicesFileSet,
27
+ xcodeProject,
28
+ }: CopyGoogleServicePlistOptions): void {
29
+ const destination = `${iosPath}/GoogleService-Info.plist`;
30
+
31
+ if (FileManagement.exists(destination)) {
32
+ logger.info(`File already exists: ${destination}. Skipping...`);
33
+ return;
34
+ }
35
+
36
+ if (appName && FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)) {
37
+ // This is where RN Firebase potentially copies GoogleService-Info.plist
38
+ // Do not copy if it's already done by Firebase to avoid conflict in Resources
39
+ logger.info(
40
+ `File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`
41
+ );
42
+ return;
43
+ }
44
+
45
+ if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
46
+ if (expoIosGoogleServicesFileSet) {
47
+ logger.warn(
48
+ 'Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' +
49
+ ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile'
50
+ );
51
+ }
52
+
53
+ try {
54
+ FileManagement.copyFile(googleServicesFile, destination);
55
+ addFileToXcodeProject(xcodeProject, 'GoogleService-Info.plist');
56
+ } catch {
57
+ logger.error(
58
+ `There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${destination}`
59
+ );
60
+ }
61
+ } else {
62
+ logger.error(
63
+ `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${destination}`
64
+ );
65
+ }
66
+ }
67
+
9
68
  export const withGoogleServicesJsonFile: ConfigPlugin<
10
69
  CustomerIOPluginOptionsIOS
11
70
  > = (config, cioProps) => {
@@ -21,54 +80,13 @@ export const withGoogleServicesJsonFile: ConfigPlugin<
21
80
  ' GoogleService-Info.plist as part of Firebase integration'
22
81
  );
23
82
 
24
- // googleServicesFile
25
- const iosPath = props.modRequest.platformProjectRoot;
26
- const googleServicesFile = cioProps.pushNotification?.googleServicesFile;
27
- const appName = props.modRequest.projectName;
28
-
29
- if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {
30
- logger.info(
31
- `File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`
32
- );
33
- return props;
34
- }
35
-
36
- if (
37
- FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)
38
- ) {
39
- // This is where RN Firebase potentially copies GoogleService-Info.plist
40
- // Do not copy if it's already done by Firebase to avoid conflict in Resources
41
- logger.info(
42
- `File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`
43
- );
44
- return props;
45
- }
46
-
47
- if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
48
- if (config.ios?.googleServicesFile) {
49
- logger.warn(
50
- 'Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' +
51
- ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile'
52
- );
53
- }
54
-
55
- try {
56
- FileManagement.copyFile(
57
- googleServicesFile,
58
- `${iosPath}/GoogleService-Info.plist`
59
- );
60
-
61
- addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');
62
- } catch {
63
- logger.error(
64
- `There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`
65
- );
66
- }
67
- } else {
68
- logger.error(
69
- `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`
70
- );
71
- }
83
+ copyGoogleServicePlistFile({
84
+ iosPath: props.modRequest.platformProjectRoot,
85
+ appName: props.modRequest.projectName,
86
+ googleServicesFile: cioProps.pushNotification?.googleServicesFile,
87
+ expoIosGoogleServicesFileSet: Boolean(config.ios?.googleServicesFile),
88
+ xcodeProject: props.modResults,
89
+ });
72
90
 
73
91
  return props;
74
92
  });