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.
- package/lib/commonjs/analytics/injectAnalytics.js +31 -0
- package/lib/commonjs/analytics/injectAnalytics.js.map +1 -0
- package/lib/commonjs/android/withAppGoogleServices.js +22 -0
- package/lib/commonjs/android/withAppGoogleServices.js.map +1 -0
- package/lib/commonjs/android/withCIOAndroid.js +18 -0
- package/lib/commonjs/android/withCIOAndroid.js.map +1 -0
- package/lib/commonjs/android/withGistMavenRepository.js +21 -0
- package/lib/commonjs/android/withGistMavenRepository.js.map +1 -0
- package/lib/commonjs/android/withGoogleServicesJSON.js +34 -0
- package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -0
- package/lib/commonjs/android/withProjectGoogleServices.js +20 -0
- package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -0
- package/lib/commonjs/helpers/constants/android.js +21 -0
- package/lib/commonjs/helpers/constants/android.js.map +1 -0
- package/lib/commonjs/helpers/constants/globals.d.js +2 -0
- package/lib/commonjs/helpers/constants/globals.d.js.map +1 -0
- package/lib/commonjs/helpers/constants/ios.js +140 -0
- package/lib/commonjs/helpers/constants/ios.js.map +1 -0
- package/{build/helpers/ios/CIONotificationService-Info.plist → lib/commonjs/helpers/native-files/ios/NotificationService-Info.plist} +2 -2
- package/{build/helpers/ios/CIONotificationService.h → lib/commonjs/helpers/native-files/ios/NotificationService.h} +0 -0
- package/{build/helpers/ios/CIONotificationService.m → lib/commonjs/helpers/native-files/ios/NotificationService.m} +2 -6
- package/{build/helpers/ios/CIONotificationService.swift → lib/commonjs/helpers/native-files/ios/NotificationService.swift} +0 -2
- package/{build/helpers → lib/commonjs/helpers/native-files}/ios/PushNotification.swift +1 -10
- package/lib/commonjs/helpers/utils/codeInjection.js +33 -0
- package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
- package/lib/commonjs/helpers/utils/fileManagement.js +76 -0
- package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -0
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +37 -0
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
- package/lib/commonjs/index.js +23 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/ios/withAppDelegateModifications.js +85 -0
- package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
- package/lib/commonjs/ios/withAppDelegateXcodeProject.js +79 -0
- package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -0
- package/lib/commonjs/ios/withCIOIos.js +23 -0
- package/lib/commonjs/ios/withCIOIos.js.map +1 -0
- package/lib/commonjs/ios/withNotificationsXcodeProject.js +158 -0
- package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
- package/lib/commonjs/ios/withXcodeProject.js +28 -0
- package/lib/commonjs/ios/withXcodeProject.js.map +1 -0
- package/lib/commonjs/types/cio-types.js +2 -0
- package/lib/commonjs/types/cio-types.js.map +1 -0
- 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 +15 -0
- package/lib/module/android/withAppGoogleServices.js.map +1 -0
- package/lib/module/android/withCIOAndroid.js +12 -0
- package/lib/module/android/withCIOAndroid.js.map +1 -0
- package/lib/module/android/withGistMavenRepository.js +14 -0
- package/lib/module/android/withGistMavenRepository.js.map +1 -0
- package/lib/module/android/withGoogleServicesJSON.js +27 -0
- package/lib/module/android/withGoogleServicesJSON.js.map +1 -0
- package/lib/module/android/withProjectGoogleServices.js +13 -0
- package/lib/module/android/withProjectGoogleServices.js.map +1 -0
- package/lib/module/helpers/constants/android.js +8 -0
- package/lib/module/helpers/constants/android.js.map +1 -0
- package/lib/module/helpers/constants/globals.d.js +2 -0
- package/lib/module/helpers/constants/globals.d.js.map +1 -0
- package/lib/module/helpers/constants/ios.js +103 -0
- package/lib/module/helpers/constants/ios.js.map +1 -0
- package/lib/module/helpers/native-files/ios/NotificationService-Info.plist +31 -0
- package/lib/module/helpers/native-files/ios/NotificationService.h +5 -0
- package/lib/module/helpers/native-files/ios/NotificationService.m +26 -0
- package/lib/module/helpers/native-files/ios/NotificationService.swift +19 -0
- package/lib/module/helpers/native-files/ios/PushNotification.swift +47 -0
- package/lib/module/helpers/utils/codeInjection.js +24 -0
- package/lib/module/helpers/utils/codeInjection.js.map +1 -0
- package/lib/module/helpers/utils/fileManagement.js +69 -0
- package/lib/module/helpers/utils/fileManagement.js.map +1 -0
- package/lib/module/helpers/utils/injectCIOPodfileCode.js +30 -0
- package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
- package/lib/module/index.js +16 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/ios/withAppDelegateModifications.js +78 -0
- package/lib/module/ios/withAppDelegateModifications.js.map +1 -0
- package/lib/module/ios/withAppDelegateXcodeProject.js +71 -0
- package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -0
- package/lib/module/ios/withCIOIos.js +17 -0
- package/lib/module/ios/withCIOIos.js.map +1 -0
- package/lib/module/ios/withNotificationsXcodeProject.js +150 -0
- package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
- package/lib/module/ios/withXcodeProject.js +21 -0
- package/lib/module/ios/withXcodeProject.js.map +1 -0
- package/lib/module/types/cio-types.js +2 -0
- package/lib/module/types/cio-types.js.map +1 -0
- 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/android/withAppGoogleServices.d.ts +3 -0
- package/lib/typescript/android/withCIOAndroid.d.ts +3 -0
- package/lib/typescript/android/withGistMavenRepository.d.ts +3 -0
- package/lib/typescript/android/withGoogleServicesJSON.d.ts +3 -0
- package/lib/typescript/android/withProjectGoogleServices.d.ts +3 -0
- package/lib/typescript/helpers/constants/android.d.ts +7 -0
- package/lib/typescript/helpers/constants/ios.d.ts +31 -0
- package/lib/typescript/helpers/utils/codeInjection.d.ts +4 -0
- package/lib/typescript/helpers/utils/fileManagement.d.ts +12 -0
- package/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -0
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/ios/withAppDelegateModifications.d.ts +2 -0
- package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +3 -0
- package/lib/typescript/ios/withCIOIos.d.ts +3 -0
- package/lib/typescript/ios/withNotificationsXcodeProject.d.ts +3 -0
- package/lib/typescript/ios/withXcodeProject.d.ts +3 -0
- package/lib/typescript/types/cio-types.d.ts +25 -0
- package/lib/typescript/version.d.ts +1 -0
- package/package.json +88 -13
- package/src/analytics/injectAnalytics.ts +36 -0
- package/src/android/withAppGoogleServices.ts +26 -0
- package/src/android/withCIOAndroid.ts +19 -0
- package/src/android/withGistMavenRepository.ts +26 -0
- package/src/android/withGoogleServicesJSON.ts +36 -0
- package/src/android/withProjectGoogleServices.ts +24 -0
- package/src/helpers/constants/android.ts +14 -0
- package/src/helpers/constants/globals.d.ts +8 -0
- package/src/helpers/constants/ios.ts +116 -0
- package/src/helpers/native-files/ios/NotificationService-Info.plist +31 -0
- package/src/helpers/native-files/ios/NotificationService.h +5 -0
- package/src/helpers/native-files/ios/NotificationService.m +26 -0
- package/src/helpers/native-files/ios/NotificationService.swift +19 -0
- package/src/helpers/native-files/ios/PushNotification.swift +47 -0
- package/src/helpers/utils/codeInjection.ts +46 -0
- package/src/helpers/utils/fileManagement.ts +87 -0
- package/src/helpers/utils/injectCIOPodfileCode.ts +53 -0
- package/src/index.ts +26 -0
- package/src/ios/withAppDelegateModifications.ts +166 -0
- package/src/ios/withAppDelegateXcodeProject.ts +89 -0
- package/src/ios/withCIOIos.ts +25 -0
- package/src/ios/withNotificationsXcodeProject.ts +237 -0
- package/src/ios/withXcodeProject.ts +25 -0
- package/src/types/cio-types.ts +31 -0
- package/src/version.ts +1 -0
- package/build/helpers/.DS_Store +0 -0
- package/build/helpers/ios/.DS_Store +0 -0
- package/build/package.json +0 -36
- package/build/src/android/withAppGoogleServices.js +0 -12
- package/build/src/android/withCIOAndroid.js +0 -15
- package/build/src/android/withGistMavenRepository.js +0 -12
- package/build/src/android/withGoogleServicesJSON.js +0 -24
- package/build/src/android/withProjectGoogleServices.js +0 -12
- package/build/src/helpers/constants/android.js +0 -9
- package/build/src/helpers/constants/ios.js +0 -102
- package/build/src/helpers/utils/codeInjection.js +0 -30
- package/build/src/helpers/utils/fileManagement.js +0 -40
- package/build/src/helpers/utils/injectCIOPodfileCode.js +0 -37
- package/build/src/index.js +0 -11
- package/build/src/ios/withAppDelegateModifications.js +0 -77
- package/build/src/ios/withAppDelegateXcodeProject.js +0 -78
- package/build/src/ios/withCIOIos.js +0 -15
- package/build/src/ios/withNotificationsXcodeProject.js +0 -133
- package/build/src/ios/withXcodeProject.js +0 -22
- package/build/src/types/cio-types.js +0 -8
package/package.json
CHANGED
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "customerio-expo-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"description": "Expo config plugin for the Customer IO React Native SDK",
|
|
5
|
-
"main": "
|
|
6
|
-
"
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"source": "src/index",
|
|
9
|
+
"react-native": "src/index",
|
|
7
10
|
"license": "MIT",
|
|
8
11
|
"files": [
|
|
9
|
-
"
|
|
12
|
+
"src",
|
|
13
|
+
"lib/**/*"
|
|
10
14
|
],
|
|
11
15
|
"scripts": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"clean": "rm -rf build",
|
|
16
|
+
"build": "npm run clean && tsc",
|
|
17
|
+
"prebuild": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
|
|
18
|
+
"clean": "rm -rf lib && npm run prebuild",
|
|
16
19
|
"expo-module": "expo-module",
|
|
17
|
-
"lint": "eslint .",
|
|
18
|
-
"
|
|
19
|
-
"prepare": "npm run clean &&
|
|
20
|
-
|
|
20
|
+
"lint": "eslint . --fix",
|
|
21
|
+
"typescript": "tsc --noEmit",
|
|
22
|
+
"prepare": "npm run clean && bob build"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"react-native",
|
|
26
|
+
"ios",
|
|
27
|
+
"android"
|
|
28
|
+
],
|
|
29
|
+
"repository": "https://github.com/customerio/customerio-expo-plugin",
|
|
30
|
+
"author": "ami-segun <segun@customer.io> (https://customer.io/)",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/customerio/customerio-expo-plugin/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/customerio/customerio-expo-plugin#readme",
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"registry": "https://registry.npmjs.org/"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"customerio-reactnative": "*"
|
|
21
40
|
},
|
|
22
41
|
"devDependencies": {
|
|
23
42
|
"@expo/config-plugins": "^4.1.4",
|
|
@@ -27,10 +46,66 @@
|
|
|
27
46
|
"eslint": "^8.14.0",
|
|
28
47
|
"eslint-config-prettier": "^8.5.0",
|
|
29
48
|
"eslint-plugin-prettier": "^4.0.0",
|
|
30
|
-
"expo-module-scripts": "^2.0.0",
|
|
31
49
|
"expo-build-properties": "^0.2.0",
|
|
50
|
+
"expo-module-scripts": "^2.0.0",
|
|
32
51
|
"prettier": "^2.6.2",
|
|
52
|
+
"react-native-builder-bob": "^0.18.3",
|
|
33
53
|
"typescript": "^4.6.4",
|
|
34
54
|
"xcode": "^3.0.1"
|
|
55
|
+
},
|
|
56
|
+
"jest": {
|
|
57
|
+
"preset": "react-native",
|
|
58
|
+
"modulePathIgnorePatterns": [
|
|
59
|
+
"<rootDir>/lib/"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"commitlint": {
|
|
63
|
+
"extends": [
|
|
64
|
+
"@commitlint/config-conventional"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"eslintConfig": {
|
|
68
|
+
"root": true,
|
|
69
|
+
"extends": [
|
|
70
|
+
"@react-native-community",
|
|
71
|
+
"prettier"
|
|
72
|
+
],
|
|
73
|
+
"rules": {
|
|
74
|
+
"prettier/prettier": [
|
|
75
|
+
"error",
|
|
76
|
+
{
|
|
77
|
+
"quoteProps": "consistent",
|
|
78
|
+
"singleQuote": true,
|
|
79
|
+
"tabWidth": 2,
|
|
80
|
+
"trailingComma": "es5",
|
|
81
|
+
"useTabs": false
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"eslintIgnore": [
|
|
87
|
+
"node_modules/",
|
|
88
|
+
"lib/"
|
|
89
|
+
],
|
|
90
|
+
"prettier": {
|
|
91
|
+
"quoteProps": "consistent",
|
|
92
|
+
"singleQuote": true,
|
|
93
|
+
"tabWidth": 2,
|
|
94
|
+
"trailingComma": "es5",
|
|
95
|
+
"useTabs": false
|
|
96
|
+
},
|
|
97
|
+
"react-native-builder-bob": {
|
|
98
|
+
"source": "src",
|
|
99
|
+
"output": "lib",
|
|
100
|
+
"targets": [
|
|
101
|
+
"commonjs",
|
|
102
|
+
"module",
|
|
103
|
+
[
|
|
104
|
+
"typescript",
|
|
105
|
+
{
|
|
106
|
+
"project": "tsconfig.build.json"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
]
|
|
35
110
|
}
|
|
36
111
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LIB_VERSION } from './../version';
|
|
2
|
+
import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';
|
|
3
|
+
import { FileManagement } from '../helpers/utils/fileManagement';
|
|
4
|
+
import type { CustomerIOPluginOptions } from '../types/cio-types';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export const withAnalytics: ConfigPlugin<CustomerIOPluginOptions> = (config) => {
|
|
8
|
+
return withXcodeProject(config, async (props) => {
|
|
9
|
+
const expoVersionSnippet = `"expoVersion": "${LIB_VERSION}"`;
|
|
10
|
+
let versionRegEx = new RegExp(expoVersionSnippet);
|
|
11
|
+
const filename = `node_modules/customerio-reactnative/package.json`;
|
|
12
|
+
if (FileManagement.exists(filename)) {
|
|
13
|
+
const pJsonFile = await FileManagement.read(filename);
|
|
14
|
+
const lines = pJsonFile.split('\n');
|
|
15
|
+
const missingMmatch = pJsonFile.match(versionRegEx);
|
|
16
|
+
const expoVersionRegex = /"expoVersion": ".*"/;
|
|
17
|
+
const existatch = pJsonFile.match(expoVersionRegex);
|
|
18
|
+
|
|
19
|
+
if (existatch && !missingMmatch) {
|
|
20
|
+
const index = lines.findIndex((line) =>
|
|
21
|
+
expoVersionRegex.test(line)
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const content = [
|
|
25
|
+
...lines.slice(0, index),
|
|
26
|
+
` ${expoVersionSnippet},`,
|
|
27
|
+
...lines.slice(index + 1),
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
FileManagement.write(filename, content.join('\n'));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return props;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ConfigPlugin, withAppBuildGradle } from '@expo/config-plugins';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CIO_APP_APPLY_REGEX,
|
|
5
|
+
CIO_APP_GOOGLE_SNIPPET,
|
|
6
|
+
} from '../helpers/constants/android';
|
|
7
|
+
import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
|
|
8
|
+
|
|
9
|
+
export const withAppGoogleServices: ConfigPlugin<
|
|
10
|
+
CustomerIOPluginOptionsAndroid
|
|
11
|
+
> = (configOuter) => {
|
|
12
|
+
return withAppBuildGradle(configOuter, (props) => {
|
|
13
|
+
const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);
|
|
14
|
+
const match = props.modResults.contents.match(regex);
|
|
15
|
+
if (!match) {
|
|
16
|
+
props.modResults.contents = props.modResults.contents.replace(
|
|
17
|
+
CIO_APP_APPLY_REGEX,
|
|
18
|
+
`$1\n${CIO_APP_GOOGLE_SNIPPET}`
|
|
19
|
+
);
|
|
20
|
+
} else {
|
|
21
|
+
console.log('app/build.gradle snippet already exists. Skipping...');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return props;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ExpoConfig } from '@expo/config-types';
|
|
2
|
+
|
|
3
|
+
import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
|
|
4
|
+
import { withAppGoogleServices } from './withAppGoogleServices';
|
|
5
|
+
import { withGistMavenRepository } from './withGistMavenRepository';
|
|
6
|
+
import { withGoogleServicesJSON } from './withGoogleServicesJSON';
|
|
7
|
+
import { withProjectGoogleServices } from './withProjectGoogleServices';
|
|
8
|
+
|
|
9
|
+
export function withCIOAndroid(
|
|
10
|
+
config: ExpoConfig,
|
|
11
|
+
props: CustomerIOPluginOptionsAndroid
|
|
12
|
+
): ExpoConfig {
|
|
13
|
+
config = withGistMavenRepository(config, props);
|
|
14
|
+
config = withProjectGoogleServices(config, props);
|
|
15
|
+
config = withAppGoogleServices(config, props);
|
|
16
|
+
config = withGoogleServicesJSON(config, props);
|
|
17
|
+
|
|
18
|
+
return config;
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CIO_GIST_MAVEN_REGEX,
|
|
5
|
+
CIO_PROJECT_ALLPROJECTS_REGEX,
|
|
6
|
+
CIO_PROJECT_GIST_MAVEN_SNIPPET,
|
|
7
|
+
} from '../helpers/constants/android';
|
|
8
|
+
import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
|
|
9
|
+
|
|
10
|
+
export const withGistMavenRepository: ConfigPlugin<
|
|
11
|
+
CustomerIOPluginOptionsAndroid
|
|
12
|
+
> = (configOuter) => {
|
|
13
|
+
return withProjectBuildGradle(configOuter, (props) => {
|
|
14
|
+
const targetMatch = props.modResults.contents.match(CIO_GIST_MAVEN_REGEX);
|
|
15
|
+
if (!targetMatch) {
|
|
16
|
+
props.modResults.contents = props.modResults.contents.replace(
|
|
17
|
+
CIO_PROJECT_ALLPROJECTS_REGEX,
|
|
18
|
+
`$1\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`
|
|
19
|
+
);
|
|
20
|
+
} else {
|
|
21
|
+
console.log('build.gradle snippet alreade exists. Skipping...');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return props;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
|
|
3
|
+
import { FileManagement } from './../helpers/utils/fileManagement';
|
|
4
|
+
import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
|
|
5
|
+
|
|
6
|
+
export const withGoogleServicesJSON: ConfigPlugin<
|
|
7
|
+
CustomerIOPluginOptionsAndroid
|
|
8
|
+
> = (configOuter, cioProps) => {
|
|
9
|
+
return withProjectBuildGradle(configOuter, (props) => {
|
|
10
|
+
const options: CustomerIOPluginOptionsAndroid = {
|
|
11
|
+
androidPath: props.modRequest.platformProjectRoot,
|
|
12
|
+
googleServicesFilePath: cioProps?.googleServicesFilePath,
|
|
13
|
+
};
|
|
14
|
+
const { androidPath, googleServicesFilePath } = options;
|
|
15
|
+
if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {
|
|
16
|
+
if (googleServicesFilePath) {
|
|
17
|
+
try {
|
|
18
|
+
FileManagement.copyFile(
|
|
19
|
+
`${googleServicesFilePath}google-services.json`,
|
|
20
|
+
`${androidPath}/app/google-services.json`
|
|
21
|
+
);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.log(
|
|
24
|
+
`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
console.log(
|
|
30
|
+
`File already exists: ${androidPath}/app/google-services.json. Skipping...`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return props;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ConfigPlugin, withProjectBuildGradle } from '@expo/config-plugins';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CIO_PROJECT_BUILDSCRIPTS_REGEX,
|
|
5
|
+
CIO_PROJECT_GOOGLE_SNIPPET,
|
|
6
|
+
} from './../helpers/constants/android';
|
|
7
|
+
import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
|
|
8
|
+
|
|
9
|
+
export const withProjectGoogleServices: ConfigPlugin<
|
|
10
|
+
CustomerIOPluginOptionsAndroid
|
|
11
|
+
> = (configOuter) => {
|
|
12
|
+
return withProjectBuildGradle(configOuter, (props) => {
|
|
13
|
+
const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);
|
|
14
|
+
const match = props.modResults.contents.match(regex);
|
|
15
|
+
if (!match) {
|
|
16
|
+
props.modResults.contents = props.modResults.contents.replace(
|
|
17
|
+
CIO_PROJECT_BUILDSCRIPTS_REGEX,
|
|
18
|
+
`$1\n${CIO_PROJECT_GOOGLE_SNIPPET}`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return props;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const CIO_PROJECT_BUILDSCRIPTS_REGEX =
|
|
2
|
+
/(buildscript\s*\{(.|\n)*dependencies\s*\{)/;
|
|
3
|
+
export const CIO_APP_APPLY_REGEX = /(apply plugin: "com.android.application")/;
|
|
4
|
+
export const CIO_GIST_MAVEN_REGEX =
|
|
5
|
+
/maven { url "https:\/\/maven.gist.build" }/;
|
|
6
|
+
export const CIO_PROJECT_ALLPROJECTS_REGEX =
|
|
7
|
+
/(allprojects\s*\{(.|\n)*repositories\s*\{)/;
|
|
8
|
+
|
|
9
|
+
export const CIO_PROJECT_GIST_MAVEN_SNIPPET =
|
|
10
|
+
' maven { url "https://maven.gist.build" }';
|
|
11
|
+
export const CIO_APP_GOOGLE_SNIPPET =
|
|
12
|
+
'apply plugin: "com.google.gms.google-services" // Google Services plugin';
|
|
13
|
+
export const CIO_PROJECT_GOOGLE_SNIPPET =
|
|
14
|
+
' classpath "com.google.gms:google-services:4.3.13" // Google Services plugin';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;
|
|
2
|
+
export const IOS_DEPLOYMENT_TARGET = '13.0';
|
|
3
|
+
export const CIO_PODFILE_REGEX = /pod 'RCT-Folly'/;
|
|
4
|
+
export const CIO_CIO_TARGET_REGEX = /cio_target_names/;
|
|
5
|
+
export const CIO_PODFILE_NOTIFICATION_REGEX = /target 'NotificationService' do/;
|
|
6
|
+
export const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
|
|
7
|
+
export const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
|
|
8
|
+
export const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
|
|
9
|
+
export const CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \|installer\|/;
|
|
10
|
+
export const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =
|
|
11
|
+
/(- \(BOOL\)application:\(UIApplication \*\)application didFinishLaunchingWithOptions:\(NSDictionary \*\)launchOptions(\s|\n)*?\{)((.|\n)*)\[super(\s)application:application(\s)didFinishLaunchingWithOptions:launchOptions\];/;
|
|
12
|
+
|
|
13
|
+
export const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =
|
|
14
|
+
/return \[super application:application didFailToRegisterForRemoteNotificationsWithError:error\];/;
|
|
15
|
+
|
|
16
|
+
export const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =
|
|
17
|
+
/(- \(void\)application:\(UIApplication \*\)application didFailToRegisterForRemoteNotificationsWithError:\(NSError \*\)error(\s|\n)*?\{)(.|\n){2}.*\n\}/;
|
|
18
|
+
|
|
19
|
+
export const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =
|
|
20
|
+
/return \[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\];/;
|
|
21
|
+
|
|
22
|
+
export const CIO_APPDELEGATEDECLARATION_REGEX =
|
|
23
|
+
/@implementation AppDelegate(.|\n)/;
|
|
24
|
+
|
|
25
|
+
export const CIO_APPDELEGATEHEADER_REGEX =
|
|
26
|
+
/@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate>/;
|
|
27
|
+
export const DEFAULT_BUNDLE_VERSION = '1';
|
|
28
|
+
export const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
|
|
29
|
+
export const CIO_TARGET_NAME = 'CustomerIOSDK';
|
|
30
|
+
export const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';
|
|
31
|
+
export const CIO_APPDELEGATEHEADER_SNIPPET = `
|
|
32
|
+
#import <UserNotifications/UserNotifications.h>
|
|
33
|
+
|
|
34
|
+
@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
export const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `
|
|
38
|
+
CIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
export const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `
|
|
42
|
+
[pnHandlerObj application:application error:error];
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
export const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `
|
|
46
|
+
return [pnHandlerObj application:application deviceToken:deviceToken];
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
// Configure Customerio push notifications SDK by adding to application:didFinishLaunchingWithOptions: delegate method
|
|
50
|
+
// From Braze docs: https://www.customer.io/docs/sdk/react-native/push/#obj-c-push
|
|
51
|
+
export const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `
|
|
52
|
+
// Register for push notifications
|
|
53
|
+
[pnHandlerObj registerPushNotification:self];
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
// Enable push handling - notification response
|
|
57
|
+
export const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `
|
|
58
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
|
|
59
|
+
[pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
|
|
60
|
+
}`;
|
|
61
|
+
|
|
62
|
+
// Foreground push handling
|
|
63
|
+
export const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `
|
|
64
|
+
// show push when the app is in foreground
|
|
65
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
|
|
66
|
+
completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);
|
|
67
|
+
}`;
|
|
68
|
+
export const CIO_PODFILE_NOTIFICATION_SNIPPET = `
|
|
69
|
+
target '${CIO_NOTIFICATION_TARGET_NAME}' do
|
|
70
|
+
pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'
|
|
71
|
+
end`;
|
|
72
|
+
export const CIO_PODFILE_SNIPPET = `
|
|
73
|
+
pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec'
|
|
74
|
+
pod 'boost', :podspec => '../node_modules/react-native/third-party-podspecs/boost.podspec'
|
|
75
|
+
pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'`;
|
|
76
|
+
export const CIO_PODFILE_TARGET_NAMES_SNIPPET = `
|
|
77
|
+
cio_target_names = [
|
|
78
|
+
'CustomerIOTracking',
|
|
79
|
+
'CustomerIOCommon',
|
|
80
|
+
'CustomerIOMessagingPushAPN',
|
|
81
|
+
'CustomerIOMessagingPush'
|
|
82
|
+
]`;
|
|
83
|
+
export const CIO_PODFILE_POST_INSTALL_SNIPPET = `
|
|
84
|
+
installer.pods_project.targets.each do |target|
|
|
85
|
+
if cio_target_names.include? target.name
|
|
86
|
+
puts "Modifying target #{target.name}"
|
|
87
|
+
|
|
88
|
+
target.build_configurations.each do |config|
|
|
89
|
+
puts "Setting build config settings for #{target.name}"
|
|
90
|
+
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end`;
|
|
94
|
+
export const CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = `
|
|
95
|
+
cio_target_names = [
|
|
96
|
+
'CustomerIOTracking',
|
|
97
|
+
'CustomerIOCommon',
|
|
98
|
+
'CustomerIOMessagingPushAPN',
|
|
99
|
+
'CustomerIOMessagingPush'
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
post_install do |installer|
|
|
103
|
+
|
|
104
|
+
installer.pods_project.targets.each do |target|
|
|
105
|
+
if cio_target_names.include? target.name
|
|
106
|
+
puts "Modifying target #{target.name}"
|
|
107
|
+
|
|
108
|
+
target.build_configurations.each do |config|
|
|
109
|
+
puts "Setting build config settings for #{target.name}"
|
|
110
|
+
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
react_native_post_install(installer)
|
|
115
|
+
__apply_Xcode_12_5_M1_post_install_workaround(installer)
|
|
116
|
+
end`;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleShortVersionString</key>
|
|
6
|
+
<string>{{BUNDLE_SHORT_VERSION}}</string>
|
|
7
|
+
<key>CFBundleVersion</key>
|
|
8
|
+
<string>{{BUNDLE_VERSION}}</string>
|
|
9
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
10
|
+
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
11
|
+
<key>CFBundleDisplayName</key>
|
|
12
|
+
<string>NotificationServiceExtension</string>
|
|
13
|
+
<key>CFBundleExecutable</key>
|
|
14
|
+
<string>$(EXECUTABLE_NAME)</string>
|
|
15
|
+
<key>CFBundleIdentifier</key>
|
|
16
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
17
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
18
|
+
<string>6.0</string>
|
|
19
|
+
<key>CFBundleName</key>
|
|
20
|
+
<string>$(PRODUCT_NAME)</string>
|
|
21
|
+
<key>CFBundlePackageType</key>
|
|
22
|
+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
|
23
|
+
<key>NSExtension</key>
|
|
24
|
+
<dict>
|
|
25
|
+
<key>NSExtensionPointIdentifier</key>
|
|
26
|
+
<string>com.apple.usernotifications.service</string>
|
|
27
|
+
<key>NSExtensionPrincipalClass</key>
|
|
28
|
+
<string>NotificationService</string>
|
|
29
|
+
</dict>
|
|
30
|
+
</dict>
|
|
31
|
+
</plist>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
#import "NotificationService.h"
|
|
3
|
+
#import "NotificationService-Swift.h"
|
|
4
|
+
|
|
5
|
+
@interface NotificationService ()
|
|
6
|
+
|
|
7
|
+
@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
|
|
8
|
+
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
|
|
9
|
+
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
@implementation NotificationService
|
|
13
|
+
|
|
14
|
+
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
|
|
15
|
+
NotificationServiceCioManager* cioManagerObj = [[NotificationServiceCioManager alloc] init];
|
|
16
|
+
[cioManagerObj didReceive:request withContentHandler:contentHandler];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
- (void)serviceExtensionTimeWillExpire {
|
|
20
|
+
// Called just before the extension will be terminated by the system.
|
|
21
|
+
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
|
|
22
|
+
NotificationServiceCioManager* cioManagerObj = [[NotificationServiceCioManager alloc] init];
|
|
23
|
+
[cioManagerObj serviceExtensionTimeWillExpire];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UserNotifications
|
|
3
|
+
import CioMessagingPush
|
|
4
|
+
|
|
5
|
+
@objc
|
|
6
|
+
public class NotificationServiceCioManager : NSObject {
|
|
7
|
+
|
|
8
|
+
public override init() {}
|
|
9
|
+
|
|
10
|
+
@objc(didReceive:withContentHandler:)
|
|
11
|
+
public func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
|
12
|
+
MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@objc(serviceExtensionTimeWillExpire)
|
|
16
|
+
public func serviceExtensionTimeWillExpire() {
|
|
17
|
+
MessagingPush.shared.serviceExtensionTimeWillExpire()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import CioMessagingPushAPN
|
|
3
|
+
import CioTracking
|
|
4
|
+
import UserNotifications
|
|
5
|
+
import UIKit
|
|
6
|
+
|
|
7
|
+
@objc
|
|
8
|
+
public class CIOAppPushNotificationsHandler : NSObject {
|
|
9
|
+
|
|
10
|
+
public override init() {}
|
|
11
|
+
|
|
12
|
+
@objc(registerPushNotification:)
|
|
13
|
+
public func registerPushNotification(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {
|
|
14
|
+
|
|
15
|
+
let center = UNUserNotificationCenter.current()
|
|
16
|
+
center.delegate = notificationDelegate
|
|
17
|
+
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
|
|
18
|
+
if error == nil{
|
|
19
|
+
DispatchQueue.main.async {
|
|
20
|
+
UIApplication.shared.registerForRemoteNotifications()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@objc(application:deviceToken:)
|
|
27
|
+
public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
28
|
+
MessagingPush.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@objc(application:error:)
|
|
32
|
+
public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
|
33
|
+
MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)
|
|
37
|
+
public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
|
38
|
+
let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
|
|
39
|
+
withCompletionHandler: completionHandler)
|
|
40
|
+
|
|
41
|
+
// If the Customer.io SDK does not handle the push, it's up to you to handle it and call the
|
|
42
|
+
// completion handler. If the SDK did handle it, it called the completion handler for you.
|
|
43
|
+
if !handled {
|
|
44
|
+
completionHandler()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function injectCodeByRegex(
|
|
2
|
+
fileContent: string,
|
|
3
|
+
lineRegex: RegExp,
|
|
4
|
+
snippet: string
|
|
5
|
+
) {
|
|
6
|
+
const lines = fileContent.split('\n');
|
|
7
|
+
const index = lines.findIndex((line) => lineRegex.test(line));
|
|
8
|
+
let content: string[] = lines;
|
|
9
|
+
|
|
10
|
+
if (index > -1) {
|
|
11
|
+
content = [...lines.slice(0, index), snippet, ...lines.slice(index)];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return content;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function injectCodeByMultiLineRegex(
|
|
18
|
+
fileContent: string,
|
|
19
|
+
lineRegex: RegExp,
|
|
20
|
+
snippet: string
|
|
21
|
+
) {
|
|
22
|
+
return fileContent.replace(lineRegex, `$&\n${snippet}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function injectCodeByMultiLineRegexAndReplaceLine(
|
|
26
|
+
fileContent: string,
|
|
27
|
+
lineRegex: RegExp,
|
|
28
|
+
snippet: string
|
|
29
|
+
) {
|
|
30
|
+
return fileContent.replace(lineRegex, `${snippet}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function injectCodeByLineNumber(
|
|
34
|
+
fileContent: string,
|
|
35
|
+
index: number,
|
|
36
|
+
snippet: string
|
|
37
|
+
) {
|
|
38
|
+
const lines = fileContent.split('\n');
|
|
39
|
+
let content: string[] = lines;
|
|
40
|
+
|
|
41
|
+
if (index > -1) {
|
|
42
|
+
content = [...lines.slice(0, index), snippet, ...lines.slice(index)];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return content;
|
|
46
|
+
}
|