customerio-expo-plugin 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/package.json +13 -31
  2. package/plugin/app.plugin.js +1 -1
  3. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js +4 -4
  4. package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
  5. package/plugin/lib/commonjs/android/withCIOAndroid.js +6 -1
  6. package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
  7. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js +1 -1
  8. package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  9. package/plugin/lib/commonjs/android/withMainApplicationModifications.js +45 -0
  10. package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -0
  11. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js +1 -1
  12. package/plugin/lib/commonjs/android/withNotificationChannelMetadata.js.map +1 -1
  13. package/plugin/lib/commonjs/android/withProjectStrings.js +14 -7
  14. package/plugin/lib/commonjs/android/withProjectStrings.js.map +1 -1
  15. package/plugin/lib/commonjs/helpers/constants/android.js +7 -1
  16. package/plugin/lib/commonjs/helpers/constants/android.js.map +1 -1
  17. package/plugin/lib/commonjs/helpers/constants/common.js +18 -0
  18. package/plugin/lib/commonjs/helpers/constants/common.js.map +1 -0
  19. package/plugin/lib/commonjs/helpers/constants/ios.js +7 -7
  20. package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
  21. package/plugin/lib/commonjs/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
  22. package/plugin/lib/commonjs/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
  23. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +2 -2
  24. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  25. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +62 -0
  26. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -0
  27. package/plugin/lib/commonjs/index.js +13 -2
  28. package/plugin/lib/commonjs/index.js.map +1 -1
  29. package/plugin/lib/commonjs/ios/utils.js +1 -1
  30. package/plugin/lib/commonjs/ios/utils.js.map +1 -1
  31. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +1 -1
  32. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  33. package/plugin/lib/commonjs/ios/withCIOIos.js +17 -11
  34. package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
  35. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +133 -49
  36. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  37. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +1 -1
  38. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
  39. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +17 -19
  40. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  41. package/plugin/lib/commonjs/ios/withXcodeProject.js +1 -1
  42. package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
  43. package/plugin/lib/commonjs/postInstallHelper.js.map +1 -1
  44. package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
  45. package/plugin/lib/commonjs/utils/android.js +109 -0
  46. package/plugin/lib/commonjs/utils/android.js.map +1 -0
  47. package/plugin/lib/commonjs/utils/config.js +43 -0
  48. package/plugin/lib/commonjs/utils/config.js.map +1 -0
  49. package/plugin/lib/commonjs/utils/plugin.js +49 -0
  50. package/plugin/lib/commonjs/utils/plugin.js.map +1 -0
  51. package/plugin/lib/commonjs/utils/validation.js +44 -0
  52. package/plugin/lib/commonjs/utils/validation.js.map +1 -0
  53. package/plugin/lib/commonjs/utils/xcode.js +67 -0
  54. package/plugin/lib/commonjs/utils/xcode.js.map +1 -0
  55. package/plugin/lib/module/android/withAndroidManifestUpdates.js +4 -4
  56. package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
  57. package/plugin/lib/module/android/withCIOAndroid.js +6 -1
  58. package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
  59. package/plugin/lib/module/android/withGoogleServicesJSON.js +1 -1
  60. package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  61. package/plugin/lib/module/android/withMainApplicationModifications.js +38 -0
  62. package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -0
  63. package/plugin/lib/module/android/withNotificationChannelMetadata.js +1 -1
  64. package/plugin/lib/module/android/withNotificationChannelMetadata.js.map +1 -1
  65. package/plugin/lib/module/android/withProjectStrings.js +13 -6
  66. package/plugin/lib/module/android/withProjectStrings.js.map +1 -1
  67. package/plugin/lib/module/helpers/constants/android.js +6 -0
  68. package/plugin/lib/module/helpers/constants/android.js.map +1 -1
  69. package/plugin/lib/module/helpers/constants/common.js +12 -0
  70. package/plugin/lib/module/helpers/constants/common.js.map +1 -0
  71. package/plugin/lib/module/helpers/constants/ios.js +6 -6
  72. package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
  73. package/plugin/lib/module/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
  74. package/plugin/lib/module/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
  75. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -2
  76. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  77. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +57 -0
  78. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -0
  79. package/plugin/lib/module/index.js +14 -2
  80. package/plugin/lib/module/index.js.map +1 -1
  81. package/plugin/lib/module/ios/utils.js +1 -2
  82. package/plugin/lib/module/ios/utils.js.map +1 -1
  83. package/plugin/lib/module/ios/withAppDelegateModifications.js +3 -3
  84. package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  85. package/plugin/lib/module/ios/withCIOIos.js +17 -11
  86. package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
  87. package/plugin/lib/module/ios/withCIOIosSwift.js +134 -50
  88. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  89. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +2 -2
  90. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
  91. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +18 -20
  92. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  93. package/plugin/lib/module/ios/withXcodeProject.js +1 -1
  94. package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
  95. package/plugin/lib/module/postInstallHelper.js.map +1 -1
  96. package/plugin/lib/module/types/cio-types.js.map +1 -1
  97. package/plugin/lib/module/utils/android.js +100 -0
  98. package/plugin/lib/module/utils/android.js.map +1 -0
  99. package/plugin/lib/module/utils/config.js +38 -0
  100. package/plugin/lib/module/utils/config.js.map +1 -0
  101. package/plugin/lib/module/utils/plugin.js +38 -0
  102. package/plugin/lib/module/utils/plugin.js.map +1 -0
  103. package/plugin/lib/module/utils/validation.js +39 -0
  104. package/plugin/lib/module/utils/validation.js.map +1 -0
  105. package/plugin/lib/module/utils/xcode.js +60 -0
  106. package/plugin/lib/module/utils/xcode.js.map +1 -0
  107. package/plugin/lib/typescript/android/withCIOAndroid.d.ts +2 -2
  108. package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +3 -0
  109. package/plugin/lib/typescript/android/withProjectStrings.d.ts +2 -1
  110. package/plugin/lib/typescript/helpers/constants/android.d.ts +3 -0
  111. package/plugin/lib/typescript/helpers/constants/common.d.ts +11 -0
  112. package/plugin/lib/typescript/helpers/constants/ios.d.ts +3 -1
  113. package/plugin/lib/typescript/helpers/utils/patchPluginNativeCode.d.ts +7 -0
  114. package/plugin/lib/typescript/ios/utils.d.ts +2 -2
  115. package/plugin/lib/typescript/ios/withCIOIos.d.ts +2 -2
  116. package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +3 -3
  117. package/plugin/lib/typescript/types/cio-types.d.ts +46 -6
  118. package/plugin/lib/typescript/utils/android.d.ts +5 -0
  119. package/plugin/lib/typescript/utils/config.d.ts +8 -0
  120. package/plugin/lib/typescript/utils/plugin.d.ts +4 -0
  121. package/plugin/lib/typescript/utils/validation.d.ts +3 -0
  122. package/plugin/lib/typescript/utils/xcode.d.ts +28 -0
  123. package/plugin/src/android/withAndroidManifestUpdates.ts +5 -5
  124. package/plugin/src/android/withCIOAndroid.ts +7 -1
  125. package/plugin/src/android/withGoogleServicesJSON.ts +2 -2
  126. package/plugin/src/android/withMainApplicationModifications.ts +50 -0
  127. package/plugin/src/android/withNotificationChannelMetadata.ts +7 -3
  128. package/plugin/src/android/withProjectStrings.ts +20 -10
  129. package/plugin/src/helpers/constants/android.ts +7 -0
  130. package/plugin/src/helpers/constants/common.ts +12 -0
  131. package/plugin/src/helpers/constants/ios.ts +11 -13
  132. package/plugin/src/helpers/native-files/android/CustomerIOSDKInitializer.kt +64 -0
  133. package/plugin/src/helpers/native-files/ios/CustomerIOSDKInitializer.swift +54 -0
  134. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +8 -7
  135. package/plugin/src/helpers/utils/patchPluginNativeCode.ts +97 -0
  136. package/plugin/src/index.ts +18 -2
  137. package/plugin/src/ios/utils.ts +5 -5
  138. package/plugin/src/ios/withAppDelegateModifications.ts +11 -8
  139. package/plugin/src/ios/withCIOIos.ts +19 -11
  140. package/plugin/src/ios/withCIOIosSwift.ts +195 -73
  141. package/plugin/src/ios/withGoogleServicesJsonFile.ts +7 -10
  142. package/plugin/src/ios/withNotificationsXcodeProject.ts +25 -26
  143. package/plugin/src/ios/withXcodeProject.ts +1 -1
  144. package/plugin/src/postInstallHelper.js +1 -1
  145. package/plugin/src/types/cio-types.ts +48 -8
  146. package/plugin/src/utils/android.ts +112 -0
  147. package/plugin/src/utils/config.ts +53 -0
  148. package/plugin/src/utils/plugin.ts +46 -0
  149. package/plugin/src/utils/validation.ts +54 -0
  150. package/plugin/src/utils/xcode.ts +74 -0
  151. package/plugin/lib/commonjs/helpers/constants/globals.d.js +0 -2
  152. package/plugin/lib/commonjs/helpers/constants/globals.d.js.map +0 -1
  153. package/plugin/lib/commonjs/helpers/utils/pluginUtils.js +0 -26
  154. package/plugin/lib/commonjs/helpers/utils/pluginUtils.js.map +0 -1
  155. package/plugin/lib/module/helpers/constants/globals.d.js +0 -2
  156. package/plugin/lib/module/helpers/constants/globals.d.js.map +0 -1
  157. package/plugin/lib/module/helpers/utils/pluginUtils.js +0 -19
  158. package/plugin/lib/module/helpers/utils/pluginUtils.js.map +0 -1
  159. package/plugin/lib/typescript/helpers/utils/pluginUtils.d.ts +0 -4
  160. package/plugin/src/helpers/constants/globals.d.ts +0 -8
  161. package/plugin/src/helpers/utils/pluginUtils.ts +0 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customerio-expo-plugin",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "Expo config plugin for the Customer IO React Native SDK",
