customerio-expo-plugin 2.5.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
@@ -1 +1 @@
1
- {"version":3,"names":["withAndroidManifest","withAndroidManifestUpdates","configOuter","props","application","modResults","manifest","customerIOMessagingpush","hasService","some","service","push","action","$","console","log"],"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,SAASA,mBAAmB,QAAQ,sBAAsB;AAK1D,OAAO,MAAMC,0BAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOF,mBAAmB,CAACE,WAAW,EAAGC,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","ignoreList":[]}
1
+ {"version":3,"names":["withAndroidManifest","withAndroidManifestUpdates","configOuter","props","application","modResults","manifest","customerIOMessagingpush","service","hasService","some","$","push","action","console","log"],"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,SAASA,mBAAmB,QAAQ,sBAAsB;AAK1D,OAAO,MAAMC,0BAEZ,GAAIC,WAAW,IAAK;EACnB,OAAOF,mBAAmB,CAACE,WAAW,EAAGC,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","ignoreList":[]}
@@ -2,10 +2,11 @@ import { withAndroidManifestUpdates } from './withAndroidManifestUpdates';
2
2
  import { withAppGoogleServices } from './withAppGoogleServices';
3
3
  import { withGistMavenRepository } from './withGistMavenRepository';
4
4
  import { withGoogleServicesJSON } from './withGoogleServicesJSON';
5
+ import { withMainApplicationModifications } from './withMainApplicationModifications';
5
6
  import { withNotificationChannelMetadata } from './withNotificationChannelMetadata';
6
7
  import { withProjectGoogleServices } from './withProjectGoogleServices';
7
8
  import { withProjectStrings } from './withProjectStrings';
