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

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 (155) 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 +22 -0
  4. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -0
  5. package/lib/commonjs/android/withCIOAndroid.js +18 -0
  6. package/lib/commonjs/android/withCIOAndroid.js.map +1 -0
  7. package/lib/commonjs/android/withGistMavenRepository.js +21 -0
  8. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -0
  9. package/lib/commonjs/android/withGoogleServicesJSON.js +34 -0
  10. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -0
  11. package/lib/commonjs/android/withProjectGoogleServices.js +20 -0
  12. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -0
  13. package/lib/commonjs/helpers/constants/android.js +21 -0
  14. package/lib/commonjs/helpers/constants/android.js.map +1 -0
  15. package/lib/commonjs/helpers/constants/globals.d.js +2 -0
  16. package/lib/commonjs/helpers/constants/globals.d.js.map +1 -0
  17. package/lib/commonjs/helpers/constants/ios.js +140 -0
  18. package/lib/commonjs/helpers/constants/ios.js.map +1 -0
  19. package/{build/helpers/ios/CIONotificationService-Info.plist → lib/commonjs/helpers/native-files/ios/NotificationService-Info.plist} +2 -2
  20. package/{build/helpers/ios/CIONotificationService.h → lib/commonjs/helpers/native-files/ios/NotificationService.h} +0 -0
  21. package/{build/helpers/ios/CIONotificationService.m → lib/commonjs/helpers/native-files/ios/NotificationService.m} +2 -6
  22. package/{build/helpers/ios/CIONotificationService.swift → lib/commonjs/helpers/native-files/ios/NotificationService.swift} +0 -2
  23. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/PushNotification.swift +1 -10
  24. package/lib/commonjs/helpers/utils/codeInjection.js +33 -0
  25. package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
  26. package/lib/commonjs/helpers/utils/fileManagement.js +76 -0
  27. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -0
  28. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +37 -0
  29. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  30. package/lib/commonjs/index.js +23 -0
  31. package/lib/commonjs/index.js.map +1 -0
  32. package/lib/commonjs/ios/withAppDelegateModifications.js +85 -0
  33. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
  34. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +79 -0
  35. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -0
  36. package/lib/commonjs/ios/withCIOIos.js +23 -0
  37. package/lib/commonjs/ios/withCIOIos.js.map +1 -0
  38. package/lib/commonjs/ios/withNotificationsXcodeProject.js +158 -0
  39. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
  40. package/lib/commonjs/ios/withXcodeProject.js +28 -0
  41. package/lib/commonjs/ios/withXcodeProject.js.map +1 -0
  42. package/lib/commonjs/types/cio-types.js +2 -0
  43. package/lib/commonjs/types/cio-types.js.map +1 -0
  44. package/lib/commonjs/version.js +9 -0
  45. package/lib/commonjs/version.js.map +1 -0
  46. package/lib/module/analytics/injectAnalytics.js +24 -0
  47. package/lib/module/analytics/injectAnalytics.js.map +1 -0
  48. package/lib/module/android/withAppGoogleServices.js +15 -0
  49. package/lib/module/android/withAppGoogleServices.js.map +1 -0
  50. package/lib/module/android/withCIOAndroid.js +12 -0
  51. package/lib/module/android/withCIOAndroid.js.map +1 -0
  52. package/lib/module/android/withGistMavenRepository.js +14 -0
  53. package/lib/module/android/withGistMavenRepository.js.map +1 -0
  54. package/lib/module/android/withGoogleServicesJSON.js +27 -0
  55. package/lib/module/android/withGoogleServicesJSON.js.map +1 -0
  56. package/lib/module/android/withProjectGoogleServices.js +13 -0
  57. package/lib/module/android/withProjectGoogleServices.js.map +1 -0
  58. package/lib/module/helpers/constants/android.js +8 -0
  59. package/lib/module/helpers/constants/android.js.map +1 -0
  60. package/lib/module/helpers/constants/globals.d.js +2 -0
  61. package/lib/module/helpers/constants/globals.d.js.map +1 -0
  62. package/lib/module/helpers/constants/ios.js +103 -0
  63. package/lib/module/helpers/constants/ios.js.map +1 -0
  64. package/lib/module/helpers/native-files/ios/NotificationService-Info.plist +31 -0
  65. package/lib/module/helpers/native-files/ios/NotificationService.h +5 -0
  66. package/lib/module/helpers/native-files/ios/NotificationService.m +26 -0
  67. package/lib/module/helpers/native-files/ios/NotificationService.swift +19 -0
  68. package/lib/module/helpers/native-files/ios/PushNotification.swift +47 -0
  69. package/lib/module/helpers/utils/codeInjection.js +24 -0
  70. package/lib/module/helpers/utils/codeInjection.js.map +1 -0
  71. package/lib/module/helpers/utils/fileManagement.js +69 -0
  72. package/lib/module/helpers/utils/fileManagement.js.map +1 -0
  73. package/lib/module/helpers/utils/injectCIOPodfileCode.js +30 -0
  74. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  75. package/lib/module/index.js +16 -0
  76. package/lib/module/index.js.map +1 -0
  77. package/lib/module/ios/withAppDelegateModifications.js +78 -0
  78. package/lib/module/ios/withAppDelegateModifications.js.map +1 -0
  79. package/lib/module/ios/withAppDelegateXcodeProject.js +71 -0
  80. package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -0
  81. package/lib/module/ios/withCIOIos.js +17 -0
  82. package/lib/module/ios/withCIOIos.js.map +1 -0
  83. package/lib/module/ios/withNotificationsXcodeProject.js +150 -0
  84. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
  85. package/lib/module/ios/withXcodeProject.js +21 -0
  86. package/lib/module/ios/withXcodeProject.js.map +1 -0
  87. package/lib/module/types/cio-types.js +2 -0
  88. package/lib/module/types/cio-types.js.map +1 -0
  89. package/lib/module/version.js +2 -0
  90. package/lib/module/version.js.map +1 -0
  91. package/lib/typescript/analytics/injectAnalytics.d.ts +3 -0
  92. package/lib/typescript/android/withAppGoogleServices.d.ts +3 -0
  93. package/lib/typescript/android/withCIOAndroid.d.ts +3 -0
  94. package/lib/typescript/android/withGistMavenRepository.d.ts +3 -0
  95. package/lib/typescript/android/withGoogleServicesJSON.d.ts +3 -0
  96. package/lib/typescript/android/withProjectGoogleServices.d.ts +3 -0
  97. package/lib/typescript/helpers/constants/android.d.ts +7 -0
  98. package/lib/typescript/helpers/constants/ios.d.ts +31 -0
  99. package/lib/typescript/helpers/utils/codeInjection.d.ts +4 -0
  100. package/lib/typescript/helpers/utils/fileManagement.d.ts +12 -0
  101. package/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -0
  102. package/lib/typescript/index.d.ts +4 -0
  103. package/lib/typescript/ios/withAppDelegateModifications.d.ts +2 -0
  104. package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +3 -0
  105. package/lib/typescript/ios/withCIOIos.d.ts +3 -0
  106. package/lib/typescript/ios/withNotificationsXcodeProject.d.ts +3 -0
  107. package/lib/typescript/ios/withXcodeProject.d.ts +3 -0
  108. package/lib/typescript/types/cio-types.d.ts +25 -0
  109. package/lib/typescript/version.d.ts +1 -0
  110. package/package.json +88 -13
  111. package/src/analytics/injectAnalytics.ts +36 -0
  112. package/src/android/withAppGoogleServices.ts +26 -0
  113. package/src/android/withCIOAndroid.ts +19 -0
  114. package/src/android/withGistMavenRepository.ts +26 -0
  115. package/src/android/withGoogleServicesJSON.ts +36 -0
  116. package/src/android/withProjectGoogleServices.ts +24 -0
  117. package/src/helpers/constants/android.ts +14 -0
  118. package/src/helpers/constants/globals.d.ts +8 -0
  119. package/src/helpers/constants/ios.ts +116 -0
  120. package/src/helpers/native-files/ios/NotificationService-Info.plist +31 -0
  121. package/src/helpers/native-files/ios/NotificationService.h +5 -0
  122. package/src/helpers/native-files/ios/NotificationService.m +26 -0
  123. package/src/helpers/native-files/ios/NotificationService.swift +19 -0
  124. package/src/helpers/native-files/ios/PushNotification.swift +47 -0
  125. package/src/helpers/utils/codeInjection.ts +46 -0
  126. package/src/helpers/utils/fileManagement.ts +87 -0
  127. package/src/helpers/utils/injectCIOPodfileCode.ts +53 -0
  128. package/src/index.ts +26 -0
  129. package/src/ios/withAppDelegateModifications.ts +166 -0
  130. package/src/ios/withAppDelegateXcodeProject.ts +89 -0
  131. package/src/ios/withCIOIos.ts +25 -0
  132. package/src/ios/withNotificationsXcodeProject.ts +237 -0
  133. package/src/ios/withXcodeProject.ts +25 -0
  134. package/src/types/cio-types.ts +31 -0
  135. package/src/version.ts +1 -0
  136. package/build/helpers/.DS_Store +0 -0
  137. package/build/helpers/ios/.DS_Store +0 -0
  138. package/build/package.json +0 -36
  139. package/build/src/android/withAppGoogleServices.js +0 -12
  140. package/build/src/android/withCIOAndroid.js +0 -15
  141. package/build/src/android/withGistMavenRepository.js +0 -12
  142. package/build/src/android/withGoogleServicesJSON.js +0 -24
  143. package/build/src/android/withProjectGoogleServices.js +0 -12
  144. package/build/src/helpers/constants/android.js +0 -9
  145. package/build/src/helpers/constants/ios.js +0 -102
  146. package/build/src/helpers/utils/codeInjection.js +0 -30
  147. package/build/src/helpers/utils/fileManagement.js +0 -40
  148. package/build/src/helpers/utils/injectCIOPodfileCode.js +0 -37
  149. package/build/src/index.js +0 -11
  150. package/build/src/ios/withAppDelegateModifications.js +0 -77
  151. package/build/src/ios/withAppDelegateXcodeProject.js +0 -78
  152. package/build/src/ios/withCIOIos.js +0 -15
  153. package/build/src/ios/withNotificationsXcodeProject.js +0 -133
  154. package/build/src/ios/withXcodeProject.js +0 -22
  155. package/build/src/types/cio-types.js +0 -8