5
5
  "main": "plugin/lib/commonjs/index",
6
6
  "module": "plugin/lib/module/index",
@@ -22,7 +22,8 @@
22
22
  "build": "npm run clean && tsc",
23
23
  "clean": "rm -rf lib",
24
24
  "expo-module": "expo-module",
25
- "lint": "eslint . --fix",
25
+ "lint": "eslint plugin --config plugin/eslint.config.js",
26
+ "lint:fix": "npm run lint -- --fix",
26
27
  "typescript": "tsc --noEmit",
27
28
  "prepare": "npm run clean && bob build",
28
29
  "postinstall": "node plugin/src/postInstall.js",
@@ -36,7 +37,8 @@
36
37
  "test-plugin": "bash scripts/test-plugin.sh",
37
38
  "cleanAll": "bash scripts/clean-all.sh",
38
39
  "buildAll": "bash scripts/build-all.sh",
39
- "cleanAndBuildAll": "npm run cleanAll && npm run buildAll"
40
+ "cleanAndBuildAll": "npm run cleanAll && npm run buildAll",
41
+ "generate-api-docs": "bash scripts/generate-api-docs.sh"
40
42
  },
41
43
  "keywords": [
42
44
  "react-native",
@@ -53,26 +55,25 @@
53
55
  "registry": "https://registry.npmjs.org/"
54
56
  },
55
57
  "peerDependencies": {
56
- "customerio-reactnative": "4.5.0"
58
+ "customerio-reactnative": "4.7.0"
57
59
  },
58
60
  "devDependencies": {
61
+ "@eslint/js": "^9.33.0",
59
62
  "@expo/config-plugins": "^10.0.0",
60
63
  "@expo/config-types": "^53.0.0",
64
+ "@microsoft/api-extractor": "^7.52.9",
61
65
  "@types/jest": "^29.5.14",
62
- "@typescript-eslint/eslint-plugin": "^5.21.0",
63
- "@typescript-eslint/parser": "^5.21.0",
64
- "eslint": "^8.14.0",
65
- "eslint-config-prettier": "^8.5.0",
66
- "eslint-plugin-prettier": "^4.0.0",
66
+ "eslint": "^9.17.0",
67
67
  "expo-build-properties": "^0.14.6",
68
- "expo-module-scripts": "^3.0.2",
68
+ "expo-module-scripts": "^3.5.4",
69
69
  "gradle-to-js": "^2.0.1",
70
70
  "jest": "^29.2.1",
71
71
  "jest-environment-jsdom": "^29.7.0",
72
- "prettier": "^2.6.2",
72
+ "prettier": "^2.8.8",
73
73
  "react-native-builder-bob": "^0.18.3",
74
74
  "ts-jest": "^29.2.5",
75
- "typescript": "^5.8.3",
75
+ "typescript": "^5.9.2",
76
+ "typescript-eslint": "^8.39.0",
76
77
  "xcode": "^3.0.1"
77
78
  },
78
79
  "commitlint": {
@@ -80,25 +81,6 @@
80
81
  "@commitlint/config-conventional"
81
82
  ]
82
83
  },
