customerio-expo-plugin 2.5.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -31
- package/plugin/app.plugin.js +1 -1
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +56 -15
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/commonjs/android/withCIOAndroid.js +7 -2
- package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +1 -1
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js +45 -0
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -0
- package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +1 -1
- package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
- package/plugin/lib/commonjs/android/withProjectStrings.js +14 -7
- package/plugin/lib/commonjs/android/withProjectStrings.js.map +1 -1
- package/plugin/lib/commonjs/helpers/constants/android.js +7 -1
- package/plugin/lib/commonjs/helpers/constants/android.js.map +1 -1
- package/plugin/lib/commonjs/helpers/constants/common.js +18 -0
- package/plugin/lib/commonjs/helpers/constants/common.js.map +1 -0
- package/plugin/lib/commonjs/helpers/constants/ios.js +7 -7
- package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
- package/plugin/lib/commonjs/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +2 -2
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +62 -0
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -0
- package/plugin/lib/commonjs/index.js +13 -2
- package/plugin/lib/commonjs/index.js.map +1 -1
- package/plugin/lib/commonjs/ios/utils.js +1 -1
- package/plugin/lib/commonjs/ios/utils.js.map +1 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +1 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js +17 -11
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js +133 -49
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +17 -19
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js +1 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/postInstallHelper.js.map +1 -1
- package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
- package/plugin/lib/commonjs/utils/android.js +109 -0
- package/plugin/lib/commonjs/utils/android.js.map +1 -0
- package/plugin/lib/commonjs/utils/config.js +43 -0
- package/plugin/lib/commonjs/utils/config.js.map +1 -0
- package/plugin/lib/commonjs/utils/plugin.js +49 -0
- package/plugin/lib/commonjs/utils/plugin.js.map +1 -0
- package/plugin/lib/commonjs/utils/validation.js +44 -0
- package/plugin/lib/commonjs/utils/validation.js.map +1 -0
- package/plugin/lib/commonjs/utils/xcode.js +67 -0
- package/plugin/lib/commonjs/utils/xcode.js.map +1 -0
- package/plugin/lib/module/android/withAndroidManifestUpdates.js +55 -14
- package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/module/android/withCIOAndroid.js +7 -2
- package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/module/android/withGoogleServicesJSON.js +1 -1
- package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/module/android/withMainApplicationModifications.js +38 -0
- package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -0
- package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
- package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
- package/plugin/lib/module/android/withProjectStrings.js +13 -6
- package/plugin/lib/module/android/withProjectStrings.js.map +1 -1
- package/plugin/lib/module/helpers/constants/android.js +6 -0
- package/plugin/lib/module/helpers/constants/android.js.map +1 -1
- package/plugin/lib/module/helpers/constants/common.js +12 -0
- package/plugin/lib/module/helpers/constants/common.js.map +1 -0
- package/plugin/lib/module/helpers/constants/ios.js +6 -6
- package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
- package/plugin/lib/module/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
- package/plugin/lib/module/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -2
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +57 -0
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -0
- package/plugin/lib/module/index.js +14 -2
- package/plugin/lib/module/index.js.map +1 -1
- package/plugin/lib/module/ios/utils.js +1 -2
- package/plugin/lib/module/ios/utils.js.map +1 -1
- package/plugin/lib/module/ios/withAppDelegateModifications.js +3 -3
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIos.js +17 -11
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIosSwift.js +134 -50
- package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +2 -2
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +18 -20
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/ios/withXcodeProject.js +1 -1
- package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/module/postInstallHelper.js.map +1 -1
- package/plugin/lib/module/types/cio-types.js.map +1 -1
- package/plugin/lib/module/utils/android.js +100 -0
- package/plugin/lib/module/utils/android.js.map +1 -0
- package/plugin/lib/module/utils/config.js +38 -0
- package/plugin/lib/module/utils/config.js.map +1 -0
- package/plugin/lib/module/utils/plugin.js +38 -0
- package/plugin/lib/module/utils/plugin.js.map +1 -0
- package/plugin/lib/module/utils/validation.js +39 -0
- package/plugin/lib/module/utils/validation.js.map +1 -0
- package/plugin/lib/module/utils/xcode.js +60 -0
- package/plugin/lib/module/utils/xcode.js.map +1 -0
- package/plugin/lib/typescript/android/withAndroidManifestUpdates.d.ts +1 -0
- package/plugin/lib/typescript/android/withCIOAndroid.d.ts +2 -2
- package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +3 -0
- package/plugin/lib/typescript/android/withProjectStrings.d.ts +2 -1
- package/plugin/lib/typescript/helpers/constants/android.d.ts +3 -0
- package/plugin/lib/typescript/helpers/constants/common.d.ts +11 -0
- package/plugin/lib/typescript/helpers/constants/ios.d.ts +3 -1
- package/plugin/lib/typescript/helpers/utils/patchPluginNativeCode.d.ts +7 -0
- package/plugin/lib/typescript/ios/utils.d.ts +2 -2
- package/plugin/lib/typescript/ios/withCIOIos.d.ts +2 -2
- package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +3 -3
- package/plugin/lib/typescript/types/cio-types.d.ts +46 -6
- package/plugin/lib/typescript/utils/android.d.ts +5 -0
- package/plugin/lib/typescript/utils/config.d.ts +8 -0
- package/plugin/lib/typescript/utils/plugin.d.ts +4 -0
- package/plugin/lib/typescript/utils/validation.d.ts +3 -0
- package/plugin/lib/typescript/utils/xcode.d.ts +28 -0
- package/plugin/src/android/withAndroidManifestUpdates.ts +70 -21
- package/plugin/src/android/withCIOAndroid.ts +8 -2
- package/plugin/src/android/withGoogleServicesJSON.ts +2 -2
- package/plugin/src/android/withMainApplicationModifications.ts +50 -0
- package/plugin/src/android/withNotificationChannelMetadata.ts +7 -3
- package/plugin/src/android/withProjectStrings.ts +20 -10
- package/plugin/src/helpers/constants/android.ts +7 -0
- package/plugin/src/helpers/constants/common.ts +12 -0
- package/plugin/src/helpers/constants/ios.ts +11 -13
- package/plugin/src/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
- package/plugin/src/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +8 -7
- package/plugin/src/helpers/utils/patchPluginNativeCode.ts +97 -0
- package/plugin/src/index.ts +18 -2
- package/plugin/src/ios/utils.ts +5 -5
- package/plugin/src/ios/withAppDelegateModifications.ts +11 -8
- package/plugin/src/ios/withCIOIos.ts +19 -11
- package/plugin/src/ios/withCIOIosSwift.ts +195 -73
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +7 -10
- package/plugin/src/ios/withNotificationsXcodeProject.ts +25 -26
- package/plugin/src/ios/withXcodeProject.ts +1 -1
- package/plugin/src/postInstallHelper.js +1 -1
- package/plugin/src/types/cio-types.ts +48 -8
- package/plugin/src/utils/android.ts +112 -0
- package/plugin/src/utils/config.ts +53 -0
- package/plugin/src/utils/plugin.ts +46 -0
- package/plugin/src/utils/validation.ts +54 -0
- package/plugin/src/utils/xcode.ts +74 -0
- package/plugin/lib/commonjs/helpers/constants/globals.d.js +0 -2
- package/plugin/lib/commonjs/helpers/constants/globals.d.js.map +0 -1
- package/plugin/lib/commonjs/helpers/utils/pluginUtils.js +0 -26
- package/plugin/lib/commonjs/helpers/utils/pluginUtils.js.map +0 -1
- package/plugin/lib/module/helpers/constants/globals.d.js +0 -2
- package/plugin/lib/module/helpers/constants/globals.d.js.map +0 -1
- package/plugin/lib/module/helpers/utils/pluginUtils.js +0 -19
- package/plugin/lib/module/helpers/utils/pluginUtils.js.map +0 -1
- package/plugin/lib/typescript/helpers/utils/pluginUtils.d.ts +0 -4
- package/plugin/src/helpers/constants/globals.d.ts +0 -8
- package/plugin/src/helpers/utils/pluginUtils.ts +0 -22
|
@@ -1,27 +1,68 @@
|
|
|
1
1
|
import { withAndroidManifest } from '@expo/config-plugins';
|
|
2
|
-
|
|
2
|
+
// Default low priority for Firebase messaging service when setHighPriorityPushHandler is false
|
|
3
|
+
export const DEFAULT_LOW_PRIORITY = -10;
|
|
4
|
+
export const withAndroidManifestUpdates = (configOuter, options) => {
|
|
3
5
|
return withAndroidManifest(configOuter, props => {
|
|
4
6
|
const application = props.modResults.manifest.application;
|
|
5
7
|
const customerIOMessagingpush = 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
|
|
6
|
-
if (!application[0]
|
|
7
|
-
application[0]
|
|
8
|
+
if (!application[0].service) {
|
|
9
|
+
application[0].service = [];
|
|
8
10
|
}
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
|
|
11
|
+
const existingServiceIndex = application[0].service.findIndex(service => service.$['android:name'] === customerIOMessagingpush);
|
|
12
|
+
if (existingServiceIndex === -1) {
|
|
13
|
+
// Intent filter structure for Firebase messaging service
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const intentFilter = {
|
|
16
|
+
action: [{
|
|
17
|
+
$: {
|
|
18
|
+
'android:name': 'com.google.firebase.MESSAGING_EVENT'
|
|
19
|
+
}
|
|
20
|
+
}]
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Handle priority based on setHighPriorityPushHandler value
|
|
24
|
+
if (options.setHighPriorityPushHandler === true) {
|
|
25
|
+
// High priority - no priority attribute means default high priority
|
|
26
|
+
console.log('Successfully set CustomerIO push handler as high priority in AndroidManifest.xml');
|
|
27
|
+
} else if (options.setHighPriorityPushHandler === false) {
|
|
28
|
+
// Low priority - set fixed priority
|
|
29
|
+
intentFilter.$ = {
|
|
30
|
+
'android:priority': DEFAULT_LOW_PRIORITY.toString()
|
|
31
|
+
};
|
|
32
|
+
console.log(`Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
|
|
33
|
+
}
|
|
34
|
+
application[0].service.push({
|
|
12
35
|
'$': {
|
|
13
36
|
'android:name': customerIOMessagingpush,
|
|
14
37
|
'android:exported': 'false'
|
|
15
38
|
},
|
|
16
|
-
'intent-filter': [
|
|
17
|
-
action: [{
|
|
18
|
-
$: {
|
|
19
|
-
'android:name': 'com.google.firebase.MESSAGING_EVENT'
|
|
20
|
-
}
|
|
21
|
-
}]
|
|
22
|
-
}]
|
|
39
|
+
'intent-filter': [intentFilter]
|
|
23
40
|
});
|
|
24
|
-
|
|
41
|
+
} else if (options.setHighPriorityPushHandler === true) {
|
|
42
|
+
// Service exists, need to ensure it becomes high priority (remove priority attribute)
|
|
43
|
+
const existingService = application[0].service[existingServiceIndex];
|
|
44
|
+
if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
const intentFilter = existingService['intent-filter'][0];
|
|
47
|
+
if (intentFilter.$ && intentFilter.$['android:priority']) {
|
|
48
|
+
delete intentFilter.$['android:priority'];
|
|
49
|
+
console.log('Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} else if (options.setHighPriorityPushHandler === false) {
|
|
53
|
+
// Service exists, update to low priority
|
|
54
|
+
const existingService = application[0].service[existingServiceIndex];
|
|
55
|
+
|
|
56
|
+
// Update existing service intent-filter with fixed priority
|
|
57
|
+
if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
const intentFilter = existingService['intent-filter'][0];
|
|
60
|
+
if (!intentFilter.$) {
|
|
61
|
+
intentFilter.$ = {};
|
|
62
|
+
}
|
|
63
|
+
intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();
|
|
64
|
+
console.log(`Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`);
|
|
65
|
+
}
|
|
25
66
|
}
|
|
26
67
|
props.modResults.manifest.application = application;
|
|
27
68
|
return props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAndroidManifest","withAndroidManifestUpdates","configOuter","props","application","modResults","manifest","customerIOMessagingpush","
|
|
1
|
+
{"version":3,"names":["withAndroidManifest","DEFAULT_LOW_PRIORITY","withAndroidManifestUpdates","configOuter","options","props","application","modResults","manifest","customerIOMessagingpush","service","existingServiceIndex","findIndex","$","intentFilter","action","setHighPriorityPushHandler","console","log","toString","push","existingService","length"],"sources":["withAndroidManifestUpdates.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\n// Default low priority for Firebase messaging service when setHighPriorityPushHandler is false\nexport const DEFAULT_LOW_PRIORITY = -10;\n\n\nexport const withAndroidManifestUpdates: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, options) => {\n return withAndroidManifest(configOuter, (props) => {\n const application = props.modResults.manifest\n .application as ManifestApplication[];\n const customerIOMessagingpush =\n 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';\n\n if (!application[0].service) {\n application[0].service = [];\n }\n\n const existingServiceIndex = application[0].service.findIndex(\n (service) => service.$['android:name'] === customerIOMessagingpush\n );\n\n if (existingServiceIndex === -1) {\n // Intent filter structure for Firebase messaging service\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter: any = {\n action: [\n {\n $: {\n 'android:name': 'com.google.firebase.MESSAGING_EVENT',\n },\n },\n ],\n };\n\n // Handle priority based on setHighPriorityPushHandler value\n if (options.setHighPriorityPushHandler === true) {\n // High priority - no priority attribute means default high priority\n console.log(\n 'Successfully set CustomerIO push handler as high priority in AndroidManifest.xml'\n );\n } else if (options.setHighPriorityPushHandler === false) {\n // Low priority - set fixed priority\n intentFilter.$ = {\n 'android:priority': DEFAULT_LOW_PRIORITY.toString(),\n };\n console.log(\n `Successfully set CustomerIO push handler as low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n\n application[0].service.push({\n '$': {\n 'android:name': customerIOMessagingpush,\n 'android:exported': 'false',\n },\n 'intent-filter': [intentFilter],\n });\n } else if (options.setHighPriorityPushHandler === true) {\n // Service exists, need to ensure it becomes high priority (remove priority attribute)\n const existingService = application[0].service[existingServiceIndex];\n\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (intentFilter.$ && intentFilter.$['android:priority']) {\n delete intentFilter.$['android:priority'];\n console.log(\n 'Successfully updated existing CustomerIO push handler to high priority in AndroidManifest.xml'\n );\n }\n }\n } else if (options.setHighPriorityPushHandler === false) {\n // Service exists, update to low priority\n const existingService = application[0].service[existingServiceIndex];\n\n // Update existing service intent-filter with fixed priority\n if (existingService['intent-filter'] && existingService['intent-filter'].length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const intentFilter = existingService['intent-filter'][0] as any;\n if (!intentFilter.$) {\n intentFilter.$ = {};\n }\n intentFilter.$['android:priority'] = DEFAULT_LOW_PRIORITY.toString();\n console.log(\n `Successfully updated existing CustomerIO push handler to low priority (${DEFAULT_LOW_PRIORITY}) in AndroidManifest.xml`\n );\n }\n }\n\n props.modResults.manifest.application = application;\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAK1D;AACA,OAAO,MAAMC,oBAAoB,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@ import { withAndroidManifestUpdates } from './withAndroidManifestUpdates';
|
|
|
2
2
|
import { withAppGoogleServices } from './withAppGoogleServices';
|
|
3
3
|
import { withGistMavenRepository } from './withGistMavenRepository';
|
|
4
4
|
import { withGoogleServicesJSON } from './withGoogleServicesJSON';
|
|
5
|
+
import { withMainApplicationModifications } from './withMainApplicationModifications';
|
|
5
6
|
import { withNotificationChannelMetadata } from './withNotificationChannelMetadata';
|
|
6
7
|
import { withProjectGoogleServices } from './withProjectGoogleServices';
|
|
7
8
|
import { withProjectStrings } from './withProjectStrings';
|
|
8
|
-
export function withCIOAndroid(config, props) {
|
|
9
|
+
export function withCIOAndroid(config, sdkConfig, props) {
|
|
9
10
|
var _props$pushNotificati;
|
|
10
11
|
config = withGistMavenRepository(config, props);
|
|
11
12
|
config = withProjectGoogleServices(config, props);
|
|
12
13
|
config = withAppGoogleServices(config, props);
|
|
13
14
|
config = withGoogleServicesJSON(config, props);
|
|
14
15
|
config = withProjectStrings(config);
|
|
15
|
-
if (props.setHighPriorityPushHandler) {
|
|
16
|
+
if (props.setHighPriorityPushHandler !== undefined) {
|
|
16
17
|
config = withAndroidManifestUpdates(config, props);
|
|
17
18
|
}
|
|
18
19
|
if ((_props$pushNotificati = props.pushNotification) !== null && _props$pushNotificati !== void 0 && _props$pushNotificati.channel) {
|
|
19
20
|
config = withNotificationChannelMetadata(config, props);
|
|
20
21
|
}
|
|
22
|
+
// Add auto initialization if sdkConfig is provided
|
|
23
|
+
if (sdkConfig) {
|
|
24
|
+
config = withMainApplicationModifications(config, sdkConfig);
|
|
25
|
+
}
|
|
21
26
|
return config;
|
|
22
27
|
}
|
|
23
28
|
//# sourceMappingURL=withCIOAndroid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAndroidManifestUpdates","withAppGoogleServices","withGistMavenRepository","withGoogleServicesJSON","withNotificationChannelMetadata","withProjectGoogleServices","withProjectStrings","withCIOAndroid","config","props","_props$pushNotificati","setHighPriorityPushHandler","pushNotification","channel"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { withAndroidManifestUpdates } from './withAndroidManifestUpdates';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGistMavenRepository } from './withGistMavenRepository';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withNotificationChannelMetadata } from './withNotificationChannelMetadata';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\nimport { withProjectStrings } from './withProjectStrings';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsAndroid\n): ExpoConfig {\n config = withGistMavenRepository(config, props);\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n config = withProjectStrings(config);\n if (props.setHighPriorityPushHandler) {\n config = withAndroidManifestUpdates(config, props);\n }\n if (props.pushNotification?.channel) {\n config = withNotificationChannelMetadata(config, props);\n }\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,kBAAkB,QAAQ,sBAAsB;AAEzD,OAAO,SAASC,cAAcA,CAC5BC,MAAkB,EAClBC,KAAqC,EACzB;EAAA,IAAAC,qBAAA;
|
|
1
|
+
{"version":3,"names":["withAndroidManifestUpdates","withAppGoogleServices","withGistMavenRepository","withGoogleServicesJSON","withMainApplicationModifications","withNotificationChannelMetadata","withProjectGoogleServices","withProjectStrings","withCIOAndroid","config","sdkConfig","props","_props$pushNotificati","setHighPriorityPushHandler","undefined","pushNotification","channel"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsAndroid, NativeSDKConfig } from '../types/cio-types';\nimport { withAndroidManifestUpdates } from './withAndroidManifestUpdates';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGistMavenRepository } from './withGistMavenRepository';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withMainApplicationModifications } from './withMainApplicationModifications';\nimport { withNotificationChannelMetadata } from './withNotificationChannelMetadata';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\nimport { withProjectStrings } from './withProjectStrings';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n sdkConfig: NativeSDKConfig | undefined,\n props: CustomerIOPluginOptionsAndroid\n): ExpoConfig {\n config = withGistMavenRepository(config, props);\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n config = withProjectStrings(config);\n if (props.setHighPriorityPushHandler !== undefined) {\n config = withAndroidManifestUpdates(config, props);\n }\n if (props.pushNotification?.channel) {\n config = withNotificationChannelMetadata(config, props);\n }\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n config = withMainApplicationModifications(config, sdkConfig);\n }\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,gCAAgC,QAAQ,oCAAoC;AACrF,SAASC,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,kBAAkB,QAAQ,sBAAsB;AAEzD,OAAO,SAASC,cAAcA,CAC5BC,MAAkB,EAClBC,SAAsC,EACtCC,KAAqC,EACzB;EAAA,IAAAC,qBAAA;EACZH,MAAM,GAAGP,uBAAuB,CAACO,MAAM,EAAEE,KAAK,CAAC;EAC/CF,MAAM,GAAGH,yBAAyB,CAACG,MAAM,EAAEE,KAAK,CAAC;EACjDF,MAAM,GAAGR,qBAAqB,CAACQ,MAAM,EAAEE,KAAK,CAAC;EAC7CF,MAAM,GAAGN,sBAAsB,CAACM,MAAM,EAAEE,KAAK,CAAC;EAC9CF,MAAM,GAAGF,kBAAkB,CAACE,MAAM,CAAC;EACnC,IAAIE,KAAK,CAACE,0BAA0B,KAAKC,SAAS,EAAE;IAClDL,MAAM,GAAGT,0BAA0B,CAACS,MAAM,EAAEE,KAAK,CAAC;EACpD;EACA,KAAAC,qBAAA,GAAID,KAAK,CAACI,gBAAgB,cAAAH,qBAAA,eAAtBA,qBAAA,CAAwBI,OAAO,EAAE;IACnCP,MAAM,GAAGJ,+BAA+B,CAACI,MAAM,EAAEE,KAAK,CAAC;EACzD;EACA;EACA,IAAID,SAAS,EAAE;IACbD,MAAM,GAAGL,gCAAgC,CAACK,MAAM,EAAEC,SAAS,CAAC;EAC9D;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@ export const withGoogleServicesJSON = (configOuter, cioProps) => {
|
|
|
14
14
|
if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
|
|
15
15
|
try {
|
|
16
16
|
FileManagement.copyFile(googleServicesFile, `${androidPath}/app/google-services.json`);
|
|
17
|
-
} catch
|
|
17
|
+
} catch {
|
|
18
18
|
console.log(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`);
|
|
19
19
|
}
|
|
20
20
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withProjectBuildGradle","FileManagement","withGoogleServicesJSON","configOuter","cioProps","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","exists","copyFile","
|
|
1
|
+
{"version":3,"names":["withProjectBuildGradle","FileManagement","withGoogleServicesJSON","configOuter","cioProps","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","exists","copyFile","console","log"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } 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 googleServicesFile: cioProps?.googleServicesFile,\n };\n const { androidPath, googleServicesFile } = options;\n if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${androidPath}/app/google-services.json`\n );\n } catch {\n console.log(\n `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n console.log(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`\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":"AACA,SAASA,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,cAAc,QAAQ,mCAAmC;AAGlE,OAAO,MAAMC,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAOJ,sBAAsB,CAACG,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEN,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACL,cAAc,CAACU,MAAM,CAAC,GAAGJ,WAAW,2BAA2B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIT,cAAc,CAACU,MAAM,CAACD,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFT,cAAc,CAACW,QAAQ,CACrBF,kBAAkB,EAClB,GAAGH,WAAW,2BAChB,CAAC;QACH,CAAC,CAAC,MAAM;UACNM,OAAO,CAACC,GAAG,CACT,4FAA4FP,WAAW,2BACzG,CAAC;QACH;MACF,CAAC,MAAM;QACLM,OAAO,CAACC,GAAG,CACT,wCAAwCJ,kBAAkB,yDAAyDH,WAAW,2BAChI,CAAC;MACH;IACF,CAAC,MAAM;MACLM,OAAO,CAACC,GAAG,CACT,wBAAwBP,WAAW,wCACrC,CAAC;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { withMainApplication } from '@expo/config-plugins';
|
|
2
|
+
import { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';
|
|
3
|
+
import { PLATFORM } from '../helpers/constants/common';
|
|
4
|
+
import { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';
|
|
5
|
+
import { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';
|
|
6
|
+
export const withMainApplicationModifications = (configOuter, sdkConfig) => {
|
|
7
|
+
return withMainApplication(configOuter, async config => {
|
|
8
|
+
const content = setupCustomerIOSDKInitializer(config, sdkConfig);
|
|
9
|
+
config.modResults.contents = content;
|
|
10
|
+
return config;
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Setup CustomerIOSDKInitializer for Android auto initialization
|
|
16
|
+
*/
|
|
17
|
+
const setupCustomerIOSDKInitializer = (config, sdkConfig) => {
|
|
18
|
+
const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
|
|
19
|
+
const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
|
|
20
|
+
const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
|
|
21
|
+
const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
|
|
22
|
+
let content = config.modResults.contents;
|
|
23
|
+
try {
|
|
24
|
+
// Always regenerate the CustomerIOSDKInitializer file to reflect config changes
|
|
25
|
+
copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig));
|
|
26
|
+
// Add import if not already present
|
|
27
|
+
content = addImportToFile(content, SDK_INITIALIZER_IMPORT);
|
|
28
|
+
// Add initialization code to onCreate if not already present
|
|
29
|
+
if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {
|
|
30
|
+
content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);
|
|
34
|
+
return config.modResults.contents;
|
|
35
|
+
}
|
|
36
|
+
return content;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=withMainApplicationModifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withMainApplication","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","PLATFORM","patchNativeSDKInitializer","addCodeToMethod","addImportToFile","copyTemplateFile","withMainApplicationModifications","configOuter","sdkConfig","config","content","setupCustomerIOSDKInitializer","modResults","contents","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","ANDROID","includes","error","console","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type { NativeSDKConfig } from '../types/cio-types';\nimport { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';\n\nexport const withMainApplicationModifications: ConfigPlugin<NativeSDKConfig> = (configOuter, sdkConfig) => {\n return withMainApplication(configOuter, async (config) => {\n const content = setupCustomerIOSDKInitializer(config, sdkConfig);\n config.modResults.contents = content;\n return config;\n });\n};\n\n/**\n * Setup CustomerIOSDKInitializer for Android auto initialization\n */\nconst setupCustomerIOSDKInitializer = (\n config: ExportedConfigWithProps<ApplicationProjectFile>,\n sdkConfig: NativeSDKConfig,\n): string => {\n const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';\n const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';\n\n const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;\n const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;\n\n let content = config.modResults.contents;\n\n try {\n // Always regenerate the CustomerIOSDKInitializer file to reflect config changes\n copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>\n patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig)\n );\n // Add import if not already present\n content = addImportToFile(content, SDK_INITIALIZER_IMPORT);\n // Add initialization code to onCreate if not already present\n if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);\n }\n } catch (error) {\n console.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);\n return config.modResults.contents;\n }\n\n return content;\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAE1D,SAASC,kCAAkC,EAAEC,8BAA8B,EAAEC,iCAAiC,QAAQ,8BAA8B;AACpJ,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SAASC,yBAAyB,QAAQ,wCAAwC;AAElF,SAASC,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,QAAQ,kBAAkB;AAErF,OAAO,MAAMC,gCAA+D,GAAGA,CAACC,WAAW,EAAEC,SAAS,KAAK;EACzG,OAAOX,mBAAmB,CAACU,WAAW,EAAE,MAAOE,MAAM,IAAK;IACxD,MAAMC,OAAO,GAAGC,6BAA6B,CAACF,MAAM,EAAED,SAAS,CAAC;IAChEC,MAAM,CAACG,UAAU,CAACC,QAAQ,GAAGH,OAAO;IACpC,OAAOD,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA,MAAME,6BAA6B,GAAGA,CACpCF,MAAuD,EACvDD,SAA0B,KACf;EACX,MAAMM,qBAAqB,GAAG,0BAA0B;EACxD,MAAMC,uBAAuB,GAAG,sBAAsB;EAEtD,MAAMC,oBAAoB,GAAG,GAAGF,qBAAqB,KAAK;EAC1D,MAAMG,sBAAsB,GAAG,UAAUF,uBAAuB,IAAID,qBAAqB,EAAE;EAE3F,IAAIJ,OAAO,GAAGD,MAAM,CAACG,UAAU,CAACC,QAAQ;EAExC,IAAI;IACF;IACAR,gBAAgB,CAACI,MAAM,EAAEO,oBAAoB,EAAED,uBAAuB,EAAGL,OAAO,IAC9ER,yBAAyB,CAACQ,OAAO,EAAET,QAAQ,CAACiB,OAAO,EAAEV,SAAS,CAChE,CAAC;IACD;IACAE,OAAO,GAAGN,eAAe,CAACM,OAAO,EAAEO,sBAAsB,CAAC;IAC1D;IACA,IAAI,CAACP,OAAO,CAACS,QAAQ,CAACpB,8BAA8B,CAAC,EAAE;MACrDW,OAAO,GAAGP,eAAe,CAACO,OAAO,EAAEZ,kCAAkC,EAAEE,iCAAiC,CAAC;IAC3G;EACF,CAAC,CAAC,OAAOoB,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,mBAAmBR,qBAAqB,GAAG,EAAEM,KAAK,CAAC;IAChE,OAAOX,MAAM,CAACG,UAAU,CAACC,QAAQ;EACnC;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -9,7 +9,7 @@ const addMetadataIfNotExists = (application, name, value) => {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
// Check if metadata already exists
|
|
12
|
-
const hasMetadata = application['meta-data'].some(metadata => metadata['
|
|
12
|
+
const hasMetadata = application['meta-data'].some(metadata => metadata.$['android:name'] === name);
|
|
13
13
|
|
|
14
14
|
// Add metadata if it doesn't exist
|
|
15
15
|
if (!hasMetadata) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAndroidManifest","addMetadataIfNotExists","application","name","value","hasMetadata","some","metadata","
|
|
1
|
+
{"version":3,"names":["withAndroidManifest","addMetadataIfNotExists","application","name","value","hasMetadata","some","metadata","$","push","withNotificationChannelMetadata","config","props","manifestProps","_props$pushNotificati","modResults","manifest","channel","pushNotification","id","importance","undefined","String"],"sources":["withNotificationChannelMetadata.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\n/**\n * Adds a metadata entry to the Android manifest if it doesn't already exist\n */\nconst addMetadataIfNotExists = (\n application: ManifestApplication,\n name: string,\n value: string\n): void => {\n // Initialize meta-data array if it doesn't exist\n if (!application['meta-data']) {\n application['meta-data'] = [];\n }\n\n // Check if metadata already exists\n const hasMetadata = application['meta-data'].some(\n (metadata) => metadata.$['android:name'] === name\n );\n\n // Add metadata if it doesn't exist\n if (!hasMetadata) {\n application['meta-data'].push({\n $: {\n 'android:name': name,\n 'android:value': value,\n },\n });\n }\n};\n\nexport const withNotificationChannelMetadata: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (config, props) => {\n return withAndroidManifest(config, (manifestProps) => {\n const application = manifestProps.modResults.manifest\n .application as ManifestApplication[];\n const channel = props.pushNotification?.channel;\n\n // Only proceed if channel configuration exists\n if (\n channel &&\n (channel.id || channel.name || channel.importance !== undefined)\n ) {\n if (channel.id) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_id',\n channel.id\n );\n }\n\n if (channel.name) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_name',\n channel.name\n );\n }\n\n if (channel.importance !== undefined) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_importance',\n String(channel.importance)\n );\n }\n }\n\n manifestProps.modResults.manifest.application = application;\n return manifestProps;\n });\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAK1D;AACA;AACA;AACA,MAAMC,sBAAsB,GAAGA,CAC7BC,WAAgC,EAChCC,IAAY,EACZC,KAAa,KACJ;EACT;EACA,IAAI,CAACF,WAAW,CAAC,WAAW,CAAC,EAAE;IAC7BA,WAAW,CAAC,WAAW,CAAC,GAAG,EAAE;EAC/B;;EAEA;EACA,MAAMG,WAAW,GAAGH,WAAW,CAAC,WAAW,CAAC,CAACI,IAAI,CAC9CC,QAAQ,IAAKA,QAAQ,CAACC,CAAC,CAAC,cAAc,CAAC,KAAKL,IAC/C,CAAC;;EAED;EACA,IAAI,CAACE,WAAW,EAAE;IAChBH,WAAW,CAAC,WAAW,CAAC,CAACO,IAAI,CAAC;MAC5BD,CAAC,EAAE;QACD,cAAc,EAAEL,IAAI;QACpB,eAAe,EAAEC;MACnB;IACF,CAAC,CAAC;EACJ;AACF,CAAC;AAED,OAAO,MAAMM,+BAEZ,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EACrB,OAAOZ,mBAAmB,CAACW,MAAM,EAAGE,aAAa,IAAK;IAAA,IAAAC,qBAAA;IACpD,MAAMZ,WAAW,GAAGW,aAAa,CAACE,UAAU,CAACC,QAAQ,CAClDd,WAAoC;IACvC,MAAMe,OAAO,IAAAH,qBAAA,GAAGF,KAAK,CAACM,gBAAgB,cAAAJ,qBAAA,uBAAtBA,qBAAA,CAAwBG,OAAO;;IAE/C;IACA,IACEA,OAAO,KACNA,OAAO,CAACE,EAAE,IAAIF,OAAO,CAACd,IAAI,IAAIc,OAAO,CAACG,UAAU,KAAKC,SAAS,CAAC,EAChE;MACA,IAAIJ,OAAO,CAACE,EAAE,EAAE;QACdlB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,qCAAqC,EACrCe,OAAO,CAACE,EACV,CAAC;MACH;MAEA,IAAIF,OAAO,CAACd,IAAI,EAAE;QAChBF,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,uCAAuC,EACvCe,OAAO,CAACd,IACV,CAAC;MACH;MAEA,IAAIc,OAAO,CAACG,UAAU,KAAKC,SAAS,EAAE;QACpCpB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,6CAA6C,EAC7CoB,MAAM,CAACL,OAAO,CAACG,UAAU,CAC3B,CAAC;MACH;IACF;IAEAP,aAAa,CAACE,UAAU,CAACC,QAAQ,CAACd,WAAW,GAAGA,WAAW;IAC3D,OAAOW,aAAa;EACtB,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { withStringsXml } from '@expo/config-plugins';
|
|
2
|
-
import { getPluginVersion } from '../
|
|
2
|
+
import { getPluginVersion } from '../utils/plugin';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Adds or updates string resources in Android's strings.xml required by the plugin
|
|
6
6
|
*/
|
|
7
|
-
export const withProjectStrings =
|
|
8
|
-
return withStringsXml(
|
|
7
|
+
export const withProjectStrings = configOuter => {
|
|
8
|
+
return withStringsXml(configOuter, config => {
|
|
9
9
|
const stringsXml = config.modResults;
|
|
10
10
|
const pluginVersion = getPluginVersion();
|
|
11
11
|
|
|
@@ -38,20 +38,27 @@ export function addStringsToXml(stringsXml, stringResources) {
|
|
|
38
38
|
string: []
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
+
// Ensure the string array exists
|
|
42
|
+
if (!stringsXml.resources.string) {
|
|
43
|
+
stringsXml.resources.string = [];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Get a reference to the string array after ensuring it exists
|
|
47
|
+
const stringArray = stringsXml.resources.string;
|
|
41
48
|
stringResources.forEach(({
|
|
42
49
|
name,
|
|
43
50
|
value
|
|
44
51
|
}) => {
|
|
45
|
-
const existingStringIndex =
|
|
52
|
+
const existingStringIndex = stringArray.findIndex(item => {
|
|
46
53
|
var _item$$;
|
|
47
54
|
return ((_item$$ = item.$) === null || _item$$ === void 0 ? void 0 : _item$$.name) === name;
|
|
48
55
|
});
|
|
49
56
|
if (existingStringIndex !== -1) {
|
|
50
57
|
// Update the existing string
|
|
51
|
-
|
|
58
|
+
stringArray[existingStringIndex]._ = value;
|
|
52
59
|
} else {
|
|
53
60
|
// Add a new string resource
|
|
54
|
-
|
|
61
|
+
stringArray.push({
|
|
55
62
|
$: {
|
|
56
63
|
name
|
|
57
64
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withStringsXml","getPluginVersion","withProjectStrings","config","stringsXml","modResults","pluginVersion","addStringsToXml","name","value","stringResources","resources","string","forEach","existingStringIndex","findIndex","item","_item$$","$","_","push"],"sources":["withProjectStrings.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withStringsXml } from '@expo/config-plugins';\nimport { getPluginVersion } from '../
|
|
1
|
+
{"version":3,"names":["withStringsXml","getPluginVersion","withProjectStrings","configOuter","config","stringsXml","modResults","pluginVersion","addStringsToXml","name","value","stringResources","resources","string","stringArray","forEach","existingStringIndex","findIndex","item","_item$$","$","_","push"],"sources":["withProjectStrings.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withStringsXml } from '@expo/config-plugins';\nimport type { ResourceXML } from '@expo/config-plugins/build/android/Resources';\nimport { getPluginVersion } from '../utils/plugin';\n\n/**\n * Adds or updates string resources in Android's strings.xml required by the plugin\n */\nexport const withProjectStrings: ConfigPlugin = (configOuter) => {\n return withStringsXml(configOuter, (config) => {\n const stringsXml = config.modResults;\n const pluginVersion = getPluginVersion();\n\n // Updating meta-data in AndroidManifest.xml fails on Manifest merging, so we're updating\n // the strings here instead\n // These strings are added to the strings.xml file by Customer.io's React Native SDK\n // We're updating them here to include the Expo client source and version so user agent\n // can be generated correctly for Expo apps\n addStringsToXml(stringsXml, [\n { name: 'customer_io_react_native_sdk_client_source', value: 'Expo' },\n {\n name: 'customer_io_react_native_sdk_client_version',\n value: pluginVersion,\n },\n ]);\n\n return config;\n });\n};\n\n/**\n * Adds or updates multiple string resources in Android's strings.xml\n * @param stringsXml - Parsed strings.xml object\n * @param stringResources - Array of string resources to add or update\n * @returns Updated strings.xml object\n */\nexport function addStringsToXml(\n stringsXml: ResourceXML,\n stringResources: { name: string; value: string }[]\n) {\n // Ensure the resource exists\n if (!stringsXml.resources) {\n stringsXml.resources = { string: [] };\n }\n // Ensure the string array exists\n if (!stringsXml.resources.string) {\n stringsXml.resources.string = [];\n }\n\n // Get a reference to the string array after ensuring it exists\n const stringArray = stringsXml.resources.string;\n stringResources.forEach(({ name, value }) => {\n const existingStringIndex = stringArray.findIndex(\n (item) => item.$?.name === name\n );\n\n if (existingStringIndex !== -1) {\n // Update the existing string\n stringArray[existingStringIndex]._ = value;\n } else {\n // Add a new string resource\n stringArray.push({\n $: { name },\n _: value,\n });\n }\n });\n}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AAE;MAC9B;MACAF,WAAW,CAACE,mBAAmB,CAAC,CAACK,CAAC,GAAGX,KAAK;IAC5C,CAAC,MAAM;MACL;MACAI,WAAW,CAACQ,IAAI,CAAC;QACfF,CAAC,EAAE;UAAEX;QAAK,CAAC;QACXY,CAAC,EAAEX;MACL,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -5,4 +5,10 @@ export const CIO_PROJECT_ALLPROJECTS_REGEX = /(allprojects\s*\{(.|\n){1,500}repo
|
|
|
5
5
|
export const CIO_PROJECT_GIST_MAVEN_SNIPPET = ' maven { url "https://maven.gist.build" }';
|
|
6
6
|
export const CIO_APP_GOOGLE_SNIPPET = 'apply plugin: "com.google.gms.google-services" // Google Services plugin';
|
|
7
7
|
export const CIO_PROJECT_GOOGLE_SNIPPET = ' classpath "com.google.gms:google-services:4.3.13" // Google Services plugin';
|
|
8
|
+
export const CIO_MAINAPPLICATION_ONCREATE_REGEX = /override\s+fun\s+onCreate\s*\(\s*\)\s*\{[\s\S]*?\}/;
|
|
9
|
+
// Actual method call, also used to detect if Customer.io auto initialization is already present
|
|
10
|
+
export const CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize(this)';
|
|
11
|
+
// Complete code snippet to inject into MainActivity.onCreate()
|
|
12
|
+
export const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK
|
|
13
|
+
${CIO_NATIVE_SDK_INITIALIZE_CALL}`;
|
|
8
14
|
//# sourceMappingURL=android.js.map
|
|
@@ -1 +1 @@
|
|
|
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){1,500}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":"AAAA,OAAO,MAAMA,8BAA8B,GACzC,4CAA4C;AAC9C,OAAO,MAAMC,mBAAmB,GAAG,2CAA2C;AAC9E,OAAO,MAAMC,oBAAoB,GAC/B,4CAA4C;AAC9C,OAAO,MAAMC,6BAA6B,GACxC,kDAAkD;AAEpD,OAAO,MAAMC,8BAA8B,GACzC,kDAAkD;AACpD,OAAO,MAAMC,sBAAsB,GACjC,2EAA2E;AAC7E,OAAO,MAAMC,0BAA0B,GACrC,sFAAsF","ignoreList":[]}
|
|
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","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_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){1,500}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\nexport const CIO_MAINAPPLICATION_ONCREATE_REGEX = /override\\s+fun\\s+onCreate\\s*\\(\\s*\\)\\s*\\{[\\s\\S]*?\\}/;\n// Actual method call, also used to detect if Customer.io auto initialization is already present\nexport const CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize(this)';\n// Complete code snippet to inject into MainActivity.onCreate()\nexport const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK\n ${CIO_NATIVE_SDK_INITIALIZE_CALL}`;\n"],"mappings":"AAAA,OAAO,MAAMA,8BAA8B,GACzC,4CAA4C;AAC9C,OAAO,MAAMC,mBAAmB,GAAG,2CAA2C;AAC9E,OAAO,MAAMC,oBAAoB,GAC/B,4CAA4C;AAC9C,OAAO,MAAMC,6BAA6B,GACxC,kDAAkD;AAEpD,OAAO,MAAMC,8BAA8B,GACzC,kDAAkD;AACpD,OAAO,MAAMC,sBAAsB,GACjC,2EAA2E;AAC7E,OAAO,MAAMC,0BAA0B,GACrC,sFAAsF;AAExF,OAAO,MAAMC,kCAAkC,GAAG,oDAAoD;AACtG;AACA,OAAO,MAAMC,8BAA8B,GAAG,2CAA2C;AACzF;AACA,OAAO,MAAMC,iCAAiC,GAAG;AACjD,MAAMD,8BAA8B,EAAE","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PLATFORM","IOS","ANDROID"],"sources":["common.ts"],"sourcesContent":["/**\n * Platform constants for native SDK initialization\n */\nexport const PLATFORM = {\n IOS: 'ios',\n ANDROID: 'android',\n} as const;\n\n/**\n * Platform type definition\n */\nexport type Platform = typeof PLATFORM[keyof typeof PLATFORM];\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAG;EACtBC,GAAG,EAAE,KAAK;EACVC,OAAO,EAAE;AACX,CAAU;;AAEV;AACA;AACA","ignoreList":[]}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
const finder = require('find-package-json');
|
|
2
1
|
const path = require('path');
|
|
3
2
|
const resolveFrom = require('resolve-from');
|
|
4
|
-
const f = finder(__dirname);
|
|
5
|
-
let pluginPackageRoot = f.next().filename;
|
|
6
|
-
// This is the path to the root of the customerio-expo-plugin package
|
|
7
|
-
pluginPackageRoot = path.dirname(pluginPackageRoot);
|
|
8
|
-
export const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(pluginPackageRoot, 'plugin/src/helpers/native-files/ios');
|
|
9
3
|
export function getRelativePathToRNSDK(iosPath) {
|
|
10
4
|
// Root path of the Expo project
|
|
11
5
|
const rootAppPath = path.dirname(iosPath);
|
|
@@ -135,4 +129,10 @@ export const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = `
|
|
|
135
129
|
}
|
|
136
130
|
}`;
|
|
137
131
|
export const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = /\{\{REGISTER_SNIPPET\}\}/;
|
|
132
|
+
// Regex to match MessagingPush initialization in AppDelegate (different from NSE initialization)
|
|
133
|
+
export const CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX = /(MessagingPush(?:APN|FCM)\.initialize)/;
|
|
134
|
+
export const CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize()';
|
|
135
|
+
export const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK
|
|
136
|
+
${CIO_NATIVE_SDK_INITIALIZE_CALL}
|
|
137
|
+
`;
|
|
138
138
|
//# sourceMappingURL=ios.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["finder","require","path","resolveFrom","f","__dirname","pluginPackageRoot","next","filename","dirname","LOCAL_PATH_TO_CIO_NSE_FILES","join","getRelativePathToRNSDK","iosPath","rootAppPath","pluginPackageJsonPath","silent","relative","IOS_DEPLOYMENT_TARGET","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DEEPLINK_COMMENT_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_INITIALIZECIOSDK_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER"],"sources":["ios.ts"],"sourcesContent":["const finder = require('find-package-json');\nconst path = require('path');\nconst resolveFrom = require('resolve-from');\n\nconst f = finder(__dirname);\nlet pluginPackageRoot = f.next().filename;\n// This is the path to the root of the customerio-expo-plugin package\npluginPackageRoot = path.dirname(pluginPackageRoot);\n\nexport const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(\n pluginPackageRoot,\n 'plugin/src/helpers/native-files/ios'\n);\n\nexport function getRelativePathToRNSDK(iosPath: string) {\n // Root path of the Expo project\n const rootAppPath = path.dirname(iosPath);\n\n // Path of the cio RN package.json file. Example: test-app/node_modules/customerio-reactnative/package.json\n const pluginPackageJsonPath = resolveFrom.silent(rootAppPath, `customerio-reactnative/package.json`);\n\n // Example: ../node_modules/customerio-reactnative\n return path.relative(iosPath, path.dirname(pluginPackageJsonPath));\n}\n\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\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_DIDFINISHLAUNCHINGMETHOD_REGEX =\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\\s*:\\s*EXAppDelegateWrapper\\s*)(<([^>]+)>)?/;\n\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*RCTBridge\\s*\\*\\s*\\w+\\s*=\\s*\\[\\s*self\\.reactDelegate\\s+createBridgeWithDelegate:self\\s+launchOptions:launchOptions\\s*\\];\\s*$/gm;\n\nexport const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*return\\s\\[\\s*super\\s*application:\\s*application\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\];/gm;\n\nexport const CIO_DEEPLINK_COMMENT_REGEX =\n /\\sDeep link workaround for app killed state start/gm;\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';\n\nexport const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;\nexport const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET =\n 'UNUserNotificationCenterDelegate';\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n`;\n\nexport const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n`;\n\nexport const CIO_INITIALIZECIOSDK_SNIPPET = ` \n [pnHandlerObj initializeCioSdk];\n\n// Code to make the CIO SDK compatible with expo-notifications package.\n// \n// The CIO SDK and expo-notifications both need to handle when a push gets clicked. However, iOS only allows one click handler to be set per app.\n// To get around this limitation, we set the CIO SDK as the click handler. The CIO SDK sets itself up so that when another SDK or host iOS app \n// sets itself as the click handler, the CIO SDK will still be able to handle when the push gets clicked, even though it's not the designated \n// click handler in iOS at runtime. \n// \n// This should work for most SDKs. However, expo-notifications is unique in it's implementation. It will not setup push click handling it if detects \n// that another SDK or host iOS app has already set itself as the click handler:\n// https://github.com/expo/expo/blob/1b29637bec0b9888e8bc8c310476293a3e2d9786/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L31-L37\n// ...to get around this, we must manually set it as the click handler after the CIO SDK. That's what this code block does.\n//\n// Note: Initialize the native iOS SDK and setup SDK push click handling before running this code. \n# if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n // Creating a new instance, as the comments in expo-notifications suggests, does not work. With this code, if you send a CIO push to device and click on it,\n // no push metrics reporting will occur.\n // EXNotificationCenterDelegate *notificationCenterDelegate = [[EXNotificationCenterDelegate alloc] init];\n\n // ...instead, get the singleton reference from Expo. \n id<UNUserNotificationCenterDelegate> notificationCenterDelegate = (id<UNUserNotificationCenterDelegate>) [EXModuleRegistryProvider getSingletonModuleForClass:[EXNotificationCenterDelegate class]];\n UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];\n center.delegate = notificationCenterDelegate;\n# endif\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `\n// Deep link workaround for app killed state start\nNSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];\n if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {\n NSDictionary *pushContent = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];\n if (pushContent[@\"CIO\"] && pushContent[@\"CIO\"][@\"push\"] && pushContent[@\"CIO\"][@\"push\"][@\"link\"]) {\n NSString *initialURL = pushContent[@\"CIO\"][@\"push\"][@\"link\"];\n if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {\n modifiedLaunchOptions[UIApplicationLaunchOptionsURLKey] = [NSURL URLWithString:initialURL];\n }\n }\n }\n//Deep link workaround for app killed state ends\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = `\n // Deep link workaround for app killed state start\n var modifiedLaunchOptions = launchOptions\n if let launchOptions = launchOptions,\n let pushContent = launchOptions[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable: Any],\n let cio = pushContent[\"CIO\"] as? [String: Any],\n let push = cio[\"push\"] as? [String: Any],\n let link = push[\"link\"] as? String,\n !launchOptions.keys.contains(UIApplication.LaunchOptionsKey.url) {\n \n var mutableLaunchOptions = launchOptions\n mutableLaunchOptions[UIApplication.LaunchOptionsKey.url] = URL(string: link)\n modifiedLaunchOptions = mutableLaunchOptions\n }\n // Deep link workaround for app killed state ends\n`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `\n@objc(registerPushNotification)\n public func registerPushNotification() {\n\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = `\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = /\\{\\{REGISTER_SNIPPET\\}\\}/;"],"mappings":"AAAA,MAAMA,MAAM,GAAGC,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAMC,IAAI,GAAGD,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAME,WAAW,GAAGF,OAAO,CAAC,cAAc,CAAC;AAE3C,MAAMG,CAAC,GAAGJ,MAAM,CAACK,SAAS,CAAC;AAC3B,IAAIC,iBAAiB,GAAGF,CAAC,CAACG,IAAI,CAAC,CAAC,CAACC,QAAQ;AACzC;AACAF,iBAAiB,GAAGJ,IAAI,CAACO,OAAO,CAACH,iBAAiB,CAAC;AAEnD,OAAO,MAAMI,2BAA2B,GAAGR,IAAI,CAACS,IAAI,CAClDL,iBAAiB,EACjB,qCACF,CAAC;AAED,OAAO,SAASM,sBAAsBA,CAACC,OAAe,EAAE;EACtD;EACA,MAAMC,WAAW,GAAGZ,IAAI,CAACO,OAAO,CAACI,OAAO,CAAC;;EAEzC;EACA,MAAME,qBAAqB,GAAGZ,WAAW,CAAC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AAMC,2CAA2C,GAAG;AAC3D;AACA;AACA,CAAC;AAED,OAAO,MAAMC,4BAA4B,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,yCAAyC,GAAG;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,+CAA+C,GAAG;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,qCAAqC,GAAG;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AAEJ,OAAO,MAAMC,wCAAwC,GAAG;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AAEN,OAAO,MAAMC,0CAA0C,GAAG,0BAA0B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["path","require","resolveFrom","getRelativePathToRNSDK","iosPath","rootAppPath","dirname","pluginPackageJsonPath","silent","relative","IOS_DEPLOYMENT_TARGET","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DEEPLINK_COMMENT_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_INITIALIZECIOSDK_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["const path = require('path');\nconst resolveFrom = require('resolve-from');\n\nexport function getRelativePathToRNSDK(iosPath: string) {\n // Root path of the Expo project\n const rootAppPath = path.dirname(iosPath);\n\n // Path of the cio RN package.json file. Example: test-app/node_modules/customerio-reactnative/package.json\n const pluginPackageJsonPath = resolveFrom.silent(\n rootAppPath,\n `customerio-reactnative/package.json`\n );\n\n // Example: ../node_modules/customerio-reactnative\n return path.relative(iosPath, path.dirname(pluginPackageJsonPath));\n}\n\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\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_DIDFINISHLAUNCHINGMETHOD_REGEX =\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\\s*:\\s*EXAppDelegateWrapper\\s*)(<([^>]+)>)?/;\n\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*RCTBridge\\s*\\*\\s*\\w+\\s*=\\s*\\[\\s*self\\.reactDelegate\\s+createBridgeWithDelegate:self\\s+launchOptions:launchOptions\\s*\\];\\s*$/gm;\n\nexport const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*return\\s\\[\\s*super\\s*application:\\s*application\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\];/gm;\n\nexport const CIO_DEEPLINK_COMMENT_REGEX =\n /\\sDeep link workaround for app killed state start/gm;\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';\n\nexport const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;\nexport const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET =\n 'UNUserNotificationCenterDelegate';\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n`;\n\nexport const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n`;\n\nexport const CIO_INITIALIZECIOSDK_SNIPPET = ` \n [pnHandlerObj initializeCioSdk];\n\n// Code to make the CIO SDK compatible with expo-notifications package.\n// \n// The CIO SDK and expo-notifications both need to handle when a push gets clicked. However, iOS only allows one click handler to be set per app.\n// To get around this limitation, we set the CIO SDK as the click handler. The CIO SDK sets itself up so that when another SDK or host iOS app \n// sets itself as the click handler, the CIO SDK will still be able to handle when the push gets clicked, even though it's not the designated \n// click handler in iOS at runtime. \n// \n// This should work for most SDKs. However, expo-notifications is unique in it's implementation. It will not setup push click handling it if detects \n// that another SDK or host iOS app has already set itself as the click handler:\n// https://github.com/expo/expo/blob/1b29637bec0b9888e8bc8c310476293a3e2d9786/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L31-L37\n// ...to get around this, we must manually set it as the click handler after the CIO SDK. That's what this code block does.\n//\n// Note: Initialize the native iOS SDK and setup SDK push click handling before running this code. \n# if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n // Creating a new instance, as the comments in expo-notifications suggests, does not work. With this code, if you send a CIO push to device and click on it,\n // no push metrics reporting will occur.\n // EXNotificationCenterDelegate *notificationCenterDelegate = [[EXNotificationCenterDelegate alloc] init];\n\n // ...instead, get the singleton reference from Expo. \n id<UNUserNotificationCenterDelegate> notificationCenterDelegate = (id<UNUserNotificationCenterDelegate>) [EXModuleRegistryProvider getSingletonModuleForClass:[EXNotificationCenterDelegate class]];\n UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];\n center.delegate = notificationCenterDelegate;\n# endif\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `\n// Deep link workaround for app killed state start\nNSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];\n if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {\n NSDictionary *pushContent = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];\n if (pushContent[@\"CIO\"] && pushContent[@\"CIO\"][@\"push\"] && pushContent[@\"CIO\"][@\"push\"][@\"link\"]) {\n NSString *initialURL = pushContent[@\"CIO\"][@\"push\"][@\"link\"];\n if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {\n modifiedLaunchOptions[UIApplicationLaunchOptionsURLKey] = [NSURL URLWithString:initialURL];\n }\n }\n }\n//Deep link workaround for app killed state ends\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = `\n // Deep link workaround for app killed state start\n var modifiedLaunchOptions = launchOptions\n if let launchOptions = launchOptions,\n let pushContent = launchOptions[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable: Any],\n let cio = pushContent[\"CIO\"] as? [String: Any],\n let push = cio[\"push\"] as? [String: Any],\n let link = push[\"link\"] as? String,\n !launchOptions.keys.contains(UIApplication.LaunchOptionsKey.url) {\n \n var mutableLaunchOptions = launchOptions\n mutableLaunchOptions[UIApplication.LaunchOptionsKey.url] = URL(string: link)\n modifiedLaunchOptions = mutableLaunchOptions\n }\n // Deep link workaround for app killed state ends\n`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `\n@objc(registerPushNotification)\n public func registerPushNotification() {\n\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = `\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n// Regex to match MessagingPush initialization in AppDelegate (different from NSE initialization)\nexport const CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX = /(MessagingPush(?:APN|FCM)\\.initialize)/;\nexport const CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize()';\nexport const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK\n ${CIO_NATIVE_SDK_INITIALIZE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AAkC;AACpC,OAAO,MAAMC,8CAA8C,GAAG;AAC9D;AACA,CAAC;AACD,OAAO,MAAMC,8CAA8C,GAAG;AAC9D;AACA,CAAC;AAED,OAAO,MAAMC,yCAAyC,GAAG;AACzD,4FAA4F;AAE5F,OAAO,MAAMC,4DAA4D,GAAG;AAC5E;AACA;AACA,CAAC;AAED,OAAO,MAAMC,4DAA4D,GAAG;AAC5E;AACA;AACA,CAAC;AAED,OAAO,MAAMC,2CAA2C,GAAG;AAC3D;AACA;AACA,CAAC;AAED,OAAO,MAAMC,4BAA4B,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,yCAAyC,GAAG;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,+CAA+C,GAAG;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,qCAAqC,GAAG;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AAEJ,OAAO,MAAMC,wCAAwC,GAAG;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AAEN,OAAO,MAAMC,0CAA0C,GAAG,0BAA0B;AACpF;AACA,OAAO,MAAMC,0CAA0C,GAAG,wCAAwC;AAClG,OAAO,MAAMC,8BAA8B,GAAG,uCAAuC;AACrF,OAAO,MAAMC,iCAAiC,GAAG;AACjD,MAAMD,8BAA8B;AACpC,KAAK","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package io.customer.sdk.expo
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import io.customer.datapipelines.config.ScreenView
|
|
5
|
+
import io.customer.messaginginapp.MessagingInAppModuleConfig
|
|
6
|
+
import io.customer.messaginginapp.ModuleMessagingInApp
|
|
7
|
+
import io.customer.messagingpush.MessagingPushModuleConfig
|
|
8
|
+
import io.customer.messagingpush.ModuleMessagingPushFCM
|
|
9
|
+
import io.customer.reactnative.sdk.messaginginapp.ReactInAppEventListener
|
|
10
|
+
import io.customer.sdk.CustomerIOBuilder
|
|
11
|
+
import io.customer.sdk.core.util.CioLogLevel
|
|
12
|
+
import io.customer.sdk.data.model.Region
|
|
13
|
+
|
|
14
|
+
object CustomerIOSDKInitializer {
|
|
15
|
+
fun initialize(application: Application) = with(
|
|
16
|
+
CustomerIOBuilder(application, "{{CDP_API_KEY}}")
|
|
17
|
+
) {
|
|
18
|
+
val siteId: String? = {{SITE_ID}}
|
|
19
|
+
val migrationSiteId: String? = {{MIGRATION_SITE_ID}}
|
|
20
|
+
val region = Region.getRegion({{REGION}})
|
|
21
|
+
|
|
22
|
+
setIfDefined({{LOG_LEVEL}}, CustomerIOBuilder::logLevel) { CioLogLevel.getLogLevel(it) }
|
|
23
|
+
setIfDefined(region, CustomerIOBuilder::region)
|
|
24
|
+
setIfDefined({{AUTO_TRACK_DEVICE_ATTRIBUTES}}, CustomerIOBuilder::autoTrackDeviceAttributes)
|
|
25
|
+
setIfDefined({{TRACK_APPLICATION_LIFECYCLE_EVENTS}}, CustomerIOBuilder::trackApplicationLifecycleEvents)
|
|
26
|
+
setIfDefined({{SCREEN_VIEW_USE}}, CustomerIOBuilder::screenViewUse) { ScreenView.getScreenView(it) }
|
|
27
|
+
setIfDefined(migrationSiteId, CustomerIOBuilder::migrationSiteId)
|
|
28
|
+
|
|
29
|
+
// Add messaging modules if siteId is provided
|
|
30
|
+
if (!(siteId.isNullOrBlank())) {
|
|
31
|
+
addCustomerIOModule(
|
|
32
|
+
ModuleMessagingInApp(
|
|
33
|
+
MessagingInAppModuleConfig.Builder(siteId, region)
|
|
34
|
+
.setEventListener(ReactInAppEventListener())
|
|
35
|
+
.build()
|
|
36
|
+
)
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
addCustomerIOModule(
|
|
40
|
+
ModuleMessagingPushFCM(
|
|
41
|
+
MessagingPushModuleConfig.Builder().build()
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
build()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Apply a value after transforming it, only if both the original and transformed values are non-nil
|
|
50
|
+
private inline fun <R, T> CustomerIOBuilder.setIfDefined(
|
|
51
|
+
value: R?,
|
|
52
|
+
block: CustomerIOBuilder.(T) -> CustomerIOBuilder,
|
|
53
|
+
transform: (R) -> T,
|
|
54
|
+
): CustomerIOBuilder = value?.let { block(transform(it)) } ?: this
|
|
55
|
+
|
|
56
|
+
// Apply a value to a setter only if it's non-nil
|
|
57
|
+
private inline fun <T> CustomerIOBuilder.setIfDefined(
|
|
58
|
+
value: T?,
|
|
59
|
+
block: CustomerIOBuilder.(T) -> CustomerIOBuilder,
|
|
60
|
+
): CustomerIOBuilder = setIfDefined(
|
|
61
|
+
value = value,
|
|
62
|
+
block = block,
|
|
63
|
+
transform = { it },
|
|
64
|
+
)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import CioDataPipelines
|
|
2
|
+
import CioInternalCommon
|
|
3
|
+
import CioMessagingInApp
|
|
4
|
+
import customerio_reactnative
|
|
5
|
+
|
|
6
|
+
class CustomerIOSDKInitializer {
|
|
7
|
+
static func initialize() {
|
|
8
|
+
// Override SDK client info to include Expo metadata in user agent
|
|
9
|
+
let pluginVersion = "{{EXPO_PLUGIN_VERSION}}"
|
|
10
|
+
DIGraphShared.shared.override(
|
|
11
|
+
value: CustomerIOSdkClient(source: "Expo", sdkVersion: pluginVersion),
|
|
12
|
+
forType: SdkClient.self
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
let cdpApiKey = "{{CDP_API_KEY}}"
|
|
16
|
+
let siteId: String? = {{SITE_ID}}
|
|
17
|
+
let region = CioInternalCommon.Region.getRegion(from: {{REGION}})
|
|
18
|
+
|
|
19
|
+
let builder = SDKConfigBuilder(cdpApiKey: cdpApiKey)
|
|
20
|
+
setIfDefined(value: {{LOG_LEVEL}}, thenPassItTo: builder.logLevel, transformingBy: CioLogLevel.getLogLevel)
|
|
21
|
+
setIfDefined(value: region, thenPassItTo: builder.region)
|
|
22
|
+
setIfDefined(value: {{AUTO_TRACK_DEVICE_ATTRIBUTES}}, thenPassItTo: builder.autoTrackDeviceAttributes)
|
|
23
|
+
setIfDefined(value: {{TRACK_APPLICATION_LIFECYCLE_EVENTS}}, thenPassItTo: builder.trackApplicationLifecycleEvents)
|
|
24
|
+
setIfDefined(value: {{SCREEN_VIEW_USE}}, thenPassItTo: builder.screenViewUse) { ScreenView.getScreenView($0) }
|
|
25
|
+
setIfDefined(value: {{MIGRATION_SITE_ID}}, thenPassItTo: builder.migrationSiteId)
|
|
26
|
+
|
|
27
|
+
CustomerIO.initialize(withConfig: builder.build())
|
|
28
|
+
|
|
29
|
+
if let siteId = siteId {
|
|
30
|
+
let inAppConfig = MessagingInAppConfigBuilder(siteId: siteId, region: region).build()
|
|
31
|
+
MessagingInApp.initialize(withConfig: inAppConfig)
|
|
32
|
+
MessagingInApp.shared.setEventListener(ReactInAppEventListener.shared)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// Apply a value to a setter only if it's non-nil
|
|
37
|
+
private static func setIfDefined<Raw>(
|
|
38
|
+
value rawValue: Raw?,
|
|
39
|
+
thenPassItTo handler: (Raw) -> Any
|
|
40
|
+
) {
|
|
41
|
+
setIfDefined(value: rawValue, thenPassItTo: handler) { $0 }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// Apply a value after transforming it, only if both the original and transformed values are non-nil
|
|
45
|
+
private static func setIfDefined<Raw, Transformed>(
|
|
46
|
+
value rawValue: Raw?,
|
|
47
|
+
thenPassItTo handler: (Transformed) -> Any,
|
|
48
|
+
transformingBy transform: (Raw) -> Transformed?
|
|
49
|
+
) {
|
|
50
|
+
if let value = rawValue, let result = transform(value) {
|
|
51
|
+
_ = handler(result)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|