@@ -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,31 @@
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
+ pushNotification?: {
19
+ useRichPush: boolean;
20
+ };
21
+ };
22
+
23
+ export type CustomerIOPluginOptionsAndroid = {
24
+ androidPath: string;
25
+ googleServicesFilePath?: string;
26
+ };
27
+
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.2";
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;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withAppDelegateModifications = void 0;
4
- const config_plugins_1 = require("@expo/config-plugins");
5
- const Paths_1 = require("@expo/config-plugins/build/ios/Paths");
6
- const ios_1 = require("../helpers/constants/ios");
7
- const codeInjection_1 = require("../helpers/utils/codeInjection");
8
- const fileManagement_1 = require("../helpers/utils/fileManagement");
9
- const pushCodeSnippets = [
10
- ios_1.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,
11
- ios_1.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,
12
- ];
13
- const additionalMethodsForPushNotifications = `${pushCodeSnippets.join('\n')}\n`; // Join w/ newlines and ensure a newline at the end.
14
- const addImport = (stringContents) => {
15
- const importRegex = /^(#import .*)\n/gm;
16
- const addedImport = `
17
- // Add swift bridge imports
18
- #import <ExpoModulesCore-Swift.h>
19
- #import <testiosapp-Swift.h>
20
- `;
21
- const match = stringContents.match(importRegex);
22
- let endOfMatchIndex;
23
- if (!match || match.index === undefined) {
24
- // No imports found, just add to start of file:
25
- endOfMatchIndex = 0;
26
- }
27
- else {
28
- // Add after first import:
29
- endOfMatchIndex = match.index + match[0].length;
30
- }
31
- stringContents = (0, codeInjection_1.injectCodeByLineNumber)(stringContents, endOfMatchIndex, addedImport).join('\n');
32
- return stringContents;
33
- };
34
- const addNotificationHandlerDeclaration = (stringContents) => {
35
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegex)(stringContents, ios_1.CIO_APPDELEGATEDECLARATION_REGEX, ios_1.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET);
36
- return stringContents;
37
- };
38
- const addNotificationConfiguration = (stringContents) => {
39
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegex)(stringContents, ios_1.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, ios_1.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET);
40
- return stringContents;
41
- };
42
- const addDidFailToRegisterForRemoteNotificationsWithError = (stringContents) => {
43
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, ios_1.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, ios_1.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET);
44
- return stringContents;
45
- };
46
- const AddDidRegisterForRemoteNotificationsWithDeviceToken = (stringContents) => {
47
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, ios_1.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, ios_1.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET);
48
- return stringContents;
49
- };
50
- const addAdditionalMethodsForPushNotifications = (stringContents) => {
51
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegex)(stringContents, ios_1.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX, additionalMethodsForPushNotifications);
52
- return stringContents;
53
- };
54
- const addAppdelegateHeaderModification = (stringContents) => {
55
- stringContents = (0, codeInjection_1.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, ios_1.CIO_APPDELEGATEHEADER_REGEX, ios_1.CIO_APPDELEGATEHEADER_SNIPPET);
56
- return stringContents;
57
- };
58
- const withAppDelegateModifications = (configOuter) => {
59
- return (0, config_plugins_1.withAppDelegate)(configOuter, async (config) => {
60
- let stringContents = config.modResults.contents;
61
- const headerPath = (0, Paths_1.getAppDelegateHeaderFilePath)(config.modRequest.projectRoot);
62
- let headerContent = await fileManagement_1.FileManagement.read(headerPath);
63
- headerContent = addAppdelegateHeaderModification(headerContent);
64
- fileManagement_1.FileManagement.write(headerPath, headerContent);
65
- stringContents = addImport(stringContents);
66
- stringContents = addNotificationHandlerDeclaration(stringContents);
67
- stringContents = addNotificationConfiguration(stringContents);
68
- stringContents = addAdditionalMethodsForPushNotifications(stringContents);
69
- stringContents =
70
- addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
71
- stringContents =
72
- AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
73
- config.modResults.contents = stringContents;
74
- return config;
75
- });
76
- };
77
- exports.withAppDelegateModifications = withAppDelegateModifications;
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withCioAppdelegateXcodeProject = void 0;
7
- const config_plugins_1 = require("@expo/config-plugins");
8
- const fs_1 = __importDefault(require("fs"));
9
- const xcode_1 = __importDefault(require("xcode"));
10
- const ios_1 = require("../helpers/constants/ios");
11
- const addNotificationServiceExtensionFile = async (options) => {
12
- const { iosPath, appName } = options;
13
- const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
14
- const xcodeProject = xcode_1.default.project(projPath);
15
- xcodeProject.parse(async function (err) {
16
- if (err) {
17
- throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
18
- }
19
- fs_1.default.mkdirSync(`${iosPath}/${appName}`, {
20
- recursive: true,
21
- });
22
- const file = 'PushNotification.swift';
23
- const getTargetFile = (filename) => `${iosPath}/${appName}/${filename}`;
24
- const targetFile = getTargetFile(file);
25
- fs_1.default.copyFileSync(`${ios_1.LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
26
- // Create new PBXGroup for the extension
27
- const extGroup = xcodeProject.addPbxGroup([file], appName, appName);
28
- // Add the new PBXGroup to the top level group. This makes the
29
- // files / folder appear in the file explorer in Xcode.
30
- const groups = xcodeProject.hash.project.objects['PBXGroup'];
31
- Object.keys(groups).forEach((key) => {
32
- if (groups[key].name === undefined) {
33
- xcodeProject.addToPbxGroup(extGroup.uuid, key);
34
- }
35
- });
36
- // WORK AROUND for codeProject.addTarget BUG
37
- // Xcode projects don't contain these if there is only one target
38
- // An upstream fix should be made to the code referenced in this link:
39
- // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
40
- const projObjects = xcodeProject.hash.project.objects;
41
- projObjects['PBXTargetDependency'] =
42
- projObjects['PBXTargetDependency'] || {};
43
- projObjects['PBXContainerItemProxy'] =
44
- projObjects['PBXTargetDependency'] || {};
45
- fs_1.default.writeFileSync(projPath, xcodeProject.writeSync());
46
- });
47
- };
48
- const withCioAppdelegateXcodeProject = (configOuter, props) => {
49
- return (0, config_plugins_1.withXcodeProject)(configOuter, async (config) => {
50
- const { modRequest, ios, version: bundleShortVersion } = config;
51
- const { appleTeamId, iosDeploymentTarget } = props;
52
- if (ios === undefined)
53
- throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
54
- const { projectName, platformProjectRoot } = modRequest;
55
- const { bundleIdentifier, buildNumber } = ios;
56
- if (bundleShortVersion === undefined) {
57
- throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
58
- }
59
- if (bundleIdentifier === undefined) {
60
- throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
61
- }
62
- if (projectName === undefined) {
63
- throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
64
- }
65
- const options = {
66
- appleTeamId,
67
- bundleIdentifier,
68
- bundleShortVersion,
69
- bundleVersion: buildNumber !== null && buildNumber !== void 0 ? buildNumber : ios_1.DEFAULT_BUNDLE_VERSION,
70
- iosPath: platformProjectRoot,
71
- appName: projectName,
72
- iosDeploymentTarget,
73
- };
74
- await addNotificationServiceExtensionFile(options);
75
- return config;
76
- });
77
- };
78
- exports.withCioAppdelegateXcodeProject = withCioAppdelegateXcodeProject;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withCIOIos = void 0;
4
- const withAppDelegateModifications_1 = require("./withAppDelegateModifications");
5
- const withAppDelegateXcodeProject_1 = require("./withAppDelegateXcodeProject");
6
- const withNotificationsXcodeProject_1 = require("./withNotificationsXcodeProject");
7
- const withXcodeProject_1 = require("./withXcodeProject");
8
- function withCIOIos(config, props) {
9
- config = (0, withNotificationsXcodeProject_1.withCioNotificationsXcodeProject)(config, props);
10
- config = (0, withAppDelegateModifications_1.withAppDelegateModifications)(config, props);
11
- config = (0, withXcodeProject_1.withCioXcodeProject)(config, props);
12
- config = (0, withAppDelegateXcodeProject_1.withCioAppdelegateXcodeProject)(config, props);
13
- return config;
14
- }
15
- exports.withCIOIos = withCIOIos;