83
- "eslintConfig": {
84
- "root": true,
85
- "extends": [
86
- "@react-native-community",
87
- "prettier"
88
- ],
89
- "rules": {
90
- "prettier/prettier": [
91
- "error",
92
- {
93
- "quoteProps": "consistent",
94
- "singleQuote": true,
95
- "tabWidth": 2,
96
- "trailingComma": "es5",
97
- "useTabs": false
98
- }
99
- ]
100
- }
101
- },
102
84
  "eslintIgnore": [
103
85
  "node_modules/",
104
86
  "plugin/lib/"
@@ -1 +1 @@
1
- module.exports = require("./lib/commonjs/index");
1
+ module.exports = require('./lib/commonjs/index');
@@ -9,12 +9,12 @@ const withAndroidManifestUpdates = configOuter => {
9
9
  return (0, _configPlugins.withAndroidManifest)(configOuter, props => {
10
10
  const application = props.modResults.manifest.application;
11
11
  const customerIOMessagingpush = 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
12
- if (!application[0]['service']) {
13
- application[0]['service'] = [];
12
+ if (!application[0].service) {
13
+ application[0].service = [];
14
14
  }
15
- const hasService = application[0]['service'].some(service => service['$']['android:name'] === customerIOMessagingpush);
15
+ const hasService = application[0].service.some(service => service.$['android:name'] === customerIOMessagingpush);
16
16
  if (!hasService) {
17
- application[0]['service'].push({
17
+ application[0].service.push({
18
18
  '$': {
19
19
  'android:name': customerIOMessagingpush,
20
20
  'android:exported': 'false'
@@ -1 +1 @@
1
- {"version":3,"names":["_configPlugins","require","withAndroidManifestUpdates","configOuter","withAndroidManifest","props","application","modResults","manifest","customerIOMessagingpush","hasService","some","service","push","action","$","console","log","exports"],"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\nexport const withAndroidManifestUpdates: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\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 hasService = application[0]['service'].some(\n (service) => service['$']['android:name'] === customerIOMessagingpush\n );\n\n if (!hasService) {\n application[0]['service'].push({\n '$': {\n 'android:name': customerIOMessagingpush,\n 'android:exported': 'false',\n },\n 'intent-filter': [\n {\n action: [\n {\n $: {\n 'android:name': 'com.google.firebase.MESSAGING_EVENT',\n },\n },\n ],\n },\n ],\n });\n console.log(\n 'Successfully set CustomerIO push handler as priority in AndroidManifest.xml'\n );\n }\n\n props.modResults.manifest.application = application;\n return props;\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAKO,MAAMC,0BAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,kCAAmB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACjD,MAAMC,WAAW,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,CAC1CF,WAAoC;IACvC,MAAMG,uBAAuB,GAC3B,8DAA8D;IAEhE,IAAI,CAACH,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;MAC9BA,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE;IAChC;IAEA,MAAMI,UAAU,GAAGJ,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAACK,IAAI,CAC9CC,OAAO,IAAKA,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,KAAKH,uBAChD,CAAC;IAED,IAAI,CAACC,UAAU,EAAE;MACfJ,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAACO,IAAI,CAAC;QAC7B,GAAG,EAAE;UACH,cAAc,EAAEJ,uBAAuB;UACvC,kBAAkB,EAAE;QACtB,CAAC;QACD,eAAe,EAAE,CACf;UACEK,MAAM,EAAE,CACN;YACEC,CAAC,EAAE;cACD,cAAc,EAAE;YAClB;UACF,CAAC;QAEL,CAAC;MAEL,CAAC,CAAC;MACFC,OAAO,CAACC,GAAG,CACT,6EACF,CAAC;IACH;IAEAZ,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACF,WAAW,GAAGA,WAAW;IACnD,OAAOD,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACa,OAAA,CAAAhB,0BAAA,GAAAA,0BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_configPlugins","require","withAndroidManifestUpdates","configOuter","withAndroidManifest","props","application","modResults","manifest","customerIOMessagingpush","service","hasService","some","$","push","action","console","log","exports"],"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\nexport const withAndroidManifestUpdates: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\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 hasService = application[0].service.some(\n (service) => service.$['android:name'] === customerIOMessagingpush\n );\n\n if (!hasService) {\n application[0].service.push({\n '$': {\n 'android:name': customerIOMessagingpush,\n 'android:exported': 'false',\n },\n 'intent-filter': [\n {\n action: [\n {\n $: {\n 'android:name': 'com.google.firebase.MESSAGING_EVENT',\n },\n },\n ],\n },\n ],\n });\n console.log(\n 'Successfully set CustomerIO push handler as priority in AndroidManifest.xml'\n );\n }\n\n props.modResults.manifest.application = application;\n return props;\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAKO,MAAMC,0BAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,kCAAmB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACjD,MAAMC,WAAW,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,CAC1CF,WAAoC;IACvC,MAAMG,uBAAuB,GAC3B,8DAA8D;IAEhE,IAAI,CAACH,WAAW,CAAC,CAAC,CAAC,CAACI,OAAO,EAAE;MAC3BJ,WAAW,CAAC,CAAC,CAAC,CAACI,OAAO,GAAG,EAAE;IAC7B;IAEA,MAAMC,UAAU,GAAGL,WAAW,CAAC,CAAC,CAAC,CAACI,OAAO,CAACE,IAAI,CAC3CF,OAAO,IAAKA,OAAO,CAACG,CAAC,CAAC,cAAc,CAAC,KAAKJ,uBAC7C,CAAC;IAED,IAAI,CAACE,UAAU,EAAE;MACfL,WAAW,CAAC,CAAC,CAAC,CAACI,OAAO,CAACI,IAAI,CAAC;QAC1B,GAAG,EAAE;UACH,cAAc,EAAEL,uBAAuB;UACvC,kBAAkB,EAAE;QACtB,CAAC;QACD,eAAe,EAAE,CACf;UACEM,MAAM,EAAE,CACN;YACEF,CAAC,EAAE;cACD,cAAc,EAAE;YAClB;UACF,CAAC;QAEL,CAAC;MAEL,CAAC,CAAC;MACFG,OAAO,CAACC,GAAG,CACT,6EACF,CAAC;IACH;IAEAZ,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACF,WAAW,GAAGA,WAAW;IACnD,OAAOD,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACa,OAAA,CAAAhB,0BAAA,GAAAA,0BAAA","ignoreList":[]}
@@ -8,10 +8,11 @@ var _withAndroidManifestUpdates = require("./withAndroidManifestUpdates");
8
8
  var _withAppGoogleServices = require("./withAppGoogleServices");
9
9
  var _withGistMavenRepository = require("./withGistMavenRepository");
10
10
  var _withGoogleServicesJSON = require("./withGoogleServicesJSON");
11
+ var _withMainApplicationModifications = require("./withMainApplicationModifications");
11
12
  var _withNotificationChannelMetadata = require("./withNotificationChannelMetadata");
12
13
  var _withProjectGoogleServices = require("./withProjectGoogleServices");
13
14
  var _withProjectStrings = require("./withProjectStrings");
14
- function withCIOAndroid(config, props) {
15
+ function withCIOAndroid(config, sdkConfig, props) {
15
16
  var _props$pushNotificati;
16
17
  config = (0, _withGistMavenRepository.withGistMavenRepository)(config, props);
17
18
  config = (0, _withProjectGoogleServices.withProjectGoogleServices)(config, props);
@@ -24,6 +25,10 @@ function withCIOAndroid(config, props) {
24
25
  if ((_props$pushNotificati = props.pushNotification) !== null && _props$pushNotificati !== void 0 && _props$pushNotificati.channel) {
25
26
  config = (0, _withNotificationChannelMetadata.withNotificationChannelMetadata)(config, props);
26
27
  }
28
+ // Add auto initialization if sdkConfig is provided
29
+ if (sdkConfig) {
30
+ config = (0, _withMainApplicationModifications.withMainApplicationModifications)(config, sdkConfig);
31
+ }
27
32
  return config;
28
33
  }
29
34
  //# sourceMappingURL=withCIOAndroid.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_withAndroidManifestUpdates","require","_withAppGoogleServices","_withGistMavenRepository","_withGoogleServicesJSON","_withNotificationChannelMetadata","_withProjectGoogleServices","_withProjectStrings","withCIOAndroid","config","props","_props$pushNotificati","withGistMavenRepository","withProjectGoogleServices","withAppGoogleServices","withGoogleServicesJSON","withProjectStrings","setHighPriorityPushHandler","withAndroidManifestUpdates","pushNotification","channel","withNotificationChannelMetadata"],"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,IAAAA,2BAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AACA,IAAAI,gCAAA,GAAAJ,OAAA;AACA,IAAAK,0BAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AAEO,SAASO,cAAcA,CAC5BC,MAAkB,EAClBC,KAAqC,EACzB;EAAA,IAAAC,qBAAA;EACZF,MAAM,GAAG,IAAAG,gDAAuB,EAACH,MAAM,EAAEC,KAAK,CAAC;EAC/CD,MAAM,GAAG,IAAAI,oDAAyB,EAACJ,MAAM,EAAEC,KAAK,CAAC;EACjDD,MAAM,GAAG,IAAAK,4CAAqB,EAACL,MAAM,EAAEC,KAAK,CAAC;EAC7CD,MAAM,GAAG,IAAAM,8CAAsB,EAACN,MAAM,EAAEC,KAAK,CAAC;EAC9CD,MAAM,GAAG,IAAAO,sCAAkB,EAACP,MAAM,CAAC;EACnC,IAAIC,KAAK,CAACO,0BAA0B,EAAE;IACpCR,MAAM,GAAG,IAAAS,sDAA0B,EAACT,MAAM,EAAEC,KAAK,CAAC;EACpD;EACA,KAAAC,qBAAA,GAAID,KAAK,CAACS,gBAAgB,cAAAR,qBAAA,eAAtBA,qBAAA,CAAwBS,OAAO,EAAE;IACnCX,MAAM,GAAG,IAAAY,gEAA+B,EAACZ,MAAM,EAAEC,KAAK,CAAC;EACzD;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"names":["_withAndroidManifestUpdates","require","_withAppGoogleServices","_withGistMavenRepository","_withGoogleServicesJSON","_withMainApplicationModifications","_withNotificationChannelMetadata","_withProjectGoogleServices","_withProjectStrings","withCIOAndroid","config","sdkConfig","props","_props$pushNotificati","withGistMavenRepository","withProjectGoogleServices","withAppGoogleServices","withGoogleServicesJSON","withProjectStrings","setHighPriorityPushHandler","withAndroidManifestUpdates","pushNotification","channel","withNotificationChannelMetadata","withMainApplicationModifications"],"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) {\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,IAAAA,2BAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AACA,IAAAI,iCAAA,GAAAJ,OAAA;AACA,IAAAK,gCAAA,GAAAL,OAAA;AACA,IAAAM,0BAAA,GAAAN,OAAA;AACA,IAAAO,mBAAA,GAAAP,OAAA;AAEO,SAASQ,cAAcA,CAC5BC,MAAkB,EAClBC,SAAsC,EACtCC,KAAqC,EACzB;EAAA,IAAAC,qBAAA;EACZH,MAAM,GAAG,IAAAI,gDAAuB,EAACJ,MAAM,EAAEE,KAAK,CAAC;EAC/CF,MAAM,GAAG,IAAAK,oDAAyB,EAACL,MAAM,EAAEE,KAAK,CAAC;EACjDF,MAAM,GAAG,IAAAM,4CAAqB,EAACN,MAAM,EAAEE,KAAK,CAAC;EAC7CF,MAAM,GAAG,IAAAO,8CAAsB,EAACP,MAAM,EAAEE,KAAK,CAAC;EAC9CF,MAAM,GAAG,IAAAQ,sCAAkB,EAACR,MAAM,CAAC;EACnC,IAAIE,KAAK,CAACO,0BAA0B,EAAE;IACpCT,MAAM,GAAG,IAAAU,sDAA0B,EAACV,MAAM,EAAEE,KAAK,CAAC;EACpD;EACA,KAAAC,qBAAA,GAAID,KAAK,CAACS,gBAAgB,cAAAR,qBAAA,eAAtBA,qBAAA,CAAwBS,OAAO,EAAE;IACnCZ,MAAM,GAAG,IAAAa,gEAA+B,EAACb,MAAM,EAAEE,KAAK,CAAC;EACzD;EACA;EACA,IAAID,SAAS,EAAE;IACbD,MAAM,GAAG,IAAAc,kEAAgC,EAACd,MAAM,EAAEC,SAAS,CAAC;EAC9D;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
@@ -20,7 +20,7 @@ const withGoogleServicesJSON = (configOuter, cioProps) => {
20
20
  if (googleServicesFile && _fileManagement.FileManagement.exists(googleServicesFile)) {
21
21
  try {
22
22
  _fileManagement.FileManagement.copyFile(googleServicesFile, `${androidPath}/app/google-services.json`);
23
- } catch (e) {
23
+ } catch {
24
24
  console.log(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`);
25
25
  }
26
26
  } else {
@@ -1 +1 @@
1
- {"version":3,"names":["_configPlugins","require","_fileManagement","withGoogleServicesJSON","configOuter","cioProps","withProjectBuildGradle","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","FileManagement","exists","copyFile","e","console","log","exports"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import { withProjectBuildGradle } from '@expo/config-plugins';\nimport type { ConfigPlugin } from '@expo/config-plugins';\n\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const options: CustomerIOPluginOptionsAndroid = {\n androidPath: props.modRequest.platformProjectRoot,\n 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 (e) {\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":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAGA,IAAAC,eAAA,GAAAD,OAAA;AAGO,MAAME,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAO,IAAAC,qCAAsB,EAACF,WAAW,EAAGG,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEP,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEO;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACK,8BAAc,CAACC,MAAM,CAAC,GAAGL,WAAW,2BAA2B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIC,8BAAc,CAACC,MAAM,CAACF,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFC,8BAAc,CAACE,QAAQ,CACrBH,kBAAkB,EAClB,GAAGH,WAAW,2BAChB,CAAC;QACH,CAAC,CAAC,OAAOO,CAAC,EAAE;UACVC,OAAO,CAACC,GAAG,CACT,4FAA4FT,WAAW,2BACzG,CAAC;QACH;MACF,CAAC,MAAM;QACLQ,OAAO,CAACC,GAAG,CACT,wCAAwCN,kBAAkB,yDAAyDH,WAAW,2BAChI,CAAC;MACH;IACF,CAAC,MAAM;MACLQ,OAAO,CAACC,GAAG,CACT,wBAAwBT,WAAW,wCACrC,CAAC;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACY,OAAA,CAAAhB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_configPlugins","require","_fileManagement","withGoogleServicesJSON","configOuter","cioProps","withProjectBuildGradle","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","FileManagement","exists","copyFile","console","log","exports"],"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,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAGO,MAAME,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAO,IAAAC,qCAAsB,EAACF,WAAW,EAAGG,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEP,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEO;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACK,8BAAc,CAACC,MAAM,CAAC,GAAGL,WAAW,2BAA2B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIC,8BAAc,CAACC,MAAM,CAACF,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFC,8BAAc,CAACE,QAAQ,CACrBH,kBAAkB,EAClB,GAAGH,WAAW,2BAChB,CAAC;QACH,CAAC,CAAC,MAAM;UACNO,OAAO,CAACC,GAAG,CACT,4FAA4FR,WAAW,2BACzG,CAAC;QACH;MACF,CAAC,MAAM;QACLO,OAAO,CAACC,GAAG,CACT,wCAAwCL,kBAAkB,yDAAyDH,WAAW,2BAChI,CAAC;MACH;IACF,CAAC,MAAM;MACLO,OAAO,CAACC,GAAG,CACT,wBAAwBR,WAAW,wCACrC,CAAC;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACW,OAAA,CAAAf,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withMainApplicationModifications = void 0;
7
+ var _configPlugins = require("@expo/config-plugins");
8
+ var _android = require("../helpers/constants/android");
9
+ var _common = require("../helpers/constants/common");
10
+ var _patchPluginNativeCode = require("../helpers/utils/patchPluginNativeCode");
11
+ var _android2 = require("../utils/android");
12
+ const withMainApplicationModifications = (configOuter, sdkConfig) => {
13
+ return (0, _configPlugins.withMainApplication)(configOuter, async config => {
14
+ const content = setupCustomerIOSDKInitializer(config, sdkConfig);
15
+ config.modResults.contents = content;
16
+ return config;
17
+ });
18
+ };
19
+
20
+ /**
21
+ * Setup CustomerIOSDKInitializer for Android auto initialization
22
+ */
23
+ exports.withMainApplicationModifications = withMainApplicationModifications;
24
+ const setupCustomerIOSDKInitializer = (config, sdkConfig) => {
25
+ const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
26
+ const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
27
+ const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
28
+ const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
29
+ let content = config.modResults.contents;
30
+ try {
31
+ // Always regenerate the CustomerIOSDKInitializer file to reflect config changes
32
+ (0, _android2.copyTemplateFile)(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => (0, _patchPluginNativeCode.patchNativeSDKInitializer)(content, _common.PLATFORM.ANDROID, sdkConfig));
33
+ // Add import if not already present
34
+ content = (0, _android2.addImportToFile)(content, SDK_INITIALIZER_IMPORT);
35
+ // Add initialization code to onCreate if not already present
36
+ if (!content.includes(_android.CIO_NATIVE_SDK_INITIALIZE_CALL)) {
37
+ content = (0, _android2.addCodeToMethod)(content, _android.CIO_MAINAPPLICATION_ONCREATE_REGEX, _android.CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
38
+ }
39
+ } catch (error) {
40
+ console.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);
41
+ return config.modResults.contents;
42
+ }
43
+ return content;
44
+ };
45
+ //# sourceMappingURL=withMainApplicationModifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_configPlugins","require","_android","_common","_patchPluginNativeCode","_android2","withMainApplicationModifications","configOuter","sdkConfig","withMainApplication","config","content","setupCustomerIOSDKInitializer","modResults","contents","exports","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","copyTemplateFile","patchNativeSDKInitializer","PLATFORM","ANDROID","addImportToFile","includes","CIO_NATIVE_SDK_INITIALIZE_CALL","addCodeToMethod","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","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,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AAEO,MAAMK,gCAA+D,GAAGA,CAACC,WAAW,EAAEC,SAAS,KAAK;EACzG,OAAO,IAAAC,kCAAmB,EAACF,WAAW,EAAE,MAAOG,MAAM,IAAK;IACxD,MAAMC,OAAO,GAAGC,6BAA6B,CAACF,MAAM,EAAEF,SAAS,CAAC;IAChEE,MAAM,CAACG,UAAU,CAACC,QAAQ,GAAGH,OAAO;IACpC,OAAOD,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AAFAK,OAAA,CAAAT,gCAAA,GAAAA,gCAAA;AAGA,MAAMM,6BAA6B,GAAGA,CACpCF,MAAuD,EACvDF,SAA0B,KACf;EACX,MAAMQ,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,IAAIL,OAAO,GAAGD,MAAM,CAACG,UAAU,CAACC,QAAQ;EAExC,IAAI;IACF;IACA,IAAAM,0BAAgB,EAACV,MAAM,EAAEQ,oBAAoB,EAAED,uBAAuB,EAAGN,OAAO,IAC9E,IAAAU,gDAAyB,EAACV,OAAO,EAAEW,gBAAQ,CAACC,OAAO,EAAEf,SAAS,CAChE,CAAC;IACD;IACAG,OAAO,GAAG,IAAAa,yBAAe,EAACb,OAAO,EAAEQ,sBAAsB,CAAC;IAC1D;IACA,IAAI,CAACR,OAAO,CAACc,QAAQ,CAACC,uCAA8B,CAAC,EAAE;MACrDf,OAAO,GAAG,IAAAgB,yBAAe,EAAChB,OAAO,EAAEiB,2CAAkC,EAAEC,0CAAiC,CAAC;IAC3G;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,mBAAmBhB,qBAAqB,GAAG,EAAEc,KAAK,CAAC;IAChE,OAAOpB,MAAM,CAACG,UAAU,CAACC,QAAQ;EACnC;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
@@ -15,7 +15,7 @@ const addMetadataIfNotExists = (application, name, value) => {
15
15
  }
16
16
 
17
17
  // Check if metadata already exists
18
- const hasMetadata = application['meta-data'].some(metadata => metadata['$']['android:name'] === name);
18
+ const hasMetadata = application['meta-data'].some(metadata => metadata.$['android:name'] === name);
19
19
 
20
20
  // Add metadata if it doesn't exist
21
21
  if (!hasMetadata) {
@@ -1 +1 @@
1
- {"version":3,"names":["_configPlugins","require","addMetadataIfNotExists","application","name","value","hasMetadata","some","metadata","push","$","withNotificationChannelMetadata","config","props","withAndroidManifest","manifestProps","_props$pushNotificati","modResults","manifest","channel","pushNotification","id","importance","undefined","String","exports"],"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.application as ManifestApplication[];\n const channel = props.pushNotification?.channel;\n\n // Only proceed if channel configuration exists\n if (channel && (channel.id || channel.name || channel.importance !== undefined)) {\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,IAAAA,cAAA,GAAAC,OAAA;AAKA;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,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,KAAKJ,IAClD,CAAC;;EAED;EACA,IAAI,CAACE,WAAW,EAAE;IAChBH,WAAW,CAAC,WAAW,CAAC,CAACM,IAAI,CAAC;MAC5BC,CAAC,EAAE;QACD,cAAc,EAAEN,IAAI;QACpB,eAAe,EAAEC;MACnB;IACF,CAAC,CAAC;EACJ;AACF,CAAC;AAEM,MAAMM,+BAEZ,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EACrB,OAAO,IAAAC,kCAAmB,EAACF,MAAM,EAAGG,aAAa,IAAK;IAAA,IAAAC,qBAAA;IACpD,MAAMb,WAAW,GAAGY,aAAa,CAACE,UAAU,CAACC,QAAQ,CAACf,WAAoC;IAC1F,MAAMgB,OAAO,IAAAH,qBAAA,GAAGH,KAAK,CAACO,gBAAgB,cAAAJ,qBAAA,uBAAtBA,qBAAA,CAAwBG,OAAO;;IAE/C;IACA,IAAIA,OAAO,KAAKA,OAAO,CAACE,EAAE,IAAIF,OAAO,CAACf,IAAI,IAAIe,OAAO,CAACG,UAAU,KAAKC,SAAS,CAAC,EAAE;MAC/E,IAAIJ,OAAO,CAACE,EAAE,EAAE;QACdnB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,qCAAqC,EACrCgB,OAAO,CAACE,EACV,CAAC;MACH;MAEA,IAAIF,OAAO,CAACf,IAAI,EAAE;QAChBF,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,uCAAuC,EACvCgB,OAAO,CAACf,IACV,CAAC;MACH;MAEA,IAAIe,OAAO,CAACG,UAAU,KAAKC,SAAS,EAAE;QACpCrB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,6CAA6C,EAC7CqB,MAAM,CAACL,OAAO,CAACG,UAAU,CAC3B,CAAC;MACH;IACF;IAEAP,aAAa,CAACE,UAAU,CAACC,QAAQ,CAACf,WAAW,GAAGA,WAAW;IAC3D,OAAOY,aAAa;EACtB,CAAC,CAAC;AACJ,CAAC;AAACU,OAAA,CAAAd,+BAAA,GAAAA,+BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_configPlugins","require","addMetadataIfNotExists","application","name","value","hasMetadata","some","metadata","$","push","withNotificationChannelMetadata","config","props","withAndroidManifest","manifestProps","_props$pushNotificati","modResults","manifest","channel","pushNotification","id","importance","undefined","String","exports"],"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,IAAAA,cAAA,GAAAC,OAAA;AAKA;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;AAEM,MAAMM,+BAEZ,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EACrB,OAAO,IAAAC,kCAAmB,EAACF,MAAM,EAAGG,aAAa,IAAK;IAAA,IAAAC,qBAAA;IACpD,MAAMb,WAAW,GAAGY,aAAa,CAACE,UAAU,CAACC,QAAQ,CAClDf,WAAoC;IACvC,MAAMgB,OAAO,IAAAH,qBAAA,GAAGH,KAAK,CAACO,gBAAgB,cAAAJ,qBAAA,uBAAtBA,qBAAA,CAAwBG,OAAO;;IAE/C;IACA,IACEA,OAAO,KACNA,OAAO,CAACE,EAAE,IAAIF,OAAO,CAACf,IAAI,IAAIe,OAAO,CAACG,UAAU,KAAKC,SAAS,CAAC,EAChE;MACA,IAAIJ,OAAO,CAACE,EAAE,EAAE;QACdnB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,qCAAqC,EACrCgB,OAAO,CAACE,EACV,CAAC;MACH;MAEA,IAAIF,OAAO,CAACf,IAAI,EAAE;QAChBF,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,uCAAuC,EACvCgB,OAAO,CAACf,IACV,CAAC;MACH;MAEA,IAAIe,OAAO,CAACG,UAAU,KAAKC,SAAS,EAAE;QACpCrB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,6CAA6C,EAC7CqB,MAAM,CAACL,OAAO,CAACG,UAAU,CAC3B,CAAC;MACH;IACF;IAEAP,aAAa,CAACE,UAAU,CAACC,QAAQ,CAACf,WAAW,GAAGA,WAAW;IAC3D,OAAOY,aAAa;EACtB,CAAC,CAAC;AACJ,CAAC;AAACU,OAAA,CAAAd,+BAAA,GAAAA,+BAAA","ignoreList":[]}
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.addStringsToXml = addStringsToXml;
7
7
  exports.withProjectStrings = void 0;
8
8
  var _configPlugins = require("@expo/config-plugins");
9
- var _pluginUtils = require("../helpers/utils/pluginUtils");
9
+ var _plugin = require("../utils/plugin");
10
10
  /**
11
11
  * Adds or updates string resources in Android's strings.xml required by the plugin
12
12
  */
13
- const withProjectStrings = config => {
14
- return (0, _configPlugins.withStringsXml)(config, config => {
13
+ const withProjectStrings = configOuter => {
14
+ return (0, _configPlugins.withStringsXml)(configOuter, config => {
15
15
  const stringsXml = config.modResults;
16
- const pluginVersion = (0, _pluginUtils.getPluginVersion)();
16
+ const pluginVersion = (0, _plugin.getPluginVersion)();
17
17
 
18
18
  // Updating meta-data in AndroidManifest.xml fails on Manifest merging, so we're updating
19
19
  // the strings here instead
@@ -45,20 +45,27 @@ function addStringsToXml(stringsXml, stringResources) {
45
45
  string: []
46
46
  };
47
47
  }
48
+ // Ensure the string array exists
49
+ if (!stringsXml.resources.string) {
50
+ stringsXml.resources.string = [];
51
+ }
52
+
53
+ // Get a reference to the string array after ensuring it exists
54
+ const stringArray = stringsXml.resources.string;
48
55
  stringResources.forEach(({
49
56
  name,
50
57
  value
51
58
  }) => {
52
- const existingStringIndex = stringsXml.resources.string.findIndex(item => {
59
+ const existingStringIndex = stringArray.findIndex(item => {
53
60
  var _item$$;
54
61
  return ((_item$$ = item.$) === null || _item$$ === void 0 ? void 0 : _item$$.name) === name;
55
62
  });
56
63
  if (existingStringIndex !== -1) {
57
64
  // Update the existing string
58
- stringsXml.resources.string[existingStringIndex]._ = value;
65
+ stringArray[existingStringIndex]._ = value;
59
66
  } else {
60
67
  // Add a new string resource
61
- stringsXml.resources.string.push({
68
+ stringArray.push({
62
69
  $: {
63
70
  name
64
71
  },
@@ -1 +1 @@
1
- {"version":3,"names":["_configPlugins","require","_pluginUtils","withProjectStrings","config","withStringsXml","stringsXml","modResults","pluginVersion","getPluginVersion","addStringsToXml","name","value","exports","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 '../helpers/utils/pluginUtils';\n\n/**\n * Adds or updates string resources in Android's strings.xml required by the plugin\n */\nexport const withProjectStrings: ConfigPlugin = (config) => {\n return withStringsXml(config, (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 { name: 'customer_io_react_native_sdk_client_version', value: pluginVersion },\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: any,\n stringResources: { name: string, value: string }[]\n) {\n // Ensure the resource exists\n if (!stringsXml.resources) {\n stringsXml.resources = { string: [] };\n }\n\n stringResources.forEach(({ name, value }) => {\n const existingStringIndex = stringsXml.resources.string.findIndex(\n (item: { $: { name: string } }) => item.$?.name === name\n );\n\n if (existingStringIndex !== -1) {\n // Update the existing string\n stringsXml.resources.string[existingStringIndex]._ = value;\n } else {\n // Add a new string resource\n stringsXml.resources.string.push({\n $: { name },\n _: value,\n });\n }\n });\n}\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACO,MAAME,kBAAgC,GAAIC,MAAM,IAAK;EAC1D,OAAO,IAAAC,6BAAc,EAACD,MAAM,EAAGA,MAAM,IAAK;IACxC,MAAME,UAAU,GAAGF,MAAM,CAACG,UAAU;IACpC,MAAMC,aAAa,GAAG,IAAAC,6BAAgB,EAAC,CAAC;;IAExC;IACA;IACA;IACA;IACA;IACAC,eAAe,CAACJ,UAAU,EAAE,CAC1B;MAAEK,IAAI,EAAE,4CAA4C;MAAEC,KAAK,EAAE;IAAO,CAAC,EACrE;MAAED,IAAI,EAAE,6CAA6C;MAAEC,KAAK,EAAEJ;IAAc,CAAC,CAC9E,CAAC;IAEF,OAAOJ,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAS,OAAA,CAAAV,kBAAA,GAAAA,kBAAA;AAMO,SAASO,eAAeA,CAC7BJ,UAAe,EACfQ,eAAkD,EAClD;EACA;EACA,IAAI,CAACR,UAAU,CAACS,SAAS,EAAE;IACzBT,UAAU,CAACS,SAAS,GAAG;MAAEC,MAAM,EAAE;IAAG,CAAC;EACvC;EAEAF,eAAe,CAACG,OAAO,CAAC,CAAC;IAAEN,IAAI;IAAEC;EAAM,CAAC,KAAK;IAC3C,MAAMM,mBAAmB,GAAGZ,UAAU,CAACS,SAAS,CAACC,MAAM,CAACG,SAAS,CAC9DC,IAA6B;MAAA,IAAAC,OAAA;MAAA,OAAK,EAAAA,OAAA,GAAAD,IAAI,CAACE,CAAC,cAAAD,OAAA,uBAANA,OAAA,CAAQV,IAAI,MAAKA,IAAI;IAAA,CAC1D,CAAC;IAED,IAAIO,mBAAmB,KAAK,CAAC,CAAC,EAAE;MAC9B;MACAZ,UAAU,CAACS,SAAS,CAACC,MAAM,CAACE,mBAAmB,CAAC,CAACK,CAAC,GAAGX,KAAK;IAC5D,CAAC,MAAM;MACL;MACAN,UAAU,CAACS,SAAS,CAACC,MAAM,CAACQ,IAAI,CAAC;QAC/BF,CAAC,EAAE;UAAEX;QAAK,CAAC;QACXY,CAAC,EAAEX;MACL,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["_configPlugins","require","_plugin","withProjectStrings","configOuter","withStringsXml","config","stringsXml","modResults","pluginVersion","getPluginVersion","addStringsToXml","name","value","exports","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}\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACO,MAAME,kBAAgC,GAAIC,WAAW,IAAK;EAC/D,OAAO,IAAAC,6BAAc,EAACD,WAAW,EAAGE,MAAM,IAAK;IAC7C,MAAMC,UAAU,GAAGD,MAAM,CAACE,UAAU;IACpC,MAAMC,aAAa,GAAG,IAAAC,wBAAgB,EAAC,CAAC;;IAExC;IACA;IACA;IACA;IACA;IACAC,eAAe,CAACJ,UAAU,EAAE,CAC1B;MAAEK,IAAI,EAAE,4CAA4C;MAAEC,KAAK,EAAE;IAAO,CAAC,EACrE;MACED,IAAI,EAAE,6CAA6C;MACnDC,KAAK,EAAEJ;IACT,CAAC,CACF,CAAC;IAEF,OAAOH,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAQ,OAAA,CAAAX,kBAAA,GAAAA,kBAAA;AAMO,SAASQ,eAAeA,CAC7BJ,UAAuB,EACvBQ,eAAkD,EAClD;EACA;EACA,IAAI,CAACR,UAAU,CAACS,SAAS,EAAE;IACzBT,UAAU,CAACS,SAAS,GAAG;MAAEC,MAAM,EAAE;IAAG,CAAC;EACvC;EACA;EACA,IAAI,CAACV,UAAU,CAACS,SAAS,CAACC,MAAM,EAAE;IAChCV,UAAU,CAACS,SAAS,CAACC,MAAM,GAAG,EAAE;EAClC;;EAEA;EACA,MAAMC,WAAW,GAAGX,UAAU,CAACS,SAAS,CAACC,MAAM;EAC/CF,eAAe,CAACI,OAAO,CAAC,CAAC;IAAEP,IAAI;IAAEC;EAAM,CAAC,KAAK;IAC3C,MAAMO,mBAAmB,GAAGF,WAAW,CAACG,SAAS,CAC9CC,IAAI;MAAA,IAAAC,OAAA;MAAA,OAAK,EAAAA,OAAA,GAAAD,IAAI,CAACE,CAAC,cAAAD,OAAA,uBAANA,OAAA,CAAQX,IAAI,MAAKA,IAAI;IAAA,CACjC,CAAC;IAED,IAAIQ,mBAAmB,KAAK,CAAC,CAAC,EAAE;MAC9B;MACAF,WAAW,CAACE,mBAAmB,CAAC,CAACK,CAAC,GAAGZ,KAAK;IAC5C,CAAC,MAAM;MACL;MACAK,WAAW,CAACQ,IAAI,CAAC;QACfF,CAAC,EAAE;UAAEZ;QAAK,CAAC;QACXa,CAAC,EAAEZ;MACL,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CIO_PROJECT_GOOGLE_SNIPPET = exports.CIO_PROJECT_GIST_MAVEN_SNIPPET = exports.CIO_PROJECT_BUILDSCRIPTS_REGEX = exports.CIO_PROJECT_ALLPROJECTS_REGEX = exports.CIO_GIST_MAVEN_REGEX = exports.CIO_APP_GOOGLE_SNIPPET = exports.CIO_APP_APPLY_REGEX = void 0;
6
+ exports.CIO_PROJECT_GOOGLE_SNIPPET = exports.CIO_PROJECT_GIST_MAVEN_SNIPPET = exports.CIO_PROJECT_BUILDSCRIPTS_REGEX = exports.CIO_PROJECT_ALLPROJECTS_REGEX = exports.CIO_NATIVE_SDK_INITIALIZE_SNIPPET = exports.CIO_NATIVE_SDK_INITIALIZE_CALL = exports.CIO_MAINAPPLICATION_ONCREATE_REGEX = exports.CIO_GIST_MAVEN_REGEX = exports.CIO_APP_GOOGLE_SNIPPET = exports.CIO_APP_APPLY_REGEX = void 0;
7
7
  const CIO_PROJECT_BUILDSCRIPTS_REGEX = exports.CIO_PROJECT_BUILDSCRIPTS_REGEX = /(buildscript\s*\{(.|\n)*dependencies\s*\{)/;
8
8
  const CIO_APP_APPLY_REGEX = exports.CIO_APP_APPLY_REGEX = /(apply plugin: "com.android.application")/;
9
9
  const CIO_GIST_MAVEN_REGEX = exports.CIO_GIST_MAVEN_REGEX = /maven { url "https:\/\/maven.gist.build" }/;
@@ -11,4 +11,10 @@ const CIO_PROJECT_ALLPROJECTS_REGEX = exports.CIO_PROJECT_ALLPROJECTS_REGEX = /(
11
11
  const CIO_PROJECT_GIST_MAVEN_SNIPPET = exports.CIO_PROJECT_GIST_MAVEN_SNIPPET = ' maven { url "https://maven.gist.build" }';
12
12
  const CIO_APP_GOOGLE_SNIPPET = exports.CIO_APP_GOOGLE_SNIPPET = 'apply plugin: "com.google.gms.google-services" // Google Services plugin';
13
13
  const CIO_PROJECT_GOOGLE_SNIPPET = exports.CIO_PROJECT_GOOGLE_SNIPPET = ' classpath "com.google.gms:google-services:4.3.13" // Google Services plugin';
14
+ const CIO_MAINAPPLICATION_ONCREATE_REGEX = exports.CIO_MAINAPPLICATION_ONCREATE_REGEX = /override\s+fun\s+onCreate\s*\(\s*\)\s*\{[\s\S]*?\}/;
15
+ // Actual method call, also used to detect if Customer.io auto initialization is already present
16
+ const CIO_NATIVE_SDK_INITIALIZE_CALL = exports.CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize(this)';
17
+ // Complete code snippet to inject into MainActivity.onCreate()
18
+ const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = exports.CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK
19
+ ${CIO_NATIVE_SDK_INITIALIZE_CALL}`;
14
20
  //# sourceMappingURL=android.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","exports","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":";;;;;;AAAO,MAAMA,8BAA8B,GAAAC,OAAA,CAAAD,8BAAA,GACzC,4CAA4C;AACvC,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,2CAA2C;AACvE,MAAMC,oBAAoB,GAAAF,OAAA,CAAAE,oBAAA,GAC/B,4CAA4C;AACvC,MAAMC,6BAA6B,GAAAH,OAAA,CAAAG,6BAAA,GACxC,kDAAkD;AAE7C,MAAMC,8BAA8B,GAAAJ,OAAA,CAAAI,8BAAA,GACzC,kDAAkD;AAC7C,MAAMC,sBAAsB,GAAAL,OAAA,CAAAK,sBAAA,GACjC,2EAA2E;AACtE,MAAMC,0BAA0B,GAAAN,OAAA,CAAAM,0BAAA,GACrC,sFAAsF","ignoreList":[]}
1
+ {"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","exports","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":";;;;;;AAAO,MAAMA,8BAA8B,GAAAC,OAAA,CAAAD,8BAAA,GACzC,4CAA4C;AACvC,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,2CAA2C;AACvE,MAAMC,oBAAoB,GAAAF,OAAA,CAAAE,oBAAA,GAC/B,4CAA4C;AACvC,MAAMC,6BAA6B,GAAAH,OAAA,CAAAG,6BAAA,GACxC,kDAAkD;AAE7C,MAAMC,8BAA8B,GAAAJ,OAAA,CAAAI,8BAAA,GACzC,kDAAkD;AAC7C,MAAMC,sBAAsB,GAAAL,OAAA,CAAAK,sBAAA,GACjC,2EAA2E;AACtE,MAAMC,0BAA0B,GAAAN,OAAA,CAAAM,0BAAA,GACrC,sFAAsF;AAEjF,MAAMC,kCAAkC,GAAAP,OAAA,CAAAO,kCAAA,GAAG,oDAAoD;AACtG;AACO,MAAMC,8BAA8B,GAAAR,OAAA,CAAAQ,8BAAA,GAAG,2CAA2C;AACzF;AACO,MAAMC,iCAAiC,GAAAT,OAAA,CAAAS,iCAAA,GAAG;AACjD,MAAMD,8BAA8B,EAAE","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PLATFORM = void 0;
7
+ /**
8
+ * Platform constants for native SDK initialization
9
+ */
10
+ const PLATFORM = exports.PLATFORM = {
11
+ IOS: 'ios',
12
+ ANDROID: 'android'
13
+ };
14
+
15
+ /**
16
+ * Platform type definition
17
+ */
18
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PLATFORM","exports","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;AACO,MAAMA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACtBE,GAAG,EAAE,KAAK;EACVC,OAAO,EAAE;AACX,CAAU;;AAEV;AACA;AACA","ignoreList":[]}
@@ -3,16 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.LOCAL_PATH_TO_CIO_NSE_FILES = exports.IOS_DEPLOYMENT_TARGET = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.CIO_TARGET_NAME = exports.CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_NOTIFICATION_TARGET_NAME = exports.CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = exports.CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX = exports.CIO_INITIALIZECIOSDK_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_DEEPLINK_COMMENT_REGEX = exports.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = exports.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = exports.CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = exports.CIO_APPDELEGATEDECLARATION_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = void 0;
6
+ exports.IOS_DEPLOYMENT_TARGET = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.CIO_TARGET_NAME = exports.CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_NOTIFICATION_TARGET_NAME = exports.CIO_NATIVE_SDK_INITIALIZE_SNIPPET = exports.CIO_NATIVE_SDK_INITIALIZE_CALL = exports.CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX = exports.CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = exports.CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX = exports.CIO_INITIALIZECIOSDK_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_DEEPLINK_COMMENT_REGEX = exports.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = exports.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = exports.CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = exports.CIO_APPDELEGATEDECLARATION_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = void 0;
7
7
  exports.getRelativePathToRNSDK = getRelativePathToRNSDK;
8
- const finder = require('find-package-json');
9
8
  const path = require('path');
10
9
  const resolveFrom = require('resolve-from');
11
- const f = finder(__dirname);
12
- let pluginPackageRoot = f.next().filename;
13
- // This is the path to the root of the customerio-expo-plugin package
14
- pluginPackageRoot = path.dirname(pluginPackageRoot);
15
- const LOCAL_PATH_TO_CIO_NSE_FILES = exports.LOCAL_PATH_TO_CIO_NSE_FILES = path.join(pluginPackageRoot, 'plugin/src/helpers/native-files/ios');
16
10
  function getRelativePathToRNSDK(iosPath) {
17
11
  // Root path of the Expo project
18
12
  const rootAppPath = path.dirname(iosPath);
@@ -142,4 +136,10 @@ const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = exports.CIO_REGISTER_PUSHNOTIFI
142
136
  }
143
137
  }`;
144
138
  const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = exports.CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = /\{\{REGISTER_SNIPPET\}\}/;
139
+ // Regex to match MessagingPush initialization in AppDelegate (different from NSE initialization)
140
+ const CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX = exports.CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX = /(MessagingPush(?:APN|FCM)\.initialize)/;
141
+ const CIO_NATIVE_SDK_INITIALIZE_CALL = exports.CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize()';
142
+ const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = exports.CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK
143
+ ${CIO_NATIVE_SDK_INITIALIZE_CALL}
144
+ `;
145
145
  //# 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","exports","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":"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","ignoreList":[]}
1
+ {"version":3,"names":["path","require","resolveFrom","getRelativePathToRNSDK","iosPath","rootAppPath","dirname","pluginPackageJsonPath","silent","relative","IOS_DEPLOYMENT_TARGET","exports","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_CALL}\n `;\n"],"mappings":"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","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
+ )