8
- export function withCIOAndroid(config, props) {
9
+ export function withCIOAndroid(config, sdkConfig, props) {
9
10
  var _props$pushNotificati;
10
11
  config = withGistMavenRepository(config, props);
11
12
  config = withProjectGoogleServices(config, props);
@@ -18,6 +19,10 @@ export function withCIOAndroid(config, props) {
18
19
  if ((_props$pushNotificati = props.pushNotification) !== null && _props$pushNotificati !== void 0 && _props$pushNotificati.channel) {
19
20
  config = withNotificationChannelMetadata(config, props);
20
21
  }
22
+ // Add auto initialization if sdkConfig is provided
23
+ if (sdkConfig) {
24
+ config = withMainApplicationModifications(config, sdkConfig);
25
+ }
21
26
  return config;
22
27
  }
23
28
  //# sourceMappingURL=withCIOAndroid.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withAndroidManifestUpdates","withAppGoogleServices","withGistMavenRepository","withGoogleServicesJSON","withNotificationChannelMetadata","withProjectGoogleServices","withProjectStrings","withCIOAndroid","config","props","_props$pushNotificati","setHighPriorityPushHandler","pushNotification","channel"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { withAndroidManifestUpdates } from './withAndroidManifestUpdates';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGistMavenRepository } from './withGistMavenRepository';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withNotificationChannelMetadata } from './withNotificationChannelMetadata';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\nimport { withProjectStrings } from './withProjectStrings';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsAndroid\n): ExpoConfig {\n config = withGistMavenRepository(config, props);\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n config = withProjectStrings(config);\n if (props.setHighPriorityPushHandler) {\n config = withAndroidManifestUpdates(config, props);\n }\n if (props.pushNotification?.channel) {\n config = withNotificationChannelMetadata(config, props);\n }\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,kBAAkB,QAAQ,sBAAsB;AAEzD,OAAO,SAASC,cAAcA,CAC5BC,MAAkB,EAClBC,KAAqC,EACzB;EAAA,IAAAC,qBAAA;EACZF,MAAM,GAAGN,uBAAuB,CAACM,MAAM,EAAEC,KAAK,CAAC;EAC/CD,MAAM,GAAGH,yBAAyB,CAACG,MAAM,EAAEC,KAAK,CAAC;EACjDD,MAAM,GAAGP,qBAAqB,CAACO,MAAM,EAAEC,KAAK,CAAC;EAC7CD,MAAM,GAAGL,sBAAsB,CAACK,MAAM,EAAEC,KAAK,CAAC;EAC9CD,MAAM,GAAGF,kBAAkB,CAACE,MAAM,CAAC;EACnC,IAAIC,KAAK,CAACE,0BAA0B,EAAE;IACpCH,MAAM,GAAGR,0BAA0B,CAACQ,MAAM,EAAEC,KAAK,CAAC;EACpD;EACA,KAAAC,qBAAA,GAAID,KAAK,CAACG,gBAAgB,cAAAF,qBAAA,eAAtBA,qBAAA,CAAwBG,OAAO,EAAE;IACnCL,MAAM,GAAGJ,+BAA+B,CAACI,MAAM,EAAEC,KAAK,CAAC;EACzD;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"names":["withAndroidManifestUpdates","withAppGoogleServices","withGistMavenRepository","withGoogleServicesJSON","withMainApplicationModifications","withNotificationChannelMetadata","withProjectGoogleServices","withProjectStrings","withCIOAndroid","config","sdkConfig","props","_props$pushNotificati","setHighPriorityPushHandler","pushNotification","channel"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsAndroid, NativeSDKConfig } from '../types/cio-types';\nimport { withAndroidManifestUpdates } from './withAndroidManifestUpdates';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGistMavenRepository } from './withGistMavenRepository';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withMainApplicationModifications } from './withMainApplicationModifications';\nimport { withNotificationChannelMetadata } from './withNotificationChannelMetadata';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\nimport { withProjectStrings } from './withProjectStrings';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n sdkConfig: NativeSDKConfig | undefined,\n props: CustomerIOPluginOptionsAndroid\n): ExpoConfig {\n config = withGistMavenRepository(config, props);\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n config = withProjectStrings(config);\n if (props.setHighPriorityPushHandler) {\n config = withAndroidManifestUpdates(config, props);\n }\n if (props.pushNotification?.channel) {\n config = withNotificationChannelMetadata(config, props);\n }\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n config = withMainApplicationModifications(config, sdkConfig);\n }\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,gCAAgC,QAAQ,oCAAoC;AACrF,SAASC,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,kBAAkB,QAAQ,sBAAsB;AAEzD,OAAO,SAASC,cAAcA,CAC5BC,MAAkB,EAClBC,SAAsC,EACtCC,KAAqC,EACzB;EAAA,IAAAC,qBAAA;EACZH,MAAM,GAAGP,uBAAuB,CAACO,MAAM,EAAEE,KAAK,CAAC;EAC/CF,MAAM,GAAGH,yBAAyB,CAACG,MAAM,EAAEE,KAAK,CAAC;EACjDF,MAAM,GAAGR,qBAAqB,CAACQ,MAAM,EAAEE,KAAK,CAAC;EAC7CF,MAAM,GAAGN,sBAAsB,CAACM,MAAM,EAAEE,KAAK,CAAC;EAC9CF,MAAM,GAAGF,kBAAkB,CAACE,MAAM,CAAC;EACnC,IAAIE,KAAK,CAACE,0BAA0B,EAAE;IACpCJ,MAAM,GAAGT,0BAA0B,CAACS,MAAM,EAAEE,KAAK,CAAC;EACpD;EACA,KAAAC,qBAAA,GAAID,KAAK,CAACG,gBAAgB,cAAAF,qBAAA,eAAtBA,qBAAA,CAAwBG,OAAO,EAAE;IACnCN,MAAM,GAAGJ,+BAA+B,CAACI,MAAM,EAAEE,KAAK,CAAC;EACzD;EACA;EACA,IAAID,SAAS,EAAE;IACbD,MAAM,GAAGL,gCAAgC,CAACK,MAAM,EAAEC,SAAS,CAAC;EAC9D;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
@@ -14,7 +14,7 @@ export const withGoogleServicesJSON = (configOuter, cioProps) => {
14
14
  if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
15
15
  try {
16
16
  FileManagement.copyFile(googleServicesFile, `${androidPath}/app/google-services.json`);
17
- } catch (e) {
17
+ } catch {
18
18
  console.log(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`);
19
19
  }
20
20
  } else {
@@ -1 +1 @@
1
- {"version":3,"names":["withProjectBuildGradle","FileManagement","withGoogleServicesJSON","configOuter","cioProps","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","exists","copyFile","e","console","log"],"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,SAASA,sBAAsB,QAAQ,sBAAsB;AAG7D,SAASC,cAAc,QAAQ,mCAAmC;AAGlE,OAAO,MAAMC,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAOJ,sBAAsB,CAACG,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEN,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACL,cAAc,CAACU,MAAM,CAAC,GAAGJ,WAAW,2BAA2B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIT,cAAc,CAACU,MAAM,CAACD,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFT,cAAc,CAACW,QAAQ,CACrBF,kBAAkB,EAClB,GAAGH,WAAW,2BAChB,CAAC;QACH,CAAC,CAAC,OAAOM,CAAC,EAAE;UACVC,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","ignoreList":[]}
1
+ {"version":3,"names":["withProjectBuildGradle","FileManagement","withGoogleServicesJSON","configOuter","cioProps","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","exists","copyFile","console","log"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withProjectBuildGradle } from '@expo/config-plugins';\n\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const options: CustomerIOPluginOptionsAndroid = {\n androidPath: props.modRequest.platformProjectRoot,\n googleServicesFile: cioProps?.googleServicesFile,\n };\n const { androidPath, googleServicesFile } = options;\n if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${androidPath}/app/google-services.json`\n );\n } catch {\n console.log(\n `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n console.log(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n console.log(\n `File already exists: ${androidPath}/app/google-services.json. Skipping...`\n );\n }\n\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,cAAc,QAAQ,mCAAmC;AAGlE,OAAO,MAAMC,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAOJ,sBAAsB,CAACG,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEN,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACL,cAAc,CAACU,MAAM,CAAC,GAAGJ,WAAW,2BAA2B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIT,cAAc,CAACU,MAAM,CAACD,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFT,cAAc,CAACW,QAAQ,CACrBF,kBAAkB,EAClB,GAAGH,WAAW,2BAChB,CAAC;QACH,CAAC,CAAC,MAAM;UACNM,OAAO,CAACC,GAAG,CACT,4FAA4FP,WAAW,2BACzG,CAAC;QACH;MACF,CAAC,MAAM;QACLM,OAAO,CAACC,GAAG,CACT,wCAAwCJ,kBAAkB,yDAAyDH,WAAW,2BAChI,CAAC;MACH;IACF,CAAC,MAAM;MACLM,OAAO,CAACC,GAAG,CACT,wBAAwBP,WAAW,wCACrC,CAAC;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ import { withMainApplication } from '@expo/config-plugins';
2
+ import { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';
3
+ import { PLATFORM } from '../helpers/constants/common';
4
+ import { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';
5
+ import { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';
6
+ export const withMainApplicationModifications = (configOuter, sdkConfig) => {
7
+ return withMainApplication(configOuter, async config => {
8
+ const content = setupCustomerIOSDKInitializer(config, sdkConfig);
9
+ config.modResults.contents = content;
10
+ return config;
11
+ });
12
+ };
13
+
14
+ /**
15
+ * Setup CustomerIOSDKInitializer for Android auto initialization
16
+ */
17
+ const setupCustomerIOSDKInitializer = (config, sdkConfig) => {
18
+ const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
19
+ const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
20
+ const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
21
+ const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
22
+ let content = config.modResults.contents;
23
+ try {
24
+ // Always regenerate the CustomerIOSDKInitializer file to reflect config changes
25
+ copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig));
26
+ // Add import if not already present
27
+ content = addImportToFile(content, SDK_INITIALIZER_IMPORT);
28
+ // Add initialization code to onCreate if not already present
29
+ if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {
30
+ content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);
31
+ }
32
+ } catch (error) {
33
+ console.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);
34
+ return config.modResults.contents;
35
+ }
36
+ return content;
37
+ };
38
+ //# sourceMappingURL=withMainApplicationModifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withMainApplication","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","PLATFORM","patchNativeSDKInitializer","addCodeToMethod","addImportToFile","copyTemplateFile","withMainApplicationModifications","configOuter","sdkConfig","config","content","setupCustomerIOSDKInitializer","modResults","contents","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","ANDROID","includes","error","console","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type { NativeSDKConfig } from '../types/cio-types';\nimport { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';\n\nexport const withMainApplicationModifications: ConfigPlugin<NativeSDKConfig> = (configOuter, sdkConfig) => {\n return withMainApplication(configOuter, async (config) => {\n const content = setupCustomerIOSDKInitializer(config, sdkConfig);\n config.modResults.contents = content;\n return config;\n });\n};\n\n/**\n * Setup CustomerIOSDKInitializer for Android auto initialization\n */\nconst setupCustomerIOSDKInitializer = (\n config: ExportedConfigWithProps<ApplicationProjectFile>,\n sdkConfig: NativeSDKConfig,\n): string => {\n const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';\n const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';\n\n const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;\n const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;\n\n let content = config.modResults.contents;\n\n try {\n // Always regenerate the CustomerIOSDKInitializer file to reflect config changes\n copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>\n patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig)\n );\n // Add import if not already present\n content = addImportToFile(content, SDK_INITIALIZER_IMPORT);\n // Add initialization code to onCreate if not already present\n if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);\n }\n } catch (error) {\n console.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);\n return config.modResults.contents;\n }\n\n return content;\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAE1D,SAASC,kCAAkC,EAAEC,8BAA8B,EAAEC,iCAAiC,QAAQ,8BAA8B;AACpJ,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SAASC,yBAAyB,QAAQ,wCAAwC;AAElF,SAASC,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,QAAQ,kBAAkB;AAErF,OAAO,MAAMC,gCAA+D,GAAGA,CAACC,WAAW,EAAEC,SAAS,KAAK;EACzG,OAAOX,mBAAmB,CAACU,WAAW,EAAE,MAAOE,MAAM,IAAK;IACxD,MAAMC,OAAO,GAAGC,6BAA6B,CAACF,MAAM,EAAED,SAAS,CAAC;IAChEC,MAAM,CAACG,UAAU,CAACC,QAAQ,GAAGH,OAAO;IACpC,OAAOD,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA,MAAME,6BAA6B,GAAGA,CACpCF,MAAuD,EACvDD,SAA0B,KACf;EACX,MAAMM,qBAAqB,GAAG,0BAA0B;EACxD,MAAMC,uBAAuB,GAAG,sBAAsB;EAEtD,MAAMC,oBAAoB,GAAG,GAAGF,qBAAqB,KAAK;EAC1D,MAAMG,sBAAsB,GAAG,UAAUF,uBAAuB,IAAID,qBAAqB,EAAE;EAE3F,IAAIJ,OAAO,GAAGD,MAAM,CAACG,UAAU,CAACC,QAAQ;EAExC,IAAI;IACF;IACAR,gBAAgB,CAACI,MAAM,EAAEO,oBAAoB,EAAED,uBAAuB,EAAGL,OAAO,IAC9ER,yBAAyB,CAACQ,OAAO,EAAET,QAAQ,CAACiB,OAAO,EAAEV,SAAS,CAChE,CAAC;IACD;IACAE,OAAO,GAAGN,eAAe,CAACM,OAAO,EAAEO,sBAAsB,CAAC;IAC1D;IACA,IAAI,CAACP,OAAO,CAACS,QAAQ,CAACpB,8BAA8B,CAAC,EAAE;MACrDW,OAAO,GAAGP,eAAe,CAACO,OAAO,EAAEZ,kCAAkC,EAAEE,iCAAiC,CAAC;IAC3G;EACF,CAAC,CAAC,OAAOoB,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,mBAAmBR,qBAAqB,GAAG,EAAEM,KAAK,CAAC;IAChE,OAAOX,MAAM,CAACG,UAAU,CAACC,QAAQ;EACnC;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
@@ -9,7 +9,7 @@ const addMetadataIfNotExists = (application, name, value) => {
9
9
  }
10
10
 
11
11
  // Check if metadata already exists
12
- const hasMetadata = application['meta-data'].some(metadata => metadata['$']['android:name'] === name);
12
+ const hasMetadata = application['meta-data'].some(metadata => metadata.$['android:name'] === name);
13
13
 
14
14
  // Add metadata if it doesn't exist
15
15
  if (!hasMetadata) {
@@ -1 +1 @@
1
- {"version":3,"names":["withAndroidManifest","addMetadataIfNotExists","application","name","value","hasMetadata","some","metadata","push","$","withNotificationChannelMetadata","config","props","manifestProps","_props$pushNotificati","modResults","manifest","channel","pushNotification","id","importance","undefined","String"],"sources":["withNotificationChannelMetadata.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\n/**\n * Adds a metadata entry to the Android manifest if it doesn't already exist\n */\nconst addMetadataIfNotExists = (\n application: ManifestApplication,\n name: string,\n value: string\n): void => {\n // Initialize meta-data array if it doesn't exist\n if (!application['meta-data']) {\n application['meta-data'] = [];\n }\n\n // Check if metadata already exists\n const hasMetadata = application['meta-data'].some(\n (metadata) => metadata['$']['android:name'] === name\n );\n\n // Add metadata if it doesn't exist\n if (!hasMetadata) {\n application['meta-data'].push({\n $: {\n 'android:name': name,\n 'android:value': value,\n },\n });\n }\n};\n\nexport const withNotificationChannelMetadata: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (config, props) => {\n return withAndroidManifest(config, (manifestProps) => {\n const application = manifestProps.modResults.manifest.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,SAASA,mBAAmB,QAAQ,sBAAsB;AAK1D;AACA;AACA;AACA,MAAMC,sBAAsB,GAAGA,CAC7BC,WAAgC,EAChCC,IAAY,EACZC,KAAa,KACJ;EACT;EACA,IAAI,CAACF,WAAW,CAAC,WAAW,CAAC,EAAE;IAC7BA,WAAW,CAAC,WAAW,CAAC,GAAG,EAAE;EAC/B;;EAEA;EACA,MAAMG,WAAW,GAAGH,WAAW,CAAC,WAAW,CAAC,CAACI,IAAI,CAC9CC,QAAQ,IAAKA,QAAQ,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;AAED,OAAO,MAAMM,+BAEZ,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EACrB,OAAOZ,mBAAmB,CAACW,MAAM,EAAGE,aAAa,IAAK;IAAA,IAAAC,qBAAA;IACpD,MAAMZ,WAAW,GAAGW,aAAa,CAACE,UAAU,CAACC,QAAQ,CAACd,WAAoC;IAC1F,MAAMe,OAAO,IAAAH,qBAAA,GAAGF,KAAK,CAACM,gBAAgB,cAAAJ,qBAAA,uBAAtBA,qBAAA,CAAwBG,OAAO;;IAE/C;IACA,IAAIA,OAAO,KAAKA,OAAO,CAACE,EAAE,IAAIF,OAAO,CAACd,IAAI,IAAIc,OAAO,CAACG,UAAU,KAAKC,SAAS,CAAC,EAAE;MAC/E,IAAIJ,OAAO,CAACE,EAAE,EAAE;QACdlB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,qCAAqC,EACrCe,OAAO,CAACE,EACV,CAAC;MACH;MAEA,IAAIF,OAAO,CAACd,IAAI,EAAE;QAChBF,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,uCAAuC,EACvCe,OAAO,CAACd,IACV,CAAC;MACH;MAEA,IAAIc,OAAO,CAACG,UAAU,KAAKC,SAAS,EAAE;QACpCpB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,6CAA6C,EAC7CoB,MAAM,CAACL,OAAO,CAACG,UAAU,CAC3B,CAAC;MACH;IACF;IAEAP,aAAa,CAACE,UAAU,CAACC,QAAQ,CAACd,WAAW,GAAGA,WAAW;IAC3D,OAAOW,aAAa;EACtB,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withAndroidManifest","addMetadataIfNotExists","application","name","value","hasMetadata","some","metadata","$","push","withNotificationChannelMetadata","config","props","manifestProps","_props$pushNotificati","modResults","manifest","channel","pushNotification","id","importance","undefined","String"],"sources":["withNotificationChannelMetadata.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\n/**\n * Adds a metadata entry to the Android manifest if it doesn't already exist\n */\nconst addMetadataIfNotExists = (\n application: ManifestApplication,\n name: string,\n value: string\n): void => {\n // Initialize meta-data array if it doesn't exist\n if (!application['meta-data']) {\n application['meta-data'] = [];\n }\n\n // Check if metadata already exists\n const hasMetadata = application['meta-data'].some(\n (metadata) => metadata.$['android:name'] === name\n );\n\n // Add metadata if it doesn't exist\n if (!hasMetadata) {\n application['meta-data'].push({\n $: {\n 'android:name': name,\n 'android:value': value,\n },\n });\n }\n};\n\nexport const withNotificationChannelMetadata: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (config, props) => {\n return withAndroidManifest(config, (manifestProps) => {\n const application = manifestProps.modResults.manifest\n .application as ManifestApplication[];\n const channel = props.pushNotification?.channel;\n\n // Only proceed if channel configuration exists\n if (\n channel &&\n (channel.id || channel.name || channel.importance !== undefined)\n ) {\n if (channel.id) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_id',\n channel.id\n );\n }\n\n if (channel.name) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_name',\n channel.name\n );\n }\n\n if (channel.importance !== undefined) {\n addMetadataIfNotExists(\n application[0],\n 'io.customer.notification_channel_importance',\n String(channel.importance)\n );\n }\n }\n\n manifestProps.modResults.manifest.application = application;\n return manifestProps;\n });\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAK1D;AACA;AACA;AACA,MAAMC,sBAAsB,GAAGA,CAC7BC,WAAgC,EAChCC,IAAY,EACZC,KAAa,KACJ;EACT;EACA,IAAI,CAACF,WAAW,CAAC,WAAW,CAAC,EAAE;IAC7BA,WAAW,CAAC,WAAW,CAAC,GAAG,EAAE;EAC/B;;EAEA;EACA,MAAMG,WAAW,GAAGH,WAAW,CAAC,WAAW,CAAC,CAACI,IAAI,CAC9CC,QAAQ,IAAKA,QAAQ,CAACC,CAAC,CAAC,cAAc,CAAC,KAAKL,IAC/C,CAAC;;EAED;EACA,IAAI,CAACE,WAAW,EAAE;IAChBH,WAAW,CAAC,WAAW,CAAC,CAACO,IAAI,CAAC;MAC5BD,CAAC,EAAE;QACD,cAAc,EAAEL,IAAI;QACpB,eAAe,EAAEC;MACnB;IACF,CAAC,CAAC;EACJ;AACF,CAAC;AAED,OAAO,MAAMM,+BAEZ,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EACrB,OAAOZ,mBAAmB,CAACW,MAAM,EAAGE,aAAa,IAAK;IAAA,IAAAC,qBAAA;IACpD,MAAMZ,WAAW,GAAGW,aAAa,CAACE,UAAU,CAACC,QAAQ,CAClDd,WAAoC;IACvC,MAAMe,OAAO,IAAAH,qBAAA,GAAGF,KAAK,CAACM,gBAAgB,cAAAJ,qBAAA,uBAAtBA,qBAAA,CAAwBG,OAAO;;IAE/C;IACA,IACEA,OAAO,KACNA,OAAO,CAACE,EAAE,IAAIF,OAAO,CAACd,IAAI,IAAIc,OAAO,CAACG,UAAU,KAAKC,SAAS,CAAC,EAChE;MACA,IAAIJ,OAAO,CAACE,EAAE,EAAE;QACdlB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,qCAAqC,EACrCe,OAAO,CAACE,EACV,CAAC;MACH;MAEA,IAAIF,OAAO,CAACd,IAAI,EAAE;QAChBF,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,uCAAuC,EACvCe,OAAO,CAACd,IACV,CAAC;MACH;MAEA,IAAIc,OAAO,CAACG,UAAU,KAAKC,SAAS,EAAE;QACpCpB,sBAAsB,CACpBC,WAAW,CAAC,CAAC,CAAC,EACd,6CAA6C,EAC7CoB,MAAM,CAACL,OAAO,CAACG,UAAU,CAC3B,CAAC;MACH;IACF;IAEAP,aAAa,CAACE,UAAU,CAACC,QAAQ,CAACd,WAAW,GAAGA,WAAW;IAC3D,OAAOW,aAAa;EACtB,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -1,11 +1,11 @@
1
1
  import { withStringsXml } from '@expo/config-plugins';
2
- import { getPluginVersion } from '../helpers/utils/pluginUtils';
2
+ import { getPluginVersion } from '../utils/plugin';
3
3
 
4
4
  /**
5
5
  * Adds or updates string resources in Android's strings.xml required by the plugin
6
6
  */
7
- export const withProjectStrings = config => {
8
- return withStringsXml(config, config => {
7
+ export const withProjectStrings = configOuter => {
8
+ return withStringsXml(configOuter, config => {
9
9
  const stringsXml = config.modResults;
10
10
  const pluginVersion = getPluginVersion();
11
11
 
@@ -38,20 +38,27 @@ export function addStringsToXml(stringsXml, stringResources) {
38
38
  string: []
39
39
  };
40
40
  }
41
+ // Ensure the string array exists
42
+ if (!stringsXml.resources.string) {
43
+ stringsXml.resources.string = [];
44
+ }
45
+
46
+ // Get a reference to the string array after ensuring it exists
47
+ const stringArray = stringsXml.resources.string;
41
48
  stringResources.forEach(({
42
49
  name,
43
50
  value
44
51
  }) => {
45
- const existingStringIndex = stringsXml.resources.string.findIndex(item => {
52
+ const existingStringIndex = stringArray.findIndex(item => {
46
53
  var _item$$;
47
54
  return ((_item$$ = item.$) === null || _item$$ === void 0 ? void 0 : _item$$.name) === name;
48
55
  });
49
56
  if (existingStringIndex !== -1) {
50
57
  // Update the existing string
51
- stringsXml.resources.string[existingStringIndex]._ = value;
58
+ stringArray[existingStringIndex]._ = value;
52
59
  } else {
53
60
  // Add a new string resource
54
- stringsXml.resources.string.push({
61
+ stringArray.push({
55
62
  $: {
56
63
  name
57
64
  },
@@ -1 +1 @@
1
- {"version":3,"names":["withStringsXml","getPluginVersion","withProjectStrings","config","stringsXml","modResults","pluginVersion","addStringsToXml","name","value","stringResources","resources","string","forEach","existingStringIndex","findIndex","item","_item$$","$","_","push"],"sources":["withProjectStrings.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withStringsXml } from '@expo/config-plugins';\nimport { getPluginVersion } from '../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,SAASA,cAAc,QAAQ,sBAAsB;AACrD,SAASC,gBAAgB,QAAQ,8BAA8B;;AAE/D;AACA;AACA;AACA,OAAO,MAAMC,kBAAgC,GAAIC,MAAM,IAAK;EAC1D,OAAOH,cAAc,CAACG,MAAM,EAAGA,MAAM,IAAK;IACxC,MAAMC,UAAU,GAAGD,MAAM,CAACE,UAAU;IACpC,MAAMC,aAAa,GAAGL,gBAAgB,CAAC,CAAC;;IAExC;IACA;IACA;IACA;IACA;IACAM,eAAe,CAACH,UAAU,EAAE,CAC1B;MAAEI,IAAI,EAAE,4CAA4C;MAAEC,KAAK,EAAE;IAAO,CAAC,EACrE;MAAED,IAAI,EAAE,6CAA6C;MAAEC,KAAK,EAAEH;IAAc,CAAC,CAC9E,CAAC;IAEF,OAAOH,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,eAAeA,CAC7BH,UAAe,EACfM,eAAkD,EAClD;EACA;EACA,IAAI,CAACN,UAAU,CAACO,SAAS,EAAE;IACzBP,UAAU,CAACO,SAAS,GAAG;MAAEC,MAAM,EAAE;IAAG,CAAC;EACvC;EAEAF,eAAe,CAACG,OAAO,CAAC,CAAC;IAAEL,IAAI;IAAEC;EAAM,CAAC,KAAK;IAC3C,MAAMK,mBAAmB,GAAGV,UAAU,CAACO,SAAS,CAACC,MAAM,CAACG,SAAS,CAC9DC,IAA6B;MAAA,IAAAC,OAAA;MAAA,OAAK,EAAAA,OAAA,GAAAD,IAAI,CAACE,CAAC,cAAAD,OAAA,uBAANA,OAAA,CAAQT,IAAI,MAAKA,IAAI;IAAA,CAC1D,CAAC;IAED,IAAIM,mBAAmB,KAAK,CAAC,CAAC,EAAE;MAC9B;MACAV,UAAU,CAACO,SAAS,CAACC,MAAM,CAACE,mBAAmB,CAAC,CAACK,CAAC,GAAGV,KAAK;IAC5D,CAAC,MAAM;MACL;MACAL,UAAU,CAACO,SAAS,CAACC,MAAM,CAACQ,IAAI,CAAC;QAC/BF,CAAC,EAAE;UAAEV;QAAK,CAAC;QACXW,CAAC,EAAEV;MACL,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["withStringsXml","getPluginVersion","withProjectStrings","configOuter","config","stringsXml","modResults","pluginVersion","addStringsToXml","name","value","stringResources","resources","string","stringArray","forEach","existingStringIndex","findIndex","item","_item$$","$","_","push"],"sources":["withProjectStrings.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withStringsXml } from '@expo/config-plugins';\nimport type { ResourceXML } from '@expo/config-plugins/build/android/Resources';\nimport { getPluginVersion } from '../utils/plugin';\n\n/**\n * Adds or updates string resources in Android's strings.xml required by the plugin\n */\nexport const withProjectStrings: ConfigPlugin = (configOuter) => {\n return withStringsXml(configOuter, (config) => {\n const stringsXml = config.modResults;\n const pluginVersion = getPluginVersion();\n\n // Updating meta-data in AndroidManifest.xml fails on Manifest merging, so we're updating\n // the strings here instead\n // These strings are added to the strings.xml file by Customer.io's React Native SDK\n // We're updating them here to include the Expo client source and version so user agent\n // can be generated correctly for Expo apps\n addStringsToXml(stringsXml, [\n { name: 'customer_io_react_native_sdk_client_source', value: 'Expo' },\n {\n name: 'customer_io_react_native_sdk_client_version',\n value: pluginVersion,\n },\n ]);\n\n return config;\n });\n};\n\n/**\n * Adds or updates multiple string resources in Android's strings.xml\n * @param stringsXml - Parsed strings.xml object\n * @param stringResources - Array of string resources to add or update\n * @returns Updated strings.xml object\n */\nexport function addStringsToXml(\n stringsXml: ResourceXML,\n stringResources: { name: string; value: string }[]\n) {\n // Ensure the resource exists\n if (!stringsXml.resources) {\n stringsXml.resources = { string: [] };\n }\n // Ensure the string array exists\n if (!stringsXml.resources.string) {\n stringsXml.resources.string = [];\n }\n\n // Get a reference to the string array after ensuring it exists\n const stringArray = stringsXml.resources.string;\n stringResources.forEach(({ name, value }) => {\n const existingStringIndex = stringArray.findIndex(\n (item) => item.$?.name === name\n );\n\n if (existingStringIndex !== -1) {\n // Update the existing string\n stringArray[existingStringIndex]._ = value;\n } else {\n // Add a new string resource\n stringArray.push({\n $: { name },\n _: value,\n });\n }\n });\n}\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,sBAAsB;AAErD,SAASC,gBAAgB,QAAQ,iBAAiB;;AAElD;AACA;AACA;AACA,OAAO,MAAMC,kBAAgC,GAAIC,WAAW,IAAK;EAC/D,OAAOH,cAAc,CAACG,WAAW,EAAGC,MAAM,IAAK;IAC7C,MAAMC,UAAU,GAAGD,MAAM,CAACE,UAAU;IACpC,MAAMC,aAAa,GAAGN,gBAAgB,CAAC,CAAC;;IAExC;IACA;IACA;IACA;IACA;IACAO,eAAe,CAACH,UAAU,EAAE,CAC1B;MAAEI,IAAI,EAAE,4CAA4C;MAAEC,KAAK,EAAE;IAAO,CAAC,EACrE;MACED,IAAI,EAAE,6CAA6C;MACnDC,KAAK,EAAEH;IACT,CAAC,CACF,CAAC;IAEF,OAAOH,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,eAAeA,CAC7BH,UAAuB,EACvBM,eAAkD,EAClD;EACA;EACA,IAAI,CAACN,UAAU,CAACO,SAAS,EAAE;IACzBP,UAAU,CAACO,SAAS,GAAG;MAAEC,MAAM,EAAE;IAAG,CAAC;EACvC;EACA;EACA,IAAI,CAACR,UAAU,CAACO,SAAS,CAACC,MAAM,EAAE;IAChCR,UAAU,CAACO,SAAS,CAACC,MAAM,GAAG,EAAE;EAClC;;EAEA;EACA,MAAMC,WAAW,GAAGT,UAAU,CAACO,SAAS,CAACC,MAAM;EAC/CF,eAAe,CAACI,OAAO,CAAC,CAAC;IAAEN,IAAI;IAAEC;EAAM,CAAC,KAAK;IAC3C,MAAMM,mBAAmB,GAAGF,WAAW,CAACG,SAAS,CAC9CC,IAAI;MAAA,IAAAC,OAAA;MAAA,OAAK,EAAAA,OAAA,GAAAD,IAAI,CAACE,CAAC,cAAAD,OAAA,uBAANA,OAAA,CAAQV,IAAI,MAAKA,IAAI;IAAA,CACjC,CAAC;IAED,IAAIO,mBAAmB,KAAK,CAAC,CAAC,EAAE;MAC9B;MACAF,WAAW,CAACE,mBAAmB,CAAC,CAACK,CAAC,GAAGX,KAAK;IAC5C,CAAC,MAAM;MACL;MACAI,WAAW,CAACQ,IAAI,CAAC;QACfF,CAAC,EAAE;UAAEX;QAAK,CAAC;QACXY,CAAC,EAAEX;MACL,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -5,4 +5,10 @@ export const CIO_PROJECT_ALLPROJECTS_REGEX = /(allprojects\s*\{(.|\n){1,500}repo
5
5
  export const CIO_PROJECT_GIST_MAVEN_SNIPPET = ' maven { url "https://maven.gist.build" }';
6
6
  export const CIO_APP_GOOGLE_SNIPPET = 'apply plugin: "com.google.gms.google-services" // Google Services plugin';
7
7
  export const CIO_PROJECT_GOOGLE_SNIPPET = ' classpath "com.google.gms:google-services:4.3.13" // Google Services plugin';
8
+ export const CIO_MAINAPPLICATION_ONCREATE_REGEX = /override\s+fun\s+onCreate\s*\(\s*\)\s*\{[\s\S]*?\}/;
9
+ // Actual method call, also used to detect if Customer.io auto initialization is already present
10
+ export const CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize(this)';
11
+ // Complete code snippet to inject into MainActivity.onCreate()
12
+ export const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK
13
+ ${CIO_NATIVE_SDK_INITIALIZE_CALL}`;
8
14
  //# sourceMappingURL=android.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_APP_APPLY_REGEX","CIO_GIST_MAVEN_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","CIO_APP_GOOGLE_SNIPPET","CIO_PROJECT_GOOGLE_SNIPPET"],"sources":["android.ts"],"sourcesContent":["export const CIO_PROJECT_BUILDSCRIPTS_REGEX =\n /(buildscript\\s*\\{(.|\\n)*dependencies\\s*\\{)/;\nexport const CIO_APP_APPLY_REGEX = /(apply plugin: \"com.android.application\")/;\nexport const CIO_GIST_MAVEN_REGEX =\n /maven { url \"https:\\/\\/maven.gist.build\" }/;\nexport const CIO_PROJECT_ALLPROJECTS_REGEX =\n /(allprojects\\s*\\{(.|\\n){1,500}repositories\\s*\\{)/;\n\nexport const CIO_PROJECT_GIST_MAVEN_SNIPPET =\n ' maven { url \"https://maven.gist.build\" }';\nexport const CIO_APP_GOOGLE_SNIPPET =\n 'apply plugin: \"com.google.gms.google-services\" // Google Services plugin';\nexport const CIO_PROJECT_GOOGLE_SNIPPET =\n ' classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin';\n"],"mappings":"AAAA,OAAO,MAAMA,8BAA8B,GACzC,4CAA4C;AAC9C,OAAO,MAAMC,mBAAmB,GAAG,2CAA2C;AAC9E,OAAO,MAAMC,oBAAoB,GAC/B,4CAA4C;AAC9C,OAAO,MAAMC,6BAA6B,GACxC,kDAAkD;AAEpD,OAAO,MAAMC,8BAA8B,GACzC,kDAAkD;AACpD,OAAO,MAAMC,sBAAsB,GACjC,2EAA2E;AAC7E,OAAO,MAAMC,0BAA0B,GACrC,sFAAsF","ignoreList":[]}
1
+ {"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_APP_APPLY_REGEX","CIO_GIST_MAVEN_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","CIO_APP_GOOGLE_SNIPPET","CIO_PROJECT_GOOGLE_SNIPPET","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET"],"sources":["android.ts"],"sourcesContent":["export const CIO_PROJECT_BUILDSCRIPTS_REGEX =\n /(buildscript\\s*\\{(.|\\n)*dependencies\\s*\\{)/;\nexport const CIO_APP_APPLY_REGEX = /(apply plugin: \"com.android.application\")/;\nexport const CIO_GIST_MAVEN_REGEX =\n /maven { url \"https:\\/\\/maven.gist.build\" }/;\nexport const CIO_PROJECT_ALLPROJECTS_REGEX =\n /(allprojects\\s*\\{(.|\\n){1,500}repositories\\s*\\{)/;\n\nexport const CIO_PROJECT_GIST_MAVEN_SNIPPET =\n ' maven { url \"https://maven.gist.build\" }';\nexport const CIO_APP_GOOGLE_SNIPPET =\n 'apply plugin: \"com.google.gms.google-services\" // Google Services plugin';\nexport const CIO_PROJECT_GOOGLE_SNIPPET =\n ' classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin';\n\nexport const CIO_MAINAPPLICATION_ONCREATE_REGEX = /override\\s+fun\\s+onCreate\\s*\\(\\s*\\)\\s*\\{[\\s\\S]*?\\}/;\n// Actual method call, also used to detect if Customer.io auto initialization is already present\nexport const CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize(this)';\n// Complete code snippet to inject into MainActivity.onCreate()\nexport const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK\n ${CIO_NATIVE_SDK_INITIALIZE_CALL}`;\n"],"mappings":"AAAA,OAAO,MAAMA,8BAA8B,GACzC,4CAA4C;AAC9C,OAAO,MAAMC,mBAAmB,GAAG,2CAA2C;AAC9E,OAAO,MAAMC,oBAAoB,GAC/B,4CAA4C;AAC9C,OAAO,MAAMC,6BAA6B,GACxC,kDAAkD;AAEpD,OAAO,MAAMC,8BAA8B,GACzC,kDAAkD;AACpD,OAAO,MAAMC,sBAAsB,GACjC,2EAA2E;AAC7E,OAAO,MAAMC,0BAA0B,GACrC,sFAAsF;AAExF,OAAO,MAAMC,kCAAkC,GAAG,oDAAoD;AACtG;AACA,OAAO,MAAMC,8BAA8B,GAAG,2CAA2C;AACzF;AACA,OAAO,MAAMC,iCAAiC,GAAG;AACjD,MAAMD,8BAA8B,EAAE","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Platform constants for native SDK initialization
3
+ */
4
+ export const PLATFORM = {
5
+ IOS: 'ios',
6
+ ANDROID: 'android'
7
+ };
8
+
9
+ /**
10
+ * Platform type definition
11
+ */
12
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PLATFORM","IOS","ANDROID"],"sources":["common.ts"],"sourcesContent":["/**\n * Platform constants for native SDK initialization\n */\nexport const PLATFORM = {\n IOS: 'ios',\n ANDROID: 'android',\n} as const;\n\n/**\n * Platform type definition\n */\nexport type Platform = typeof PLATFORM[keyof typeof PLATFORM];\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAG;EACtBC,GAAG,EAAE,KAAK;EACVC,OAAO,EAAE;AACX,CAAU;;AAEV;AACA;AACA","ignoreList":[]}
@@ -1,11 +1,5 @@
1
- const finder = require('find-package-json');
2
1
  const path = require('path');
3
2
  const resolveFrom = require('resolve-from');
4
- const f = finder(__dirname);
5
- let pluginPackageRoot = f.next().filename;
6
- // This is the path to the root of the customerio-expo-plugin package
7
- pluginPackageRoot = path.dirname(pluginPackageRoot);
8
- export const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(pluginPackageRoot, 'plugin/src/helpers/native-files/ios');
9
3
  export function getRelativePathToRNSDK(iosPath) {
10
4
  // Root path of the Expo project
11
5
  const rootAppPath = path.dirname(iosPath);
@@ -135,4 +129,10 @@ export const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = `
135
129
  }
136
130
  }`;
137
131
  export const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = /\{\{REGISTER_SNIPPET\}\}/;
132
+ // Regex to match MessagingPush initialization in AppDelegate (different from NSE initialization)
133
+ export const CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX = /(MessagingPush(?:APN|FCM)\.initialize)/;
134
+ export const CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize()';
135
+ export const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK
136
+ ${CIO_NATIVE_SDK_INITIALIZE_CALL}
137
+ `;
138
138
  //# sourceMappingURL=ios.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["finder","require","path","resolveFrom","f","__dirname","pluginPackageRoot","next","filename","dirname","LOCAL_PATH_TO_CIO_NSE_FILES","join","getRelativePathToRNSDK","iosPath","rootAppPath","pluginPackageJsonPath","silent","relative","IOS_DEPLOYMENT_TARGET","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DEEPLINK_COMMENT_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_INITIALIZECIOSDK_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER"],"sources":["ios.ts"],"sourcesContent":["const finder = require('find-package-json');\nconst path = require('path');\nconst resolveFrom = require('resolve-from');\n\nconst f = finder(__dirname);\nlet pluginPackageRoot = f.next().filename;\n// This is the path to the root of the customerio-expo-plugin package\npluginPackageRoot = path.dirname(pluginPackageRoot);\n\nexport const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(\n pluginPackageRoot,\n 'plugin/src/helpers/native-files/ios'\n);\n\nexport function getRelativePathToRNSDK(iosPath: string) {\n // Root path of the Expo project\n const rootAppPath = path.dirname(iosPath);\n\n // Path of the cio RN package.json file. Example: test-app/node_modules/customerio-reactnative/package.json\n const pluginPackageJsonPath = resolveFrom.silent(rootAppPath, `customerio-reactnative/package.json`);\n\n // Example: ../node_modules/customerio-reactnative\n return path.relative(iosPath, path.dirname(pluginPackageJsonPath));\n}\n\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /.*\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /(@interface AppDelegate\\s*:\\s*EXAppDelegateWrapper\\s*)(<([^>]+)>)?/;\n\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*RCTBridge\\s*\\*\\s*\\w+\\s*=\\s*\\[\\s*self\\.reactDelegate\\s+createBridgeWithDelegate:self\\s+launchOptions:launchOptions\\s*\\];\\s*$/gm;\n\nexport const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*return\\s\\[\\s*super\\s*application:\\s*application\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\];/gm;\n\nexport const CIO_DEEPLINK_COMMENT_REGEX =\n /\\sDeep link workaround for app killed state start/gm;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';\n\nexport const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;\nexport const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET =\n 'UNUserNotificationCenterDelegate';\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n`;\n\nexport const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n`;\n\nexport const CIO_INITIALIZECIOSDK_SNIPPET = ` \n [pnHandlerObj initializeCioSdk];\n\n// Code to make the CIO SDK compatible with expo-notifications package.\n// \n// The CIO SDK and expo-notifications both need to handle when a push gets clicked. However, iOS only allows one click handler to be set per app.\n// To get around this limitation, we set the CIO SDK as the click handler. The CIO SDK sets itself up so that when another SDK or host iOS app \n// sets itself as the click handler, the CIO SDK will still be able to handle when the push gets clicked, even though it's not the designated \n// click handler in iOS at runtime. \n// \n// This should work for most SDKs. However, expo-notifications is unique in it's implementation. It will not setup push click handling it if detects \n// that another SDK or host iOS app has already set itself as the click handler:\n// https://github.com/expo/expo/blob/1b29637bec0b9888e8bc8c310476293a3e2d9786/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L31-L37\n// ...to get around this, we must manually set it as the click handler after the CIO SDK. That's what this code block does.\n//\n// Note: Initialize the native iOS SDK and setup SDK push click handling before running this code. \n# if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n // Creating a new instance, as the comments in expo-notifications suggests, does not work. With this code, if you send a CIO push to device and click on it,\n // no push metrics reporting will occur.\n // EXNotificationCenterDelegate *notificationCenterDelegate = [[EXNotificationCenterDelegate alloc] init];\n\n // ...instead, get the singleton reference from Expo. \n id<UNUserNotificationCenterDelegate> notificationCenterDelegate = (id<UNUserNotificationCenterDelegate>) [EXModuleRegistryProvider getSingletonModuleForClass:[EXNotificationCenterDelegate class]];\n UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];\n center.delegate = notificationCenterDelegate;\n# endif\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `\n// Deep link workaround for app killed state start\nNSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];\n if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {\n NSDictionary *pushContent = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];\n if (pushContent[@\"CIO\"] && pushContent[@\"CIO\"][@\"push\"] && pushContent[@\"CIO\"][@\"push\"][@\"link\"]) {\n NSString *initialURL = pushContent[@\"CIO\"][@\"push\"][@\"link\"];\n if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {\n modifiedLaunchOptions[UIApplicationLaunchOptionsURLKey] = [NSURL URLWithString:initialURL];\n }\n }\n }\n//Deep link workaround for app killed state ends\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = `\n // Deep link workaround for app killed state start\n var modifiedLaunchOptions = launchOptions\n if let launchOptions = launchOptions,\n let pushContent = launchOptions[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable: Any],\n let cio = pushContent[\"CIO\"] as? [String: Any],\n let push = cio[\"push\"] as? [String: Any],\n let link = push[\"link\"] as? String,\n !launchOptions.keys.contains(UIApplication.LaunchOptionsKey.url) {\n \n var mutableLaunchOptions = launchOptions\n mutableLaunchOptions[UIApplication.LaunchOptionsKey.url] = URL(string: link)\n modifiedLaunchOptions = mutableLaunchOptions\n }\n // Deep link workaround for app killed state ends\n`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `\n@objc(registerPushNotification)\n public func registerPushNotification() {\n\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = `\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = /\\{\\{REGISTER_SNIPPET\\}\\}/;"],"mappings":"AAAA,MAAMA,MAAM,GAAGC,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAMC,IAAI,GAAGD,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAME,WAAW,GAAGF,OAAO,CAAC,cAAc,CAAC;AAE3C,MAAMG,CAAC,GAAGJ,MAAM,CAACK,SAAS,CAAC;AAC3B,IAAIC,iBAAiB,GAAGF,CAAC,CAACG,IAAI,CAAC,CAAC,CAACC,QAAQ;AACzC;AACAF,iBAAiB,GAAGJ,IAAI,CAACO,OAAO,CAACH,iBAAiB,CAAC;AAEnD,OAAO,MAAMI,2BAA2B,GAAGR,IAAI,CAACS,IAAI,CAClDL,iBAAiB,EACjB,qCACF,CAAC;AAED,OAAO,SAASM,sBAAsBA,CAACC,OAAe,EAAE;EACtD;EACA,MAAMC,WAAW,GAAGZ,IAAI,CAACO,OAAO,CAACI,OAAO,CAAC;;EAEzC;EACA,MAAME,qBAAqB,GAAGZ,WAAW,CAACa,MAAM,CAACF,WAAW,EAAE,qCAAqC,CAAC;;EAEpG;EACA,OAAOZ,IAAI,CAACe,QAAQ,CAACJ,OAAO,EAAEX,IAAI,CAACO,OAAO,CAACM,qBAAqB,CAAC,CAAC;AACpE;AAEA,OAAO,MAAMG,qBAAqB,GAAG,MAAM;AAC3C,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,mCAAmC,GAAG,4BAA4B;AAC/E,OAAO,MAAMC,6BAA6B,GAAG,sBAAsB;AACnE,OAAO,MAAMC,kCAAkC,GAC7C,wFAAwF;AAE1F,OAAO,MAAMC,0DAA0D,GACrE,kGAAkG;AAEpG,OAAO,MAAMC,8DAA8D,GACzE,wJAAwJ;AAE1J,OAAO,MAAMC,0DAA0D,GACrE,wGAAwG;AAE1G,OAAO,MAAMC,gCAAgC,GAC3C,mCAAmC;AAErC,OAAO,MAAMC,2BAA2B,GACtC,oEAAoE;AAEtE,OAAO,MAAMC,4CAA4C,GACvD,mIAAmI;AAErI,OAAO,MAAMC,gDAAgD,GAC3D,iHAAiH;AAEnH,OAAO,MAAMC,0BAA0B,GACrC,qDAAqD;AACvD,OAAO,MAAMC,sBAAsB,GAAG,GAAG;AACzC,OAAO,MAAMC,4BAA4B,GAAG,KAAK;AACjD,OAAO,MAAMC,eAAe,GAAG,eAAe;AAC9C,OAAO,MAAMC,4BAA4B,GAAG,qBAAqB;AAEjE,OAAO,MAAMC,oCAAoC,GAAG,iDAAiD;AACrG,OAAO,MAAMC,sDAAsD,GACjE,kCAAkC;AACpC,OAAO,MAAMC,8CAA8C,GAAG;AAC9D;AACA,CAAC;AACD,OAAO,MAAMC,8CAA8C,GAAG;AAC9D;AACA,CAAC;AAED,OAAO,MAAMC,yCAAyC,GAAG;AACzD,4FAA4F;AAE5F,OAAO,MAAMC,4DAA4D,GAAG;AAC5E;AACA;AACA,CAAC;AAED,OAAO,MAAMC,4DAA4D,GAAG;AAC5E;AACA;AACA,CAAC;AAED,OAAO,MAAMC,2CAA2C,GAAG;AAC3D;AACA;AACA,CAAC;AAED,OAAO,MAAMC,4BAA4B,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,yCAAyC,GAAG;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,+CAA+C,GAAG;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,qCAAqC,GAAG;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AAEJ,OAAO,MAAMC,wCAAwC,GAAG;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AAEN,OAAO,MAAMC,0CAA0C,GAAG,0BAA0B","ignoreList":[]}
1
+ {"version":3,"names":["path","require","resolveFrom","getRelativePathToRNSDK","iosPath","rootAppPath","dirname","pluginPackageJsonPath","silent","relative","IOS_DEPLOYMENT_TARGET","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DEEPLINK_COMMENT_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_INITIALIZECIOSDK_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["const path = require('path');\nconst resolveFrom = require('resolve-from');\n\nexport function getRelativePathToRNSDK(iosPath: string) {\n // Root path of the Expo project\n const rootAppPath = path.dirname(iosPath);\n\n // Path of the cio RN package.json file. Example: test-app/node_modules/customerio-reactnative/package.json\n const pluginPackageJsonPath = resolveFrom.silent(\n rootAppPath,\n `customerio-reactnative/package.json`\n );\n\n // Example: ../node_modules/customerio-reactnative\n return path.relative(iosPath, path.dirname(pluginPackageJsonPath));\n}\n\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /.*\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /(@interface AppDelegate\\s*:\\s*EXAppDelegateWrapper\\s*)(<([^>]+)>)?/;\n\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*RCTBridge\\s*\\*\\s*\\w+\\s*=\\s*\\[\\s*self\\.reactDelegate\\s+createBridgeWithDelegate:self\\s+launchOptions:launchOptions\\s*\\];\\s*$/gm;\n\nexport const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*return\\s\\[\\s*super\\s*application:\\s*application\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\];/gm;\n\nexport const CIO_DEEPLINK_COMMENT_REGEX =\n /\\sDeep link workaround for app killed state start/gm;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';\n\nexport const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;\nexport const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET =\n 'UNUserNotificationCenterDelegate';\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n`;\n\nexport const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n`;\n\nexport const CIO_INITIALIZECIOSDK_SNIPPET = ` \n [pnHandlerObj initializeCioSdk];\n\n// Code to make the CIO SDK compatible with expo-notifications package.\n// \n// The CIO SDK and expo-notifications both need to handle when a push gets clicked. However, iOS only allows one click handler to be set per app.\n// To get around this limitation, we set the CIO SDK as the click handler. The CIO SDK sets itself up so that when another SDK or host iOS app \n// sets itself as the click handler, the CIO SDK will still be able to handle when the push gets clicked, even though it's not the designated \n// click handler in iOS at runtime. \n// \n// This should work for most SDKs. However, expo-notifications is unique in it's implementation. It will not setup push click handling it if detects \n// that another SDK or host iOS app has already set itself as the click handler:\n// https://github.com/expo/expo/blob/1b29637bec0b9888e8bc8c310476293a3e2d9786/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L31-L37\n// ...to get around this, we must manually set it as the click handler after the CIO SDK. That's what this code block does.\n//\n// Note: Initialize the native iOS SDK and setup SDK push click handling before running this code. \n# if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n // Creating a new instance, as the comments in expo-notifications suggests, does not work. With this code, if you send a CIO push to device and click on it,\n // no push metrics reporting will occur.\n // EXNotificationCenterDelegate *notificationCenterDelegate = [[EXNotificationCenterDelegate alloc] init];\n\n // ...instead, get the singleton reference from Expo. \n id<UNUserNotificationCenterDelegate> notificationCenterDelegate = (id<UNUserNotificationCenterDelegate>) [EXModuleRegistryProvider getSingletonModuleForClass:[EXNotificationCenterDelegate class]];\n UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];\n center.delegate = notificationCenterDelegate;\n# endif\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `\n// Deep link workaround for app killed state start\nNSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];\n if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {\n NSDictionary *pushContent = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];\n if (pushContent[@\"CIO\"] && pushContent[@\"CIO\"][@\"push\"] && pushContent[@\"CIO\"][@\"push\"][@\"link\"]) {\n NSString *initialURL = pushContent[@\"CIO\"][@\"push\"][@\"link\"];\n if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {\n modifiedLaunchOptions[UIApplicationLaunchOptionsURLKey] = [NSURL URLWithString:initialURL];\n }\n }\n }\n//Deep link workaround for app killed state ends\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = `\n // Deep link workaround for app killed state start\n var modifiedLaunchOptions = launchOptions\n if let launchOptions = launchOptions,\n let pushContent = launchOptions[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable: Any],\n let cio = pushContent[\"CIO\"] as? [String: Any],\n let push = cio[\"push\"] as? [String: Any],\n let link = push[\"link\"] as? String,\n !launchOptions.keys.contains(UIApplication.LaunchOptionsKey.url) {\n \n var mutableLaunchOptions = launchOptions\n mutableLaunchOptions[UIApplication.LaunchOptionsKey.url] = URL(string: link)\n modifiedLaunchOptions = mutableLaunchOptions\n }\n // Deep link workaround for app killed state ends\n`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `\n@objc(registerPushNotification)\n public func registerPushNotification() {\n\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = `\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n// Regex to match MessagingPush initialization in AppDelegate (different from NSE initialization)\nexport const CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX = /(MessagingPush(?:APN|FCM)\\.initialize)/;\nexport const CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize()';\nexport const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK\n ${CIO_NATIVE_SDK_INITIALIZE_CALL}\n `;\n"],"mappings":"AAAA,MAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAMC,WAAW,GAAGD,OAAO,CAAC,cAAc,CAAC;AAE3C,OAAO,SAASE,sBAAsBA,CAACC,OAAe,EAAE;EACtD;EACA,MAAMC,WAAW,GAAGL,IAAI,CAACM,OAAO,CAACF,OAAO,CAAC;;EAEzC;EACA,MAAMG,qBAAqB,GAAGL,WAAW,CAACM,MAAM,CAC9CH,WAAW,EACX,qCACF,CAAC;;EAED;EACA,OAAOL,IAAI,CAACS,QAAQ,CAACL,OAAO,EAAEJ,IAAI,CAACM,OAAO,CAACC,qBAAqB,CAAC,CAAC;AACpE;AAEA,OAAO,MAAMG,qBAAqB,GAAG,MAAM;AAC3C,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,mCAAmC,GAAG,4BAA4B;AAC/E,OAAO,MAAMC,6BAA6B,GAAG,sBAAsB;AACnE,OAAO,MAAMC,kCAAkC,GAC7C,wFAAwF;AAE1F,OAAO,MAAMC,0DAA0D,GACrE,kGAAkG;AAEpG,OAAO,MAAMC,8DAA8D,GACzE,wJAAwJ;AAE1J,OAAO,MAAMC,0DAA0D,GACrE,wGAAwG;AAE1G,OAAO,MAAMC,gCAAgC,GAC3C,mCAAmC;AAErC,OAAO,MAAMC,2BAA2B,GACtC,oEAAoE;AAEtE,OAAO,MAAMC,4CAA4C,GACvD,mIAAmI;AAErI,OAAO,MAAMC,gDAAgD,GAC3D,iHAAiH;AAEnH,OAAO,MAAMC,0BAA0B,GACrC,qDAAqD;AACvD,OAAO,MAAMC,sBAAsB,GAAG,GAAG;AACzC,OAAO,MAAMC,4BAA4B,GAAG,KAAK;AACjD,OAAO,MAAMC,eAAe,GAAG,eAAe;AAC9C,OAAO,MAAMC,4BAA4B,GAAG,qBAAqB;AAEjE,OAAO,MAAMC,oCAAoC,GAAG,iDAAiD;AACrG,OAAO,MAAMC,sDAAsD,GACjE,kCAAkC;AACpC,OAAO,MAAMC,8CAA8C,GAAG;AAC9D;AACA,CAAC;AACD,OAAO,MAAMC,8CAA8C,GAAG;AAC9D;AACA,CAAC;AAED,OAAO,MAAMC,yCAAyC,GAAG;AACzD,4FAA4F;AAE5F,OAAO,MAAMC,4DAA4D,GAAG;AAC5E;AACA;AACA,CAAC;AAED,OAAO,MAAMC,4DAA4D,GAAG;AAC5E;AACA;AACA,CAAC;AAED,OAAO,MAAMC,2CAA2C,GAAG;AAC3D;AACA;AACA,CAAC;AAED,OAAO,MAAMC,4BAA4B,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,yCAAyC,GAAG;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,+CAA+C,GAAG;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,qCAAqC,GAAG;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AAEJ,OAAO,MAAMC,wCAAwC,GAAG;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AAEN,OAAO,MAAMC,0CAA0C,GAAG,0BAA0B;AACpF;AACA,OAAO,MAAMC,0CAA0C,GAAG,wCAAwC;AAClG,OAAO,MAAMC,8BAA8B,GAAG,uCAAuC;AACrF,OAAO,MAAMC,iCAAiC,GAAG;AACjD,MAAMD,8BAA8B;AACpC,KAAK","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ package io.customer.sdk.expo
2
+
3
+ import android.app.Application
4
+ import io.customer.datapipelines.config.ScreenView
5
+ import io.customer.messaginginapp.MessagingInAppModuleConfig
6
+ import io.customer.messaginginapp.ModuleMessagingInApp
7
+ import io.customer.messagingpush.MessagingPushModuleConfig
8
+ import io.customer.messagingpush.ModuleMessagingPushFCM
9
+ import io.customer.reactnative.sdk.messaginginapp.ReactInAppEventListener
10
+ import io.customer.sdk.CustomerIOBuilder
11
+ import io.customer.sdk.core.util.CioLogLevel
12
+ import io.customer.sdk.data.model.Region
13
+
14
+ object CustomerIOSDKInitializer {
15
+ fun initialize(application: Application) = with(
16
+ CustomerIOBuilder(application, "{{CDP_API_KEY}}")
17
+ ) {
18
+ val siteId: String? = {{SITE_ID}}
19
+ val migrationSiteId: String? = {{MIGRATION_SITE_ID}}
20
+ val region = Region.getRegion({{REGION}})
21
+
22
+ setIfDefined({{LOG_LEVEL}}, CustomerIOBuilder::logLevel) { CioLogLevel.getLogLevel(it) }
23
+ setIfDefined(region, CustomerIOBuilder::region)
24
+ setIfDefined({{AUTO_TRACK_DEVICE_ATTRIBUTES}}, CustomerIOBuilder::autoTrackDeviceAttributes)
25
+ setIfDefined({{TRACK_APPLICATION_LIFECYCLE_EVENTS}}, CustomerIOBuilder::trackApplicationLifecycleEvents)
26
+ setIfDefined({{SCREEN_VIEW_USE}}, CustomerIOBuilder::screenViewUse) { ScreenView.getScreenView(it) }
27
+ setIfDefined(migrationSiteId, CustomerIOBuilder::migrationSiteId)
28
+
29
+ // Add messaging modules if siteId is provided
30
+ if (!(siteId.isNullOrBlank())) {
31
+ addCustomerIOModule(
32
+ ModuleMessagingInApp(
33
+ MessagingInAppModuleConfig.Builder(siteId, region)
34
+ .setEventListener(ReactInAppEventListener())
35
+ .build()
36
+ )
37
+ )
38
+ }
39
+ addCustomerIOModule(
40
+ ModuleMessagingPushFCM(
41
+ MessagingPushModuleConfig.Builder().build()
42
+ )
43
+ )
44
+
45
+ build()
46
+ }
47
+ }
48
+
49
+ // Apply a value after transforming it, only if both the original and transformed values are non-nil
50
+ private inline fun <R, T> CustomerIOBuilder.setIfDefined(
51
+ value: R?,
52
+ block: CustomerIOBuilder.(T) -> CustomerIOBuilder,
53
+ transform: (R) -> T,
54
+ ): CustomerIOBuilder = value?.let { block(transform(it)) } ?: this
55
+
56
+ // Apply a value to a setter only if it's non-nil
57
+ private inline fun <T> CustomerIOBuilder.setIfDefined(
58
+ value: T?,
59
+ block: CustomerIOBuilder.(T) -> CustomerIOBuilder,
60
+ ): CustomerIOBuilder = setIfDefined(
61
+ value = value,
62
+ block = block,
63
+ transform = { it },
64
+ )
@@ -0,0 +1,54 @@
1
+ import CioDataPipelines
2
+ import CioInternalCommon
3
+ import CioMessagingInApp
4
+ import customerio_reactnative
5
+
6
+ class CustomerIOSDKInitializer {
7
+ static func initialize() {
8
+ // Override SDK client info to include Expo metadata in user agent
9
+ let pluginVersion = "{{EXPO_PLUGIN_VERSION}}"
10
+ DIGraphShared.shared.override(
11
+ value: CustomerIOSdkClient(source: "Expo", sdkVersion: pluginVersion),
12
+ forType: SdkClient.self
13
+ )
14
+
15
+ let cdpApiKey = "{{CDP_API_KEY}}"
16
+ let siteId: String? = {{SITE_ID}}
17
+ let region = CioInternalCommon.Region.getRegion(from: {{REGION}})
18
+
19
+ let builder = SDKConfigBuilder(cdpApiKey: cdpApiKey)
20
+ setIfDefined(value: {{LOG_LEVEL}}, thenPassItTo: builder.logLevel, transformingBy: CioLogLevel.getLogLevel)
21
+ setIfDefined(value: region, thenPassItTo: builder.region)
22
+ setIfDefined(value: {{AUTO_TRACK_DEVICE_ATTRIBUTES}}, thenPassItTo: builder.autoTrackDeviceAttributes)
23
+ setIfDefined(value: {{TRACK_APPLICATION_LIFECYCLE_EVENTS}}, thenPassItTo: builder.trackApplicationLifecycleEvents)
24
+ setIfDefined(value: {{SCREEN_VIEW_USE}}, thenPassItTo: builder.screenViewUse) { ScreenView.getScreenView($0) }
25
+ setIfDefined(value: {{MIGRATION_SITE_ID}}, thenPassItTo: builder.migrationSiteId)
26
+
27
+ CustomerIO.initialize(withConfig: builder.build())
28
+
29
+ if let siteId = siteId {
30
+ let inAppConfig = MessagingInAppConfigBuilder(siteId: siteId, region: region).build()
31
+ MessagingInApp.initialize(withConfig: inAppConfig)
32
+ MessagingInApp.shared.setEventListener(ReactInAppEventListener.shared)
33
+ }
34
+ }
35
+
36
+ /// Apply a value to a setter only if it's non-nil
37
+ private static func setIfDefined<Raw>(
38
+ value rawValue: Raw?,
39
+ thenPassItTo handler: (Raw) -> Any
40
+ ) {
41
+ setIfDefined(value: rawValue, thenPassItTo: handler) { $0 }
42
+ }
43
+
44
+ /// Apply a value after transforming it, only if both the original and transformed values are non-nil
45
+ private static func setIfDefined<Raw, Transformed>(
46
+ value rawValue: Raw?,
47
+ thenPassItTo handler: (Transformed) -> Any,
48
+ transformingBy transform: (Raw) -> Transformed?
49
+ ) {
50
+ if let value = rawValue, let result = transform(value) {
51
+ _ = handler(result)
52
+ }
53
+ }
54
+ }
@@ -14,7 +14,7 @@ export async function injectCIOPodfileCode(iosPath, isFcmPushProvider) {
14
14
  const lineInPodfileToInjectSnippetBefore = /post_install do \|installer\|/;
15
15
  const snippetToInjectInPodfile = `
16
16
  ${blockStart}
17
- pod 'customerio-reactnative/${isFcmPushProvider ? "fcm" : "apn"}', :path => '${getRelativePathToRNSDK(iosPath)}'
17
+ pod 'customerio-reactnative/${isFcmPushProvider ? 'fcm' : 'apn'}', :path => '${getRelativePathToRNSDK(iosPath)}'
18
18
  ${blockEnd}
19
19
  `.trim();
20
20
  FileManagement.write(filename, injectCodeByRegex(podfile, lineInPodfileToInjectSnippetBefore, snippetToInjectInPodfile).join('\n'));
@@ -33,7 +33,7 @@ export async function injectCIONotificationPodfileCode(iosPath, useFrameworks, i
33
33
  ${blockStart}
34
34
  target 'NotificationService' do
35
35
  ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}
36
- pod 'customerio-reactnative-richpush/${isFcmPushProvider ? "fcm" : "apn"}', :path => '${getRelativePathToRNSDK(iosPath)}'
36
+ pod 'customerio-reactnative-richpush/${isFcmPushProvider ? 'fcm' : 'apn'}', :path => '${getRelativePathToRNSDK(iosPath)}'
37
37
  end
38
38
  ${blockEnd}
39
39
  `.trim();
@@ -1 +1 @@
1
- {"version":3,"names":["getRelativePathToRNSDK","injectCodeByRegex","FileManagement","injectCIOPodfileCode","iosPath","isFcmPushProvider","blockStart","blockEnd","filename","podfile","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","trim","write","join","console","log","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string, isFcmPushProvider: boolean) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const snippetToInjectInPodfile = `\n${blockStart}\n pod 'customerio-reactnative/${isFcmPushProvider ? \"fcm\" : \"apn\"}', :path => '${getRelativePathToRNSDK(\n iosPath\n )}'\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n console.log('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],\n isFcmPushProvider: boolean\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/${isFcmPushProvider ? \"fcm\" : \"apn\"}', :path => '${getRelativePathToRNSDK(\n iosPath\n )}'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,OAAO,eAAeC,oBAAoBA,CAACC,OAAe,EAAEC,iBAA0B,EAAE;EACtF,MAAMC,UAAU,GAAG,qCAAqC;EACxD,MAAMC,QAAQ,GAAG,mCAAmC;EAEpD,MAAMC,QAAQ,GAAG,GAAGJ,OAAO,UAAU;EACrC,MAAMK,OAAO,GAAG,MAAMP,cAAc,CAACQ,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,IAAIC,MAAM,CAACP,UAAU,CAAC,CAAC;EAErD,IAAI,CAACK,OAAO,EAAE;IACZ;IACA;IACA;IACA,MAAMG,kCAAkC,GAAG,+BAA+B;IAE1E,MAAMC,wBAAwB,GAAG;AACrC,EAAET,UAAU;AACZ,gCAAgCD,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBAAgBL,sBAAsB,CACnGI,OACF,CAAC;AACH,EAAEG,QAAQ;AACV,CAAC,CAACS,IAAI,CAAC,CAAC;IAEJd,cAAc,CAACe,KAAK,CAClBT,QAAQ,EACRP,iBAAiB,CACfQ,OAAO,EACPK,kCAAkC,EAClCC,wBACF,CAAC,CAACG,IAAI,CAAC,IAAI,CACb,CAAC;EACH,CAAC,MAAM;IACLC,OAAO,CAACC,GAAG,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEA,OAAO,eAAeC,gCAAgCA,CACpDjB,OAAe,EACfkB,aAA0D,EAC1DjB,iBAA0B,EAC1B;EACA,MAAMG,QAAQ,GAAG,GAAGJ,OAAO,UAAU;EACrC,MAAMK,OAAO,GAAG,MAAMP,cAAc,CAACQ,IAAI,CAACF,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMI,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,IAAIC,MAAM,CAACP,UAAU,CAAC,CAAC;EAErD,IAAI,CAACK,OAAO,EAAE;IACZ,MAAMI,wBAAwB,GAAG;AACrC,EAAET,UAAU;AACZ;AACA,IAAIgB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyCjB,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBAAgBL,sBAAsB,CAC5GI,OACF,CAAC;AACH;AACA,EAAEG,QAAQ;AACV,CAAC,CAACS,IAAI,CAAC,CAAC;IAEJd,cAAc,CAACqB,MAAM,CAACf,QAAQ,EAAEO,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
1
+ {"version":3,"names":["getRelativePathToRNSDK","injectCodeByRegex","FileManagement","injectCIOPodfileCode","iosPath","isFcmPushProvider","blockStart","blockEnd","filename","podfile","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","trim","write","join","console","log","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(\n iosPath: string,\n isFcmPushProvider: boolean\n) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const snippetToInjectInPodfile = `\n${blockStart}\n pod 'customerio-reactnative/${isFcmPushProvider ? 'fcm' : 'apn'\n }', :path => '${getRelativePathToRNSDK(iosPath)}'\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n console.log('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],\n isFcmPushProvider: boolean\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/${isFcmPushProvider ? 'fcm' : 'apn'\n }', :path => '${getRelativePathToRNSDK(iosPath)}'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,OAAO,eAAeC,oBAAoBA,CACxCC,OAAe,EACfC,iBAA0B,EAC1B;EACA,MAAMC,UAAU,GAAG,qCAAqC;EACxD,MAAMC,QAAQ,GAAG,mCAAmC;EAEpD,MAAMC,QAAQ,GAAG,GAAGJ,OAAO,UAAU;EACrC,MAAMK,OAAO,GAAG,MAAMP,cAAc,CAACQ,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,IAAIC,MAAM,CAACP,UAAU,CAAC,CAAC;EAErD,IAAI,CAACK,OAAO,EAAE;IACZ;IACA;IACA;IACA,MAAMG,kCAAkC,GAAG,+BAA+B;IAE1E,MAAMC,wBAAwB,GAAG;AACrC,EAAET,UAAU;AACZ,gCAAgCD,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBAC3CL,sBAAsB,CAACI,OAAO,CAAC;AACrD,EAAEG,QAAQ;AACV,CAAC,CAACS,IAAI,CAAC,CAAC;IAEJd,cAAc,CAACe,KAAK,CAClBT,QAAQ,EACRP,iBAAiB,CACfQ,OAAO,EACPK,kCAAkC,EAClCC,wBACF,CAAC,CAACG,IAAI,CAAC,IAAI,CACb,CAAC;EACH,CAAC,MAAM;IACLC,OAAO,CAACC,GAAG,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEA,OAAO,eAAeC,gCAAgCA,CACpDjB,OAAe,EACfkB,aAA0D,EAC1DjB,iBAA0B,EAC1B;EACA,MAAMG,QAAQ,GAAG,GAAGJ,OAAO,UAAU;EACrC,MAAMK,OAAO,GAAG,MAAMP,cAAc,CAACQ,IAAI,CAACF,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMI,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,IAAIC,MAAM,CAACP,UAAU,CAAC,CAAC;EAErD,IAAI,CAACK,OAAO,EAAE;IACZ,MAAMI,wBAAwB,GAAG;AACrC,EAAET,UAAU;AACZ;AACA,IAAIgB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyCjB,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBACpDL,sBAAsB,CAACI,OAAO,CAAC;AACrD;AACA,EAAEG,QAAQ;AACV,CAAC,CAACS,IAAI,CAAC,CAAC;IAEJd,cAAc,CAACqB,MAAM,CAACf,QAAQ,EAAEO,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
@@ -0,0 +1,57 @@
1
+ import { PLATFORM } from '../constants/common';
2
+ import { getPluginVersion } from '../../utils/plugin';
3
+
4
+ /**
5
+ * Shared utility function to perform common SDK config replacements
6
+ * for both iOS and Android template files
7
+ */
8
+ export function patchNativeSDKInitializer(rawContent, platform, sdkConfig) {
9
+ var _siteId, _migrationSiteId;
10
+ let content = rawContent;
11
+
12
+ // Helper function to replace placeholders with platform-specific fallback values
13
+ const replaceValue = (placeholder, value, transform, fallback = platform === PLATFORM.ANDROID ? 'null' : 'nil') => {
14
+ if (value !== undefined && value !== null) {
15
+ content = content.replace(placeholder, transform(value));
16
+ } else {
17
+ content = content.replace(placeholder, fallback);
18
+ }
19
+ };
20
+
21
+ // Replace EXPO_PLUGIN_VERSION with actual plugin version
22
+ const pluginVersion = getPluginVersion();
23
+ content = content.replace(/\{\{EXPO_PLUGIN_VERSION\}\}/g, pluginVersion);
24
+
25
+ // Replace CDP API Key (required field)
26
+ content = content.replace(/\{\{CDP_API_KEY\}\}/g, sdkConfig.cdpApiKey);
27
+
28
+ // Handle region - use empty string as fallback (nil not supported for region)
29
+ replaceValue(/\{\{REGION\}\}/g, sdkConfig.region, configValue => `"${configValue}"`, '""');
30
+
31
+ // Handle logLevel - use nil/null as fallback
32
+ replaceValue(/\{\{LOG_LEVEL\}\}/g, sdkConfig.logLevel, configValue => `"${configValue}"`);
33
+
34
+ // Handle optional boolean configurations
35
+ replaceValue(/\{\{AUTO_TRACK_DEVICE_ATTRIBUTES\}\}/g, sdkConfig.autoTrackDeviceAttributes, configValue => configValue.toString());
36
+ replaceValue(/\{\{TRACK_APPLICATION_LIFECYCLE_EVENTS\}\}/g, sdkConfig.trackApplicationLifecycleEvents, configValue => configValue.toString());
37
+
38
+ // Handle screenViewUse - use nil/null as fallback
39
+ replaceValue(/\{\{SCREEN_VIEW_USE\}\}/g, sdkConfig.screenViewUse, configValue => `"${configValue}"`);
40
+
41
+ // Handle siteId/migrationSiteId business logic
42
+ let siteId = sdkConfig.siteId;
43
+ let migrationSiteId = sdkConfig.migrationSiteId;
44
+
45
+ // Business rule: if only siteId provided, copy to migrationSiteId; if only migrationSiteId provided, set siteId to undefined
46
+ if (siteId && !migrationSiteId) {
47
+ migrationSiteId = siteId;
48
+ } else if (migrationSiteId && !siteId) {
49
+ siteId = undefined;
50
+ }
51
+
52
+ // Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)
53
+ replaceValue(/\{\{SITE_ID\}\}/g, ((_siteId = siteId) === null || _siteId === void 0 ? void 0 : _siteId.trim()) || undefined, configValue => `"${configValue}"`);
54
+ replaceValue(/\{\{MIGRATION_SITE_ID\}\}/g, ((_migrationSiteId = migrationSiteId) === null || _migrationSiteId === void 0 ? void 0 : _migrationSiteId.trim()) || undefined, configValue => `"${configValue}"`);
55
+ return content;
56
+ }
57
+ //# sourceMappingURL=patchPluginNativeCode.js.map