customerio-expo-plugin 1.0.0-alpha.1 → 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.
- package/lib/commonjs/analytics/injectAnalytics.js +31 -0
- package/lib/commonjs/analytics/injectAnalytics.js.map +1 -0
- package/lib/commonjs/android/withAppGoogleServices.js +7 -1
- package/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
- package/lib/commonjs/android/withGistMavenRepository.js +6 -1
- package/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
- package/lib/commonjs/android/withGoogleServicesJSON.js +10 -6
- package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/lib/commonjs/android/withProjectGoogleServices.js +5 -1
- package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
- package/lib/commonjs/helpers/constants/android.js +3 -1
- package/lib/commonjs/helpers/constants/android.js.map +1 -1
- package/lib/commonjs/helpers/constants/ios.js +5 -3
- package/lib/commonjs/helpers/constants/ios.js.map +1 -1
- package/lib/commonjs/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
- package/lib/commonjs/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
- package/lib/{module/helpers/native-files/ios/CIONotificationService.m → commonjs/helpers/native-files/ios/NotificationService.m} +2 -6
- package/lib/{module/helpers/native-files/ios/CIONotificationService.swift → commonjs/helpers/native-files/ios/NotificationService.swift} +0 -2
- package/lib/commonjs/helpers/native-files/ios/PushNotification.swift +1 -10
- package/lib/commonjs/helpers/utils/fileManagement.js +32 -0
- package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +12 -7
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/commonjs/index.js +8 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ios/withAppDelegateModifications.js +27 -18
- package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/lib/commonjs/ios/withAppDelegateXcodeProject.js +15 -32
- package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -1
- package/lib/commonjs/ios/withCIOIos.js +8 -3
- package/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/lib/commonjs/ios/withNotificationsXcodeProject.js +17 -16
- package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/commonjs/types/cio-types.js +0 -13
- package/lib/commonjs/types/cio-types.js.map +1 -1
- package/lib/commonjs/version.js +9 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/analytics/injectAnalytics.js +24 -0
- package/lib/module/analytics/injectAnalytics.js.map +1 -0
- package/lib/module/android/withAppGoogleServices.js +7 -1
- package/lib/module/android/withAppGoogleServices.js.map +1 -1
- package/lib/module/android/withGistMavenRepository.js +7 -2
- package/lib/module/android/withGistMavenRepository.js.map +1 -1
- package/lib/module/android/withGoogleServicesJSON.js +10 -6
- package/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/lib/module/android/withProjectGoogleServices.js +5 -1
- package/lib/module/android/withProjectGoogleServices.js.map +1 -1
- package/lib/module/helpers/constants/android.js +1 -0
- package/lib/module/helpers/constants/android.js.map +1 -1
- package/lib/module/helpers/constants/ios.js +3 -2
- package/lib/module/helpers/constants/ios.js.map +1 -1
- package/lib/module/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
- package/lib/module/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
- package/{src/helpers/native-files/ios/CIONotificationService.m → lib/module/helpers/native-files/ios/NotificationService.m} +2 -6
- package/{src/helpers/native-files/ios/CIONotificationService.swift → lib/module/helpers/native-files/ios/NotificationService.swift} +0 -2
- package/lib/module/helpers/native-files/ios/PushNotification.swift +1 -10
- package/lib/module/helpers/utils/fileManagement.js +33 -1
- package/lib/module/helpers/utils/fileManagement.js.map +1 -1
- package/lib/module/helpers/utils/injectCIOPodfileCode.js +13 -8
- package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/module/index.js +8 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/ios/withAppDelegateModifications.js +27 -18
- package/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/lib/module/ios/withAppDelegateXcodeProject.js +15 -32
- package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -1
- package/lib/module/ios/withCIOIos.js +8 -3
- package/lib/module/ios/withCIOIos.js.map +1 -1
- package/lib/module/ios/withNotificationsXcodeProject.js +17 -16
- package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/module/types/cio-types.js +0 -8
- package/lib/module/types/cio-types.js.map +1 -1
- package/lib/module/version.js +2 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/analytics/injectAnalytics.d.ts +3 -0
- package/lib/typescript/helpers/constants/android.d.ts +1 -0
- package/lib/typescript/helpers/constants/ios.d.ts +2 -1
- package/lib/typescript/helpers/utils/fileManagement.d.ts +7 -0
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/types/cio-types.d.ts +7 -4
- package/lib/typescript/version.d.ts +1 -0
- package/package.json +3 -2
- package/src/analytics/injectAnalytics.ts +36 -0
- package/src/android/withAppGoogleServices.ts +11 -4
- package/src/android/withGistMavenRepository.ts +11 -4
- package/src/android/withGoogleServicesJSON.ts +17 -11
- package/src/android/withProjectGoogleServices.ts +9 -4
- package/src/helpers/constants/android.ts +2 -0
- package/src/helpers/constants/ios.ts +3 -3
- package/src/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
- package/src/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
- package/{lib/commonjs/helpers/native-files/ios/CIONotificationService.m → src/helpers/native-files/ios/NotificationService.m} +2 -6
- package/{lib/commonjs/helpers/native-files/ios/CIONotificationService.swift → src/helpers/native-files/ios/NotificationService.swift} +0 -2
- package/src/helpers/native-files/ios/PushNotification.swift +1 -10
- package/src/helpers/utils/fileManagement.ts +49 -1
- package/src/helpers/utils/injectCIOPodfileCode.ts +23 -17
- package/src/index.ts +12 -7
- package/src/ios/withAppDelegateModifications.ts +39 -23
- package/src/ios/withAppDelegateXcodeProject.ts +19 -40
- package/src/ios/withCIOIos.ts +9 -3
- package/src/ios/withNotificationsXcodeProject.ts +24 -18
- package/src/types/cio-types.ts +7 -4
- package/src/version.ts +1 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withAnalytics = void 0;
|
|
7
|
+
var _version = require("./../version");
|
|
8
|
+
var _configPlugins = require("@expo/config-plugins");
|
|
9
|
+
var _fileManagement = require("../helpers/utils/fileManagement");
|
|
10
|
+
const withAnalytics = config => {
|
|
11
|
+
return (0, _configPlugins.withXcodeProject)(config, async props => {
|
|
12
|
+
const expoVersionSnippet = `"expoVersion": "${_version.LIB_VERSION}"`;
|
|
13
|
+
let versionRegEx = new RegExp(expoVersionSnippet);
|
|
14
|
+
const filename = `node_modules/customerio-reactnative/package.json`;
|
|
15
|
+
if (_fileManagement.FileManagement.exists(filename)) {
|
|
16
|
+
const pJsonFile = await _fileManagement.FileManagement.read(filename);
|
|
17
|
+
const lines = pJsonFile.split('\n');
|
|
18
|
+
const missingMmatch = pJsonFile.match(versionRegEx);
|
|
19
|
+
const expoVersionRegex = /"expoVersion": ".*"/;
|
|
20
|
+
const existatch = pJsonFile.match(expoVersionRegex);
|
|
21
|
+
if (existatch && !missingMmatch) {
|
|
22
|
+
const index = lines.findIndex(line => expoVersionRegex.test(line));
|
|
23
|
+
const content = [...lines.slice(0, index), ` ${expoVersionSnippet},`, ...lines.slice(index + 1)];
|
|
24
|
+
_fileManagement.FileManagement.write(filename, content.join('\n'));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return props;
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
exports.withAnalytics = withAnalytics;
|
|
31
|
+
//# sourceMappingURL=injectAnalytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withAnalytics","config","withXcodeProject","props","expoVersionSnippet","LIB_VERSION","versionRegEx","RegExp","filename","FileManagement","exists","pJsonFile","read","lines","split","missingMmatch","match","expoVersionRegex","existatch","index","findIndex","line","test","content","slice","write","join"],"sources":["injectAnalytics.ts"],"sourcesContent":["import { LIB_VERSION } from './../version';\nimport { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptions } from '../types/cio-types';\n\n\nexport const withAnalytics: ConfigPlugin<CustomerIOPluginOptions> = (config) => {\n return withXcodeProject(config, async (props) => {\n const expoVersionSnippet = `\"expoVersion\": \"${LIB_VERSION}\"`;\n let versionRegEx = new RegExp(expoVersionSnippet);\n const filename = `node_modules/customerio-reactnative/package.json`;\n if (FileManagement.exists(filename)) {\n const pJsonFile = await FileManagement.read(filename);\n const lines = pJsonFile.split('\\n');\n const missingMmatch = pJsonFile.match(versionRegEx);\n const expoVersionRegex = /\"expoVersion\": \".*\"/;\n const existatch = pJsonFile.match(expoVersionRegex);\n\n if (existatch && !missingMmatch) {\n const index = lines.findIndex((line) =>\n expoVersionRegex.test(line)\n );\n\n const content = [\n ...lines.slice(0, index),\n ` ${expoVersionSnippet},`,\n ...lines.slice(index + 1),\n ];\n\n FileManagement.write(filename, content.join('\\n'));\n }\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAIO,MAAMA,aAAoD,GAAIC,MAAM,IAAK;EAC9E,OAAO,IAAAC,+BAAgB,EAACD,MAAM,EAAE,MAAOE,KAAK,IAAK;IAC/C,MAAMC,kBAAkB,GAAI,mBAAkBC,oBAAY,GAAE;IAC5D,IAAIC,YAAY,GAAG,IAAIC,MAAM,CAACH,kBAAkB,CAAC;IACjD,MAAMI,QAAQ,GAAI,kDAAiD;IACnE,IAAIC,8BAAc,CAACC,MAAM,CAACF,QAAQ,CAAC,EAAE;MACnC,MAAMG,SAAS,GAAG,MAAMF,8BAAc,CAACG,IAAI,CAACJ,QAAQ,CAAC;MACrD,MAAMK,KAAK,GAAGF,SAAS,CAACG,KAAK,CAAC,IAAI,CAAC;MACnC,MAAMC,aAAa,GAAGJ,SAAS,CAACK,KAAK,CAACV,YAAY,CAAC;MACnD,MAAMW,gBAAgB,GAAG,qBAAqB;MAC9C,MAAMC,SAAS,GAAGP,SAAS,CAACK,KAAK,CAACC,gBAAgB,CAAC;MAEnD,IAAIC,SAAS,IAAI,CAACH,aAAa,EAAE;QAC/B,MAAMI,KAAK,GAAGN,KAAK,CAACO,SAAS,CAAEC,IAAI,IACjCJ,gBAAgB,CAACK,IAAI,CAACD,IAAI,CAAC,CAC5B;QAED,MAAME,OAAO,GAAG,CACd,GAAGV,KAAK,CAACW,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EACvB,KAAIf,kBAAmB,GAAE,EAC1B,GAAGS,KAAK,CAACW,KAAK,CAACL,KAAK,GAAG,CAAC,CAAC,CAC1B;QAEDV,8BAAc,CAACgB,KAAK,CAACjB,QAAQ,EAAEe,OAAO,CAACG,IAAI,CAAC,IAAI,CAAC,CAAC;MACpD;IACF;IAEA,OAAOvB,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAAC"}
|
|
@@ -8,7 +8,13 @@ var _configPlugins = require("@expo/config-plugins");
|
|
|
8
8
|
var _android = require("../helpers/constants/android");
|
|
9
9
|
const withAppGoogleServices = configOuter => {
|
|
10
10
|
return (0, _configPlugins.withAppBuildGradle)(configOuter, props => {
|
|
11
|
-
|
|
11
|
+
const regex = new RegExp(_android.CIO_APP_GOOGLE_SNIPPET);
|
|
12
|
+
const match = props.modResults.contents.match(regex);
|
|
13
|
+
if (!match) {
|
|
14
|
+
props.modResults.contents = props.modResults.contents.replace(_android.CIO_APP_APPLY_REGEX, `$1\n${_android.CIO_APP_GOOGLE_SNIPPET}`);
|
|
15
|
+
} else {
|
|
16
|
+
console.log('app/build.gradle snippet already exists. Skipping...');
|
|
17
|
+
}
|
|
12
18
|
return props;
|
|
13
19
|
});
|
|
14
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAppGoogleServices","configOuter","withAppBuildGradle","props","modResults","contents","replace","CIO_APP_APPLY_REGEX","
|
|
1
|
+
{"version":3,"names":["withAppGoogleServices","configOuter","withAppBuildGradle","props","regex","RegExp","CIO_APP_GOOGLE_SNIPPET","match","modResults","contents","replace","CIO_APP_APPLY_REGEX","console","log"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, withAppBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_APP_APPLY_REGEX,\n CIO_APP_GOOGLE_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\nexport const withAppGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAppBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_APP_APPLY_REGEX,\n `$1\\n${CIO_APP_GOOGLE_SNIPPET}`\n );\n } else {\n console.log('app/build.gradle snippet already exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAMO,MAAMA,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,iCAAkB,EAACD,WAAW,EAAGE,KAAK,IAAK;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACC,+BAAsB,CAAC;IAChD,MAAMC,KAAK,GAAGJ,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACH,KAAK,CAAC;IACpD,IAAI,CAACG,KAAK,EAAE;MACVJ,KAAK,CAACK,UAAU,CAACC,QAAQ,GAAGN,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DC,4BAAmB,EAClB,OAAML,+BAAuB,EAAC,CAChC;IACH,CAAC,MAAM;MACLM,OAAO,CAACC,GAAG,CAAC,sDAAsD,CAAC;IACrE;IAEA,OAAOV,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAAC"}
|
|
@@ -8,7 +8,12 @@ var _configPlugins = require("@expo/config-plugins");
|
|
|
8
8
|
var _android = require("../helpers/constants/android");
|
|
9
9
|
const withGistMavenRepository = configOuter => {
|
|
10
10
|
return (0, _configPlugins.withProjectBuildGradle)(configOuter, props => {
|
|
11
|
-
|
|
11
|
+
const targetMatch = props.modResults.contents.match(_android.CIO_GIST_MAVEN_REGEX);
|
|
12
|
+
if (!targetMatch) {
|
|
13
|
+
props.modResults.contents = props.modResults.contents.replace(_android.CIO_PROJECT_ALLPROJECTS_REGEX, `$1\n${_android.CIO_PROJECT_GIST_MAVEN_SNIPPET}`);
|
|
14
|
+
} else {
|
|
15
|
+
console.log('build.gradle snippet alreade exists. Skipping...');
|
|
16
|
+
}
|
|
12
17
|
return props;
|
|
13
18
|
});
|
|
14
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withGistMavenRepository","configOuter","withProjectBuildGradle","props","modResults","contents","replace","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET"],"sources":["withGistMavenRepository.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\nimport {\n CIO_PROJECT_ALLPROJECTS_REGEX,\n CIO_PROJECT_GIST_MAVEN_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGistMavenRepository: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n props.modResults.contents = props.modResults.contents.replace(\n
|
|
1
|
+
{"version":3,"names":["withGistMavenRepository","configOuter","withProjectBuildGradle","props","targetMatch","modResults","contents","match","CIO_GIST_MAVEN_REGEX","replace","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","console","log"],"sources":["withGistMavenRepository.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\nimport {\n CIO_GIST_MAVEN_REGEX,\n CIO_PROJECT_ALLPROJECTS_REGEX,\n CIO_PROJECT_GIST_MAVEN_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGistMavenRepository: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const targetMatch = props.modResults.contents.match(CIO_GIST_MAVEN_REGEX);\n if (!targetMatch) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_ALLPROJECTS_REGEX,\n `$1\\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`\n );\n } else {\n console.log('build.gradle snippet alreade exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAOO,MAAMA,uBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,qCAAsB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,WAAW,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACC,6BAAoB,CAAC;IACzE,IAAI,CAACJ,WAAW,EAAE;MAChBD,KAAK,CAACE,UAAU,CAACC,QAAQ,GAAGH,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACG,OAAO,CAC3DC,sCAA6B,EAC5B,OAAMC,uCAA+B,EAAC,CACxC;IACH,CAAC,MAAM;MACLC,OAAO,CAACC,GAAG,CAAC,kDAAkD,CAAC;IACjE;IAEA,OAAOV,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAAC"}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.withGoogleServicesJSON = void 0;
|
|
7
7
|
var _configPlugins = require("@expo/config-plugins");
|
|
8
|
-
var
|
|
8
|
+
var _fileManagement = require("./../helpers/utils/fileManagement");
|
|
9
9
|
const withGoogleServicesJSON = (configOuter, cioProps) => {
|
|
10
10
|
return (0, _configPlugins.withProjectBuildGradle)(configOuter, props => {
|
|
11
11
|
const options = {
|
|
@@ -16,12 +16,16 @@ const withGoogleServicesJSON = (configOuter, cioProps) => {
|
|
|
16
16
|
androidPath,
|
|
17
17
|
googleServicesFilePath
|
|
18
18
|
} = options;
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
if (!_fileManagement.FileManagement.exists(`${androidPath}/app/google-services.json`)) {
|
|
20
|
+
if (googleServicesFilePath) {
|
|
21
|
+
try {
|
|
22
|
+
_fileManagement.FileManagement.copyFile(`${googleServicesFilePath}google-services.json`, `${androidPath}/app/google-services.json`);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.log(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/`);
|
|
25
|
+
}
|
|
24
26
|
}
|
|
27
|
+
} else {
|
|
28
|
+
console.log(`File already exists: ${androidPath}/app/google-services.json. Skipping...`);
|
|
25
29
|
}
|
|
26
30
|
return props;
|
|
27
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withGoogleServicesJSON","configOuter","cioProps","withProjectBuildGradle","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFilePath","
|
|
1
|
+
{"version":3,"names":["withGoogleServicesJSON","configOuter","cioProps","withProjectBuildGradle","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFilePath","FileManagement","exists","copyFile","e","console","log"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const options: CustomerIOPluginOptionsAndroid = {\n androidPath: props.modRequest.platformProjectRoot,\n googleServicesFilePath: cioProps?.googleServicesFilePath,\n };\n const { androidPath, googleServicesFilePath } = options;\n if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {\n if (googleServicesFilePath) {\n try {\n FileManagement.copyFile(\n `${googleServicesFilePath}google-services.json`,\n `${androidPath}/app/google-services.json`\n );\n } catch (e) {\n console.log(\n `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/`\n );\n }\n }\n } else {\n console.log(\n `File already exists: ${androidPath}/app/google-services.json. Skipping...`\n );\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAGO,MAAMA,sBAEZ,GAAG,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAO,IAAAC,qCAAsB,EAACF,WAAW,EAAGG,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,sBAAsB,EAAEP,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEO;IACpC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAuB,CAAC,GAAGJ,OAAO;IACvD,IAAI,CAACK,8BAAc,CAACC,MAAM,CAAE,GAAEL,WAAY,2BAA0B,CAAC,EAAE;MACrE,IAAIG,sBAAsB,EAAE;QAC1B,IAAI;UACFC,8BAAc,CAACE,QAAQ,CACpB,GAAEH,sBAAuB,sBAAqB,EAC9C,GAAEH,WAAY,2BAA0B,CAC1C;QACH,CAAC,CAAC,OAAOO,CAAC,EAAE;UACVC,OAAO,CAACC,GAAG,CACR,4FAA2FT,WAAY,OAAM,CAC/G;QACH;MACF;IACF,CAAC,MAAM;MACLQ,OAAO,CAACC,GAAG,CACR,wBAAuBT,WAAY,wCAAuC,CAC5E;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAAC"}
|
|
@@ -8,7 +8,11 @@ var _configPlugins = require("@expo/config-plugins");
|
|
|
8
8
|
var _android = require("./../helpers/constants/android");
|
|
9
9
|
const withProjectGoogleServices = configOuter => {
|
|
10
10
|
return (0, _configPlugins.withProjectBuildGradle)(configOuter, props => {
|
|
11
|
-
|
|
11
|
+
const regex = new RegExp(_android.CIO_PROJECT_GOOGLE_SNIPPET);
|
|
12
|
+
const match = props.modResults.contents.match(regex);
|
|
13
|
+
if (!match) {
|
|
14
|
+
props.modResults.contents = props.modResults.contents.replace(_android.CIO_PROJECT_BUILDSCRIPTS_REGEX, `$1\n${_android.CIO_PROJECT_GOOGLE_SNIPPET}`);
|
|
15
|
+
}
|
|
12
16
|
return props;
|
|
13
17
|
});
|
|
14
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withProjectGoogleServices","configOuter","withProjectBuildGradle","props","modResults","contents","replace","CIO_PROJECT_BUILDSCRIPTS_REGEX"
|
|
1
|
+
{"version":3,"names":["withProjectGoogleServices","configOuter","withProjectBuildGradle","props","regex","RegExp","CIO_PROJECT_GOOGLE_SNIPPET","match","modResults","contents","replace","CIO_PROJECT_BUILDSCRIPTS_REGEX"],"sources":["withProjectGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, withProjectBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n CIO_PROJECT_GOOGLE_SNIPPET,\n} from './../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withProjectGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n `$1\\n${CIO_PROJECT_GOOGLE_SNIPPET}`\n );\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAMO,MAAMA,yBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,qCAAsB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACC,mCAA0B,CAAC;IACpD,MAAMC,KAAK,GAAGJ,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACH,KAAK,CAAC;IACpD,IAAI,CAACG,KAAK,EAAE;MACVJ,KAAK,CAACK,UAAU,CAACC,QAAQ,GAAGN,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DC,uCAA8B,EAC7B,OAAML,mCAA2B,EAAC,CACpC;IACH;IAEA,OAAOH,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAAC"}
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.CIO_PROJECT_GOOGLE_SNIPPET = exports.CIO_PROJECT_GIST_MAVEN_SNIPPET = exports.CIO_PROJECT_BUILDSCRIPTS_REGEX = exports.CIO_PROJECT_ALLPROJECTS_REGEX = exports.CIO_APP_GOOGLE_SNIPPET = exports.CIO_APP_APPLY_REGEX = void 0;
|
|
6
|
+
exports.CIO_PROJECT_GOOGLE_SNIPPET = exports.CIO_PROJECT_GIST_MAVEN_SNIPPET = exports.CIO_PROJECT_BUILDSCRIPTS_REGEX = exports.CIO_PROJECT_ALLPROJECTS_REGEX = exports.CIO_GIST_MAVEN_REGEX = exports.CIO_APP_GOOGLE_SNIPPET = exports.CIO_APP_APPLY_REGEX = void 0;
|
|
7
7
|
const CIO_PROJECT_BUILDSCRIPTS_REGEX = /(buildscript\s*\{(.|\n)*dependencies\s*\{)/;
|
|
8
8
|
exports.CIO_PROJECT_BUILDSCRIPTS_REGEX = CIO_PROJECT_BUILDSCRIPTS_REGEX;
|
|
9
9
|
const CIO_APP_APPLY_REGEX = /(apply plugin: "com.android.application")/;
|
|
10
10
|
exports.CIO_APP_APPLY_REGEX = CIO_APP_APPLY_REGEX;
|
|
11
|
+
const CIO_GIST_MAVEN_REGEX = /maven { url "https:\/\/maven.gist.build" }/;
|
|
12
|
+
exports.CIO_GIST_MAVEN_REGEX = CIO_GIST_MAVEN_REGEX;
|
|
11
13
|
const CIO_PROJECT_ALLPROJECTS_REGEX = /(allprojects\s*\{(.|\n)*repositories\s*\{)/;
|
|
12
14
|
exports.CIO_PROJECT_ALLPROJECTS_REGEX = CIO_PROJECT_ALLPROJECTS_REGEX;
|
|
13
15
|
const CIO_PROJECT_GIST_MAVEN_SNIPPET = ' maven { url "https://maven.gist.build" }';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_APP_APPLY_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","CIO_APP_GOOGLE_SNIPPET","CIO_PROJECT_GOOGLE_SNIPPET"],"sources":["android.ts"],"sourcesContent":["export const CIO_PROJECT_BUILDSCRIPTS_REGEX =\n /(buildscript\\s*\\{(.|\\n)*dependencies\\s*\\{)/;\nexport const CIO_APP_APPLY_REGEX = /(apply plugin: \"com.android.application\")/;\nexport const CIO_PROJECT_ALLPROJECTS_REGEX =\n /(allprojects\\s*\\{(.|\\n)*repositories\\s*\\{)/;\n\nexport const CIO_PROJECT_GIST_MAVEN_SNIPPET =\n ' maven { url \"https://maven.gist.build\" }';\nexport const CIO_APP_GOOGLE_SNIPPET =\n 'apply plugin: \"com.google.gms.google-services\" // Google Services plugin';\nexport const CIO_PROJECT_GOOGLE_SNIPPET =\n ' classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin';\n"],"mappings":";;;;;;AAAO,MAAMA,8BAA8B,GACzC,4CAA4C;AAAC;AACxC,MAAMC,mBAAmB,GAAG,2CAA2C;AAAC;AACxE,MAAMC,6BAA6B,GACxC,4CAA4C;AAAC;AAExC,MAAMC,8BAA8B,GACzC,kDAAkD;AAAC;AAC9C,MAAMC,sBAAsB,GACjC,2EAA2E;AAAC;AACvE,MAAMC,0BAA0B,GACrC,sFAAsF;AAAC"}
|
|
1
|
+
{"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_APP_APPLY_REGEX","CIO_GIST_MAVEN_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","CIO_APP_GOOGLE_SNIPPET","CIO_PROJECT_GOOGLE_SNIPPET"],"sources":["android.ts"],"sourcesContent":["export const CIO_PROJECT_BUILDSCRIPTS_REGEX =\n /(buildscript\\s*\\{(.|\\n)*dependencies\\s*\\{)/;\nexport const CIO_APP_APPLY_REGEX = /(apply plugin: \"com.android.application\")/;\nexport const CIO_GIST_MAVEN_REGEX =\n /maven { url \"https:\\/\\/maven.gist.build\" }/;\nexport const CIO_PROJECT_ALLPROJECTS_REGEX =\n /(allprojects\\s*\\{(.|\\n)*repositories\\s*\\{)/;\n\nexport const CIO_PROJECT_GIST_MAVEN_SNIPPET =\n ' maven { url \"https://maven.gist.build\" }';\nexport const CIO_APP_GOOGLE_SNIPPET =\n 'apply plugin: \"com.google.gms.google-services\" // Google Services plugin';\nexport const CIO_PROJECT_GOOGLE_SNIPPET =\n ' classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin';\n"],"mappings":";;;;;;AAAO,MAAMA,8BAA8B,GACzC,4CAA4C;AAAC;AACxC,MAAMC,mBAAmB,GAAG,2CAA2C;AAAC;AACxE,MAAMC,oBAAoB,GAC/B,4CAA4C;AAAC;AACxC,MAAMC,6BAA6B,GACxC,4CAA4C;AAAC;AAExC,MAAMC,8BAA8B,GACzC,kDAAkD;AAAC;AAC9C,MAAMC,sBAAsB,GACjC,2EAA2E;AAAC;AACvE,MAAMC,0BAA0B,GACrC,sFAAsF;AAAC"}
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.LOCAL_PATH_TO_CIO_NSE_FILES = exports.IOS_DEPLOYMENT_TARGET = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = exports.CIO_TARGET_NAME = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_PODFILE_TARGET_NAMES_SNIPPET = exports.CIO_PODFILE_SNIPPET = exports.CIO_PODFILE_REGEX = exports.CIO_PODFILE_POST_INSTALL_SNIPPET = exports.CIO_PODFILE_POST_INSTALL_REGEX = exports.CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = exports.CIO_PODFILE_NOTIFICATION_SNIPPET = exports.CIO_PODFILE_NOTIFICATION_REGEX = exports.CIO_NOTIFICATION_TARGET_NAME = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_APPDELEGATEHEADER_SNIPPET = exports.CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEDECLARATION_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = void 0;
|
|
6
|
+
exports.LOCAL_PATH_TO_CIO_NSE_FILES = exports.IOS_DEPLOYMENT_TARGET = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = exports.CIO_TARGET_NAME = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_PODFILE_TARGET_NAMES_SNIPPET = exports.CIO_PODFILE_SNIPPET = exports.CIO_PODFILE_REGEX = exports.CIO_PODFILE_POST_INSTALL_SNIPPET = exports.CIO_PODFILE_POST_INSTALL_REGEX = exports.CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = exports.CIO_PODFILE_NOTIFICATION_SNIPPET = exports.CIO_PODFILE_NOTIFICATION_REGEX = exports.CIO_NOTIFICATION_TARGET_NAME = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_CIO_TARGET_REGEX = exports.CIO_APPDELEGATEHEADER_SNIPPET = exports.CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEDECLARATION_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = void 0;
|
|
7
7
|
const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;
|
|
8
8
|
exports.LOCAL_PATH_TO_CIO_NSE_FILES = LOCAL_PATH_TO_CIO_NSE_FILES;
|
|
9
9
|
const IOS_DEPLOYMENT_TARGET = '13.0';
|
|
10
10
|
exports.IOS_DEPLOYMENT_TARGET = IOS_DEPLOYMENT_TARGET;
|
|
11
11
|
const CIO_PODFILE_REGEX = /pod 'RCT-Folly'/;
|
|
12
12
|
exports.CIO_PODFILE_REGEX = CIO_PODFILE_REGEX;
|
|
13
|
-
const
|
|
13
|
+
const CIO_CIO_TARGET_REGEX = /cio_target_names/;
|
|
14
|
+
exports.CIO_CIO_TARGET_REGEX = CIO_CIO_TARGET_REGEX;
|
|
15
|
+
const CIO_PODFILE_NOTIFICATION_REGEX = /target 'NotificationService' do/;
|
|
14
16
|
exports.CIO_PODFILE_NOTIFICATION_REGEX = CIO_PODFILE_NOTIFICATION_REGEX;
|
|
15
17
|
const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
|
|
16
18
|
exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = GROUP_IDENTIFIER_TEMPLATE_REGEX;
|
|
@@ -38,7 +40,7 @@ const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
|
|
|
38
40
|
exports.DEFAULT_BUNDLE_SHORT_VERSION = DEFAULT_BUNDLE_SHORT_VERSION;
|
|
39
41
|
const CIO_TARGET_NAME = 'CustomerIOSDK';
|
|
40
42
|
exports.CIO_TARGET_NAME = CIO_TARGET_NAME;
|
|
41
|
-
const CIO_NOTIFICATION_TARGET_NAME = '
|
|
43
|
+
const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';
|
|
42
44
|
exports.CIO_NOTIFICATION_TARGET_NAME = CIO_NOTIFICATION_TARGET_NAME;
|
|
43
45
|
const CIO_APPDELEGATEHEADER_SNIPPET = `
|
|
44
46
|
#import <UserNotifications/UserNotifications.h>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LOCAL_PATH_TO_CIO_NSE_FILES","IOS_DEPLOYMENT_TARGET","CIO_PODFILE_REGEX","CIO_PODFILE_NOTIFICATION_REGEX","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_PODFILE_POST_INSTALL_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_SNIPPET","CIO_PODFILE_TARGET_NAMES_SNIPPET","CIO_PODFILE_POST_INSTALL_SNIPPET","CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const CIO_PODFILE_REGEX = /pod 'RCT-Folly'/;\nexport const CIO_PODFILE_NOTIFICATION_REGEX
|
|
1
|
+
{"version":3,"names":["LOCAL_PATH_TO_CIO_NSE_FILES","IOS_DEPLOYMENT_TARGET","CIO_PODFILE_REGEX","CIO_CIO_TARGET_REGEX","CIO_PODFILE_NOTIFICATION_REGEX","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_PODFILE_POST_INSTALL_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_SNIPPET","CIO_PODFILE_TARGET_NAMES_SNIPPET","CIO_PODFILE_POST_INSTALL_SNIPPET","CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const CIO_PODFILE_REGEX = /pod 'RCT-Folly'/;\nexport const CIO_CIO_TARGET_REGEX = /cio_target_names/;\nexport const CIO_PODFILE_NOTIFICATION_REGEX = /target 'NotificationService' do/;\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \\|installer\\|/;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /(- \\(BOOL\\)application:\\(UIApplication \\*\\)application didFinishLaunchingWithOptions:\\(NSDictionary \\*\\)launchOptions(\\s|\\n)*?\\{)((.|\\n)*)\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate>/;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';\nexport const CIO_APPDELEGATEHEADER_SNIPPET = `\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n`;\n\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\n// Configure Customerio push notifications SDK by adding to application:didFinishLaunchingWithOptions: delegate method\n// From Braze docs: https://www.customer.io/docs/sdk/react-native/push/#obj-c-push\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification:self];\n`;\n\n// Enable push handling - notification response\nexport const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `\n- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {\n [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];\n}`;\n\n// Foreground push handling\nexport const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `\n// show push when the app is in foreground\n- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {\n completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);\n}`;\nexport const CIO_PODFILE_NOTIFICATION_SNIPPET = `\ntarget '${CIO_NOTIFICATION_TARGET_NAME}' do\n pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'\nend`;\nexport const CIO_PODFILE_SNIPPET = `\n pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec'\n pod 'boost', :podspec => '../node_modules/react-native/third-party-podspecs/boost.podspec'\n pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'`;\nexport const CIO_PODFILE_TARGET_NAMES_SNIPPET = `\n cio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n ]`;\nexport const CIO_PODFILE_POST_INSTALL_SNIPPET = `\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end`;\nexport const CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = `\ncio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n]\n\npost_install do |installer|\n\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end\n react_native_post_install(installer)\n __apply_Xcode_12_5_M1_post_install_workaround(installer)\nend`;\n"],"mappings":";;;;;;AAAO,MAAMA,2BAA2B,GAAI,kEAAiE;AAAC;AACvG,MAAMC,qBAAqB,GAAG,MAAM;AAAC;AACrC,MAAMC,iBAAiB,GAAG,iBAAiB;AAAC;AAC5C,MAAMC,oBAAoB,GAAG,kBAAkB;AAAC;AAChD,MAAMC,8BAA8B,GAAG,iCAAiC;AAAC;AACzE,MAAMC,+BAA+B,GAAG,wBAAwB;AAAC;AACjE,MAAMC,mCAAmC,GAAG,4BAA4B;AAAC;AACzE,MAAMC,6BAA6B,GAAG,sBAAsB;AAAC;AAC7D,MAAMC,8BAA8B,GAAG,+BAA+B;AAAC;AACvE,MAAMC,kCAAkC,GAC7C,gOAAgO;AAAC;AAE5N,MAAMC,0DAA0D,GACrE,kGAAkG;AAAC;AAE9F,MAAMC,8DAA8D,GACzE,wJAAwJ;AAAC;AAEpJ,MAAMC,0DAA0D,GACrE,wGAAwG;AAAC;AAEpG,MAAMC,gCAAgC,GAC3C,mCAAmC;AAAC;AAE/B,MAAMC,2BAA2B,GACtC,mEAAmE;AAAC;AAC/D,MAAMC,sBAAsB,GAAG,GAAG;AAAC;AACnC,MAAMC,4BAA4B,GAAG,KAAK;AAAC;AAC3C,MAAMC,eAAe,GAAG,eAAe;AAAC;AACxC,MAAMC,4BAA4B,GAAG,qBAAqB;AAAC;AAC3D,MAAMC,6BAA6B,GAAI;AAC9C;AACA;AACA;AACA,CAAC;AAAC;AAEK,MAAMC,8CAA8C,GAAI;AAC/D;AACA,CAAC;AAAC;AAEK,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;AAAC;AAEK,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;;AAED;AACA;AAAA;AACO,MAAMC,2CAA2C,GAAI;AAC5D;AACA;AACA,CAAC;;AAED;AAAA;AACO,MAAMC,iDAAiD,GAAI;AAClE;AACA;AACA,EAAE;;AAEF;AAAA;AACO,MAAMC,0CAA0C,GAAI;AAC3D;AACA;AACA;AACA,EAAE;AAAC;AACI,MAAMC,gCAAgC,GAAI;AACjD,UAAUR,4BAA6B;AACvC;AACA,IAAI;AAAC;AACE,MAAMS,mBAAmB,GAAI;AACpC;AACA;AACA,wDAAwD;AAAC;AAClD,MAAMC,gCAAgC,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA,IAAI;AAAC;AACE,MAAMC,gCAAgC,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AAAC;AACF,MAAMC,yCAAyC,GAAI;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AAAC"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<key>CFBundleDevelopmentRegion</key>
|
|
10
10
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
11
11
|
<key>CFBundleDisplayName</key>
|
|
12
|
-
<string>
|
|
12
|
+
<string>NotificationServiceExtension</string>
|
|
13
13
|
<key>CFBundleExecutable</key>
|
|
14
14
|
<string>$(EXECUTABLE_NAME)</string>
|
|
15
15
|
<key>CFBundleIdentifier</key>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<key>NSExtensionPointIdentifier</key>
|
|
26
26
|
<string>com.apple.usernotifications.service</string>
|
|
27
27
|
<key>NSExtensionPrincipalClass</key>
|
|
28
|
-
<string>
|
|
28
|
+
<string>NotificationService</string>
|
|
29
29
|
</dict>
|
|
30
30
|
</dict>
|
|
31
31
|
</plist>
|
package/lib/commonjs/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h}
RENAMED
|
File without changes
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
#import "
|
|
3
|
-
|
|
4
|
-
// Import "Your-target-name-Swift.h" file
|
|
5
|
-
#import "CIONotificationService-Swift.h"
|
|
2
|
+
#import "NotificationService.h"
|
|
3
|
+
#import "NotificationService-Swift.h"
|
|
6
4
|
|
|
7
5
|
@interface NotificationService ()
|
|
8
6
|
|
|
@@ -14,7 +12,6 @@
|
|
|
14
12
|
@implementation NotificationService
|
|
15
13
|
|
|
16
14
|
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
|
|
17
|
-
// MARK: - CIO-TECH-ASSISTANCE
|
|
18
15
|
NotificationServiceCioManager* cioManagerObj = [[NotificationServiceCioManager alloc] init];
|
|
19
16
|
[cioManagerObj didReceive:request withContentHandler:contentHandler];
|
|
20
17
|
}
|
|
@@ -22,7 +19,6 @@
|
|
|
22
19
|
- (void)serviceExtensionTimeWillExpire {
|
|
23
20
|
// Called just before the extension will be terminated by the system.
|
|
24
21
|
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
|
|
25
|
-
// MARK: - CIO-TECH-ASSISTANCE
|
|
26
22
|
NotificationServiceCioManager* cioManagerObj = [[NotificationServiceCioManager alloc] init];
|
|
27
23
|
[cioManagerObj serviceExtensionTimeWillExpire];
|
|
28
24
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PushNotification.swift
|
|
3
|
-
// testandroidapp
|
|
4
|
-
//
|
|
5
|
-
// Created by Segun Xtreem on 10/09/2022.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
1
|
import Foundation
|
|
9
2
|
import CioMessagingPushAPN
|
|
10
3
|
import CioTracking
|
|
@@ -16,12 +9,11 @@ public class CIOAppPushNotificationsHandler : NSObject {
|
|
|
16
9
|
|
|
17
10
|
public override init() {}
|
|
18
11
|
|
|
19
|
-
// MARK: - ObjCNEW
|
|
20
12
|
@objc(registerPushNotification:)
|
|
21
13
|
public func registerPushNotification(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {
|
|
22
14
|
|
|
23
15
|
let center = UNUserNotificationCenter.current()
|
|
24
|
-
center.delegate = notificationDelegate
|
|
16
|
+
center.delegate = notificationDelegate
|
|
25
17
|
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
|
|
26
18
|
if error == nil{
|
|
27
19
|
DispatchQueue.main.async {
|
|
@@ -41,7 +33,6 @@ public class CIOAppPushNotificationsHandler : NSObject {
|
|
|
41
33
|
MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
|
|
42
34
|
}
|
|
43
35
|
|
|
44
|
-
// MARK: - ObjCNEW
|
|
45
36
|
@objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)
|
|
46
37
|
public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
|
47
38
|
let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
|
|
@@ -39,6 +39,38 @@ class FileManagement {
|
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
+
static exists(path) {
|
|
43
|
+
return (0, _fs.existsSync)(path);
|
|
44
|
+
}
|
|
45
|
+
static copyFile(src, dest) {
|
|
46
|
+
try {
|
|
47
|
+
(0, _fs.copyFileSync)(src, dest);
|
|
48
|
+
} catch (err) {
|
|
49
|
+
console.log(`Error copying file from ${src} to ${dest}: `, err);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static mkdir(path, options) {
|
|
53
|
+
try {
|
|
54
|
+
(0, _fs.mkdirSync)(path, options);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
console.log(`Error creating directory ${path}: `, err);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
static writeFile(path, data) {
|
|
60
|
+
try {
|
|
61
|
+
(0, _fs.writeFileSync)(path, data);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.log(`Error writing to file ${path}: `, err);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
static readFile(path) {
|
|
67
|
+
try {
|
|
68
|
+
return (0, _fs.readFileSync)(path, 'utf-8');
|
|
69
|
+
} catch (err) {
|
|
70
|
+
console.log(`Error reading file ${path}: `, err);
|
|
71
|
+
}
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
42
74
|
}
|
|
43
75
|
exports.FileManagement = FileManagement;
|
|
44
76
|
//# sourceMappingURL=fileManagement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FileManagement","read","path","Promise","resolve","reject","readFile","err","data","write","contents","writeFile","append","appendFile"],"sources":["fileManagement.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"names":["FileManagement","read","path","Promise","resolve","reject","readFile","err","data","write","contents","writeFile","append","appendFile","exists","existsSync","copyFile","src","dest","copyFileSync","console","log","mkdir","options","mkdirSync","writeFileSync","readFileSync"],"sources":["fileManagement.ts"],"sourcesContent":["import {\n readFile,\n writeFile,\n appendFile,\n existsSync,\n copyFileSync,\n mkdirSync,\n writeFileSync,\n readFileSync,\n MakeDirectoryOptions,\n} from 'fs';\n\nexport class FileManagement {\n static async read(path: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n readFile(path, 'utf8', (err, data) => {\n if (err || !data) {\n reject(err);\n return;\n }\n resolve(data);\n });\n });\n }\n\n static async write(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n writeFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static async append(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n appendFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static exists(path: string) {\n return existsSync(path);\n }\n\n static copyFile(src: string, dest: string) {\n try {\n copyFileSync(src, dest);\n } catch (err) {\n console.log(`Error copying file from ${src} to ${dest}: `, err);\n }\n }\n\n static mkdir(path: string, options: MakeDirectoryOptions) {\n try {\n mkdirSync(path, options);\n } catch (err) {\n console.log(`Error creating directory ${path}: `, err);\n }\n }\n\n static writeFile(path: string, data: string) {\n try {\n writeFileSync(path, data);\n } catch (err) {\n console.log(`Error writing to file ${path}: `, err);\n }\n }\n\n static readFile(path: string) {\n try {\n return readFileSync(path, 'utf-8');\n } catch (err) {\n console.log(`Error reading file ${path}: `, err);\n }\n\n return '';\n }\n}\n"],"mappings":";;;;;;AAAA;AAYO,MAAMA,cAAc,CAAC;EAC1B,aAAaC,IAAI,CAACC,IAAY,EAAmB;IAC/C,OAAO,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC9C,IAAAC,YAAQ,EAACJ,IAAI,EAAE,MAAM,EAAE,CAACK,GAAG,EAAEC,IAAI,KAAK;QACpC,IAAID,GAAG,IAAI,CAACC,IAAI,EAAE;UAChBH,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,CAACI,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaC,KAAK,CAACP,IAAY,EAAEQ,QAAgB,EAAiB;IAChE,OAAO,IAAIP,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5C,IAAAM,aAAS,EAACT,IAAI,EAAEQ,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QACzC,IAAIA,GAAG,EAAE;UACPF,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,EAAE;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaQ,MAAM,CAACV,IAAY,EAAEQ,QAAgB,EAAiB;IACjE,OAAO,IAAIP,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5C,IAAAQ,cAAU,EAACX,IAAI,EAAEQ,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QAC1C,IAAIA,GAAG,EAAE;UACPF,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,EAAE;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,OAAOU,MAAM,CAACZ,IAAY,EAAE;IAC1B,OAAO,IAAAa,cAAU,EAACb,IAAI,CAAC;EACzB;EAEA,OAAOc,QAAQ,CAACC,GAAW,EAAEC,IAAY,EAAE;IACzC,IAAI;MACF,IAAAC,gBAAY,EAACF,GAAG,EAAEC,IAAI,CAAC;IACzB,CAAC,CAAC,OAAOX,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,2BAA0BJ,GAAI,OAAMC,IAAK,IAAG,EAAEX,GAAG,CAAC;IACjE;EACF;EAEA,OAAOe,KAAK,CAACpB,IAAY,EAAEqB,OAA6B,EAAE;IACxD,IAAI;MACF,IAAAC,aAAS,EAACtB,IAAI,EAAEqB,OAAO,CAAC;IAC1B,CAAC,CAAC,OAAOhB,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,4BAA2BnB,IAAK,IAAG,EAAEK,GAAG,CAAC;IACxD;EACF;EAEA,OAAOI,SAAS,CAACT,IAAY,EAAEM,IAAY,EAAE;IAC3C,IAAI;MACF,IAAAiB,iBAAa,EAACvB,IAAI,EAAEM,IAAI,CAAC;IAC3B,CAAC,CAAC,OAAOD,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,yBAAwBnB,IAAK,IAAG,EAAEK,GAAG,CAAC;IACrD;EACF;EAEA,OAAOD,QAAQ,CAACJ,IAAY,EAAE;IAC5B,IAAI;MACF,OAAO,IAAAwB,gBAAY,EAACxB,IAAI,EAAE,OAAO,CAAC;IACpC,CAAC,CAAC,OAAOK,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,sBAAqBnB,IAAK,IAAG,EAAEK,GAAG,CAAC;IAClD;IAEA,OAAO,EAAE;EACX;AACF;AAAC"}
|
|
@@ -11,15 +11,20 @@ async function injectCIOPodfileCode(iosPath) {
|
|
|
11
11
|
const filename = `${iosPath}/Podfile`;
|
|
12
12
|
const podfile = await _fileManagement.FileManagement.read(filename);
|
|
13
13
|
const matches = podfile.match(_ios.CIO_PODFILE_REGEX);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
content =
|
|
14
|
+
const targetMatch = podfile.match(_ios.CIO_CIO_TARGET_REGEX);
|
|
15
|
+
if (!targetMatch) {
|
|
16
|
+
const lines = podfile.split('\n');
|
|
17
|
+
const index = lines.findIndex(line => _ios.CIO_PODFILE_POST_INSTALL_REGEX.test(line));
|
|
18
|
+
let content = lines;
|
|
19
|
+
if (index > -1) {
|
|
20
|
+
content = [...lines.slice(0, index - 1), !matches ? _ios.CIO_PODFILE_SNIPPET : '', _ios.CIO_PODFILE_TARGET_NAMES_SNIPPET, ...lines.slice(index - 1, index + 1), _ios.CIO_PODFILE_POST_INSTALL_SNIPPET, ...lines.slice(index + 1)];
|
|
21
|
+
} else {
|
|
22
|
+
content.push(_ios.CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);
|
|
23
|
+
}
|
|
24
|
+
_fileManagement.FileManagement.write(filename, content.join('\n'));
|
|
19
25
|
} else {
|
|
20
|
-
|
|
26
|
+
console.log('Customerio Podfile snippets already exists. Skipping...');
|
|
21
27
|
}
|
|
22
|
-
_fileManagement.FileManagement.write(filename, content.join('\n'));
|
|
23
28
|
}
|
|
24
29
|
async function injectCIONotificationPodfileCode(iosPath) {
|
|
25
30
|
const filename = `${iosPath}/Podfile`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["injectCIOPodfileCode","iosPath","filename","podfile","FileManagement","read","matches","match","CIO_PODFILE_REGEX","lines","split","index","findIndex","line","CIO_PODFILE_POST_INSTALL_REGEX","test","content","slice","CIO_PODFILE_SNIPPET","CIO_PODFILE_TARGET_NAMES_SNIPPET","CIO_PODFILE_POST_INSTALL_SNIPPET","push","CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET","write","join","injectCIONotificationPodfileCode","CIO_PODFILE_NOTIFICATION_REGEX","append","CIO_PODFILE_NOTIFICATION_SNIPPET"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import {\n CIO_PODFILE_REGEX,\n CIO_PODFILE_SNIPPET,\n CIO_PODFILE_POST_INSTALL_REGEX,\n CIO_PODFILE_TARGET_NAMES_SNIPPET,\n CIO_PODFILE_POST_INSTALL_SNIPPET,\n CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET,\n CIO_PODFILE_NOTIFICATION_SNIPPET,\n CIO_PODFILE_NOTIFICATION_REGEX,\n} from '../constants/ios';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_REGEX);\n\n const lines = podfile.split('\\n');\n
|
|
1
|
+
{"version":3,"names":["injectCIOPodfileCode","iosPath","filename","podfile","FileManagement","read","matches","match","CIO_PODFILE_REGEX","targetMatch","CIO_CIO_TARGET_REGEX","lines","split","index","findIndex","line","CIO_PODFILE_POST_INSTALL_REGEX","test","content","slice","CIO_PODFILE_SNIPPET","CIO_PODFILE_TARGET_NAMES_SNIPPET","CIO_PODFILE_POST_INSTALL_SNIPPET","push","CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET","write","join","console","log","injectCIONotificationPodfileCode","CIO_PODFILE_NOTIFICATION_REGEX","append","CIO_PODFILE_NOTIFICATION_SNIPPET"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import {\n CIO_PODFILE_REGEX,\n CIO_PODFILE_SNIPPET,\n CIO_PODFILE_POST_INSTALL_REGEX,\n CIO_PODFILE_TARGET_NAMES_SNIPPET,\n CIO_PODFILE_POST_INSTALL_SNIPPET,\n CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET,\n CIO_PODFILE_NOTIFICATION_SNIPPET,\n CIO_PODFILE_NOTIFICATION_REGEX,\n CIO_CIO_TARGET_REGEX,\n} from '../constants/ios';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_REGEX);\n const targetMatch = podfile.match(CIO_CIO_TARGET_REGEX);\n\n if (!targetMatch) {\n const lines = podfile.split('\\n');\n const index = lines.findIndex((line) =>\n CIO_PODFILE_POST_INSTALL_REGEX.test(line)\n );\n let content: string[] = lines;\n if (index > -1) {\n content = [\n ...lines.slice(0, index - 1),\n !matches ? CIO_PODFILE_SNIPPET : '',\n CIO_PODFILE_TARGET_NAMES_SNIPPET,\n ...lines.slice(index - 1, index + 1),\n CIO_PODFILE_POST_INSTALL_SNIPPET,\n ...lines.slice(index + 1),\n ];\n } else {\n content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);\n }\n\n FileManagement.write(filename, content.join('\\n'));\n } else {\n console.log('Customerio Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_NOTIFICATION_REGEX);\n\n if (!matches) {\n FileManagement.append(filename, CIO_PODFILE_NOTIFICATION_SNIPPET);\n }\n}\n"],"mappings":";;;;;;;AAAA;AAWA;AAEO,eAAeA,oBAAoB,CAACC,OAAe,EAAE;EAC1D,MAAMC,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EACnD,MAAMI,OAAO,GAAGH,OAAO,CAACI,KAAK,CAACC,sBAAiB,CAAC;EAChD,MAAMC,WAAW,GAAGN,OAAO,CAACI,KAAK,CAACG,yBAAoB,CAAC;EAEvD,IAAI,CAACD,WAAW,EAAE;IAChB,MAAME,KAAK,GAAGR,OAAO,CAACS,KAAK,CAAC,IAAI,CAAC;IACjC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IACjCC,mCAA8B,CAACC,IAAI,CAACF,IAAI,CAAC,CAC1C;IACD,IAAIG,OAAiB,GAAGP,KAAK;IAC7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;MACdK,OAAO,GAAG,CACR,GAAGP,KAAK,CAACQ,KAAK,CAAC,CAAC,EAAEN,KAAK,GAAG,CAAC,CAAC,EAC5B,CAACP,OAAO,GAAGc,wBAAmB,GAAG,EAAE,EACnCC,qCAAgC,EAChC,GAAGV,KAAK,CAACQ,KAAK,CAACN,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAG,CAAC,CAAC,EACpCS,qCAAgC,EAChC,GAAGX,KAAK,CAACQ,KAAK,CAACN,KAAK,GAAG,CAAC,CAAC,CAC1B;IACH,CAAC,MAAM;MACLK,OAAO,CAACK,IAAI,CAACC,8CAAyC,CAAC;IACzD;IAEApB,8BAAc,CAACqB,KAAK,CAACvB,QAAQ,EAAEgB,OAAO,CAACQ,IAAI,CAAC,IAAI,CAAC,CAAC;EACpD,CAAC,MAAM;IACLC,OAAO,CAACC,GAAG,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEO,eAAeC,gCAAgC,CAAC5B,OAAe,EAAE;EACtE,MAAMC,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EACnD,MAAMI,OAAO,GAAGH,OAAO,CAACI,KAAK,CAACuB,mCAA8B,CAAC;EAE7D,IAAI,CAACxB,OAAO,EAAE;IACZF,8BAAc,CAAC2B,MAAM,CAAC7B,QAAQ,EAAE8B,qCAAgC,CAAC;EACnE;AACF"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -4,12 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _injectAnalytics = require("./analytics/injectAnalytics");
|
|
7
8
|
var _withCIOAndroid = require("./android/withCIOAndroid");
|
|
8
9
|
var _withCIOIos = require("./ios/withCIOIos");
|
|
9
10
|
// Entry point for config plugin
|
|
10
11
|
function withCustomerIOPlugin(config, props) {
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
if (props.ios) {
|
|
13
|
+
config = (0, _withCIOIos.withCIOIos)(config, props.ios);
|
|
14
|
+
}
|
|
15
|
+
if (props.android) {
|
|
16
|
+
config = (0, _withCIOAndroid.withCIOAndroid)(config, props.android);
|
|
17
|
+
}
|
|
18
|
+
config = (0, _injectAnalytics.withAnalytics)(config, props);
|
|
13
19
|
return config;
|
|
14
20
|
}
|
|
15
21
|
var _default = withCustomerIOPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withCustomerIOPlugin","config","props","withCIOIos","withCIOAndroid"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {
|
|
1
|
+
{"version":3,"names":["withCustomerIOPlugin","config","props","ios","withCIOIos","android","withCIOAndroid","withAnalytics"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withAnalytics } from './analytics/injectAnalytics';\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type { CustomerIOPluginOptions } from './types/cio-types';\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n if (props.ios) {\n config = withCIOIos(config, props.ios);\n }\n\n if (props.android) {\n config = withCIOAndroid(config, props.android);\n }\n\n config = withAnalytics(config, props);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":";;;;;;AAEA;AACA;AACA;AAGA;AACA,SAASA,oBAAoB,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA,IAAIA,KAAK,CAACC,GAAG,EAAE;IACbF,MAAM,GAAG,IAAAG,sBAAU,EAACH,MAAM,EAAEC,KAAK,CAACC,GAAG,CAAC;EACxC;EAEA,IAAID,KAAK,CAACG,OAAO,EAAE;IACjBJ,MAAM,GAAG,IAAAK,8BAAc,EAACL,MAAM,EAAEC,KAAK,CAACG,OAAO,CAAC;EAChD;EAEAJ,MAAM,GAAG,IAAAM,8BAAa,EAACN,MAAM,EAAEC,KAAK,CAAC;EAErC,OAAOD,MAAM;AACf;AAAC,eAEcD,oBAAoB;AAAA"}
|
|
@@ -10,15 +10,11 @@ var _ios = require("../helpers/constants/ios");
|
|
|
10
10
|
var _codeInjection = require("../helpers/utils/codeInjection");
|
|
11
11
|
var _fileManagement = require("../helpers/utils/fileManagement");
|
|
12
12
|
const pushCodeSnippets = [_ios.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET, _ios.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET];
|
|
13
|
-
const additionalMethodsForPushNotifications = `${pushCodeSnippets.join('\n')}\n`; // Join
|
|
13
|
+
const additionalMethodsForPushNotifications = `${pushCodeSnippets.join('\n')}\n`; // Join newlines and ensure a newline at the end.
|
|
14
14
|
|
|
15
|
-
const addImport = stringContents => {
|
|
15
|
+
const addImport = (stringContents, appName) => {
|
|
16
16
|
const importRegex = /^(#import .*)\n/gm;
|
|
17
|
-
const addedImport =
|
|
18
|
-
// Add swift bridge imports
|
|
19
|
-
#import <ExpoModulesCore-Swift.h>
|
|
20
|
-
#import <testiosapp-Swift.h>
|
|
21
|
-
`;
|
|
17
|
+
const addedImport = getImportSnippet(appName);
|
|
22
18
|
const match = stringContents.match(importRegex);
|
|
23
19
|
let endOfMatchIndex;
|
|
24
20
|
if (!match || match.index === undefined) {
|
|
@@ -58,19 +54,32 @@ const addAppdelegateHeaderModification = stringContents => {
|
|
|
58
54
|
const withAppDelegateModifications = configOuter => {
|
|
59
55
|
return (0, _configPlugins.withAppDelegate)(configOuter, async config => {
|
|
60
56
|
let stringContents = config.modResults.contents;
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
const regex = new RegExp(`#import <${config.modRequest.projectName}-Swift.h>`);
|
|
58
|
+
const match = stringContents.match(regex);
|
|
59
|
+
if (!match) {
|
|
60
|
+
const headerPath = (0, _Paths.getAppDelegateHeaderFilePath)(config.modRequest.projectRoot);
|
|
61
|
+
let headerContent = await _fileManagement.FileManagement.read(headerPath);
|
|
62
|
+
headerContent = addAppdelegateHeaderModification(headerContent);
|
|
63
|
+
_fileManagement.FileManagement.write(headerPath, headerContent);
|
|
64
|
+
stringContents = addImport(stringContents, config.modRequest.projectName);
|
|
65
|
+
stringContents = addNotificationHandlerDeclaration(stringContents);
|
|
66
|
+
stringContents = addNotificationConfiguration(stringContents);
|
|
67
|
+
stringContents = addAdditionalMethodsForPushNotifications(stringContents);
|
|
68
|
+
stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
|
|
69
|
+
stringContents = AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
|
|
70
|
+
config.modResults.contents = stringContents;
|
|
71
|
+
} else {
|
|
72
|
+
console.log('Customerio AppDelegate changes already exist. Skipping...');
|
|
73
|
+
}
|
|
72
74
|
return config;
|
|
73
75
|
});
|
|
74
76
|
};
|
|
75
77
|
exports.withAppDelegateModifications = withAppDelegateModifications;
|
|
78
|
+
function getImportSnippet(appName) {
|
|
79
|
+
return `
|
|
80
|
+
// Add swift bridge imports
|
|
81
|
+
#import <ExpoModulesCore-Swift.h>
|
|
82
|
+
#import <${appName}-Swift.h>
|
|
83
|
+
`;
|
|
84
|
+
}
|
|
76
85
|
//# sourceMappingURL=withAppDelegateModifications.js.map
|