customerio-expo-plugin 1.0.0-beta.9 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/README.md +8 -5
  2. package/package.json +32 -24
  3. package/plugin/app.plugin.js +1 -0
  4. package/{lib → plugin/lib}/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
  5. package/{lib → plugin/lib}/commonjs/android/withAppGoogleServices.js.map +1 -1
  6. package/{lib → plugin/lib}/commonjs/android/withCIOAndroid.js +2 -0
  7. package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -0
  8. package/{lib → plugin/lib}/commonjs/android/withGistMavenRepository.js.map +1 -1
  9. package/{lib → plugin/lib}/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  10. package/{lib → plugin/lib}/commonjs/android/withProjectGoogleServices.js.map +1 -1
  11. package/plugin/lib/commonjs/android/withProjectStrings.js +70 -0
  12. package/plugin/lib/commonjs/android/withProjectStrings.js.map +1 -0
  13. package/plugin/lib/commonjs/helpers/constants/android.js +14 -0
  14. package/{lib → plugin/lib}/commonjs/helpers/constants/android.js.map +1 -1
  15. package/{lib → plugin/lib}/commonjs/helpers/constants/globals.d.js.map +1 -1
  16. package/plugin/lib/commonjs/helpers/constants/ios.js +119 -0
  17. package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -0
  18. package/plugin/lib/commonjs/helpers/native-files/ios/apn/NotificationService.swift +25 -0
  19. package/{src/helpers/native-files/ios → plugin/lib/commonjs/helpers/native-files/ios/apn}/PushService.swift +11 -13
  20. package/plugin/lib/commonjs/helpers/native-files/ios/common/Env.swift +7 -0
  21. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
  22. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/PushService.swift +59 -0
  23. package/{lib → plugin/lib}/commonjs/helpers/utils/codeInjection.js +9 -1
  24. package/plugin/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
  25. package/{lib → plugin/lib}/commonjs/helpers/utils/fileManagement.js.map +1 -1
  26. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +50 -0
  27. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  28. package/plugin/lib/commonjs/helpers/utils/pluginUtils.js +26 -0
  29. package/plugin/lib/commonjs/helpers/utils/pluginUtils.js.map +1 -0
  30. package/{lib → plugin/lib}/commonjs/index.js +1 -2
  31. package/{lib → plugin/lib}/commonjs/index.js.map +1 -1
  32. package/plugin/lib/commonjs/ios/utils.js +17 -0
  33. package/plugin/lib/commonjs/ios/utils.js.map +1 -0
  34. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +151 -0
  35. package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
  36. package/{lib → plugin/lib}/commonjs/ios/withCIOIos.js +2 -0
  37. package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -0
  38. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +68 -0
  39. package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -0
  40. package/{lib → plugin/lib}/commonjs/ios/withNotificationsXcodeProject.js +59 -45
  41. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
  42. package/{lib → plugin/lib}/commonjs/ios/withXcodeProject.js +2 -1
  43. package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -0
  44. package/{lib → plugin/lib}/commonjs/postInstall.js.map +1 -1
  45. package/plugin/lib/commonjs/postInstallHelper.js +22 -0
  46. package/plugin/lib/commonjs/postInstallHelper.js.map +1 -0
  47. package/plugin/lib/commonjs/types/cio-types.js.map +1 -0
  48. package/{lib → plugin/lib}/module/android/withAndroidManifestUpdates.js.map +1 -1
  49. package/{lib → plugin/lib}/module/android/withAppGoogleServices.js.map +1 -1
  50. package/{lib → plugin/lib}/module/android/withCIOAndroid.js +2 -0
  51. package/plugin/lib/module/android/withCIOAndroid.js.map +1 -0
  52. package/{lib → plugin/lib}/module/android/withGistMavenRepository.js.map +1 -1
  53. package/{lib → plugin/lib}/module/android/withGoogleServicesJSON.js.map +1 -1
  54. package/{lib → plugin/lib}/module/android/withProjectGoogleServices.js.map +1 -1
  55. package/plugin/lib/module/android/withProjectStrings.js +63 -0
  56. package/plugin/lib/module/android/withProjectStrings.js.map +1 -0
  57. package/{lib → plugin/lib}/module/helpers/constants/android.js.map +1 -1
  58. package/{lib → plugin/lib}/module/helpers/constants/globals.d.js.map +1 -1
  59. package/plugin/lib/module/helpers/constants/ios.js +112 -0
  60. package/plugin/lib/module/helpers/constants/ios.js.map +1 -0
  61. package/plugin/lib/module/helpers/native-files/ios/apn/NotificationService.swift +25 -0
  62. package/{lib/commonjs/helpers/native-files/ios → plugin/lib/module/helpers/native-files/ios/apn}/PushService.swift +11 -13
  63. package/plugin/lib/module/helpers/native-files/ios/common/Env.swift +7 -0
  64. package/plugin/lib/module/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
  65. package/plugin/lib/module/helpers/native-files/ios/fcm/PushService.swift +59 -0
  66. package/{lib → plugin/lib}/module/helpers/utils/codeInjection.js +7 -1
  67. package/plugin/lib/module/helpers/utils/codeInjection.js.map +1 -0
  68. package/{lib → plugin/lib}/module/helpers/utils/fileManagement.js.map +1 -1
  69. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +43 -0
  70. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  71. package/plugin/lib/module/helpers/utils/pluginUtils.js +19 -0
  72. package/plugin/lib/module/helpers/utils/pluginUtils.js.map +1 -0
  73. package/{lib → plugin/lib}/module/index.js.map +1 -1
  74. package/plugin/lib/module/ios/utils.js +10 -0
  75. package/plugin/lib/module/ios/utils.js.map +1 -0
  76. package/plugin/lib/module/ios/withAppDelegateModifications.js +144 -0
  77. package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -0
  78. package/{lib → plugin/lib}/module/ios/withCIOIos.js +2 -0
  79. package/plugin/lib/module/ios/withCIOIos.js.map +1 -0
  80. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +61 -0
  81. package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -0
  82. package/{lib → plugin/lib}/module/ios/withNotificationsXcodeProject.js +59 -44
  83. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
  84. package/{lib → plugin/lib}/module/ios/withXcodeProject.js +2 -1
  85. package/plugin/lib/module/ios/withXcodeProject.js.map +1 -0
  86. package/{lib → plugin/lib}/module/postInstall.js.map +1 -1
  87. package/plugin/lib/module/postInstallHelper.js +20 -0
  88. package/plugin/lib/module/postInstallHelper.js.map +1 -0
  89. package/plugin/lib/module/types/cio-types.js.map +1 -0
  90. package/plugin/lib/typescript/android/withProjectStrings.d.ts +15 -0
  91. package/plugin/lib/typescript/helpers/constants/ios.d.ts +30 -0
  92. package/{lib → plugin/lib}/typescript/helpers/utils/codeInjection.d.ts +3 -1
  93. package/{lib → plugin/lib}/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -2
  94. package/plugin/lib/typescript/helpers/utils/pluginUtils.d.ts +4 -0
  95. package/plugin/lib/typescript/ios/utils.d.ts +7 -0
  96. package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +3 -0
  97. package/{lib → plugin/lib}/typescript/types/cio-types.d.ts +11 -2
  98. package/{src → plugin/src}/android/withCIOAndroid.ts +2 -0
  99. package/plugin/src/android/withProjectStrings.ts +57 -0
  100. package/plugin/src/helpers/constants/ios.ts +144 -0
  101. package/plugin/src/helpers/native-files/ios/apn/NotificationService.swift +25 -0
  102. package/{lib/module/helpers/native-files/ios → plugin/src/helpers/native-files/ios/apn}/PushService.swift +11 -13
  103. package/plugin/src/helpers/native-files/ios/common/Env.swift +7 -0
  104. package/plugin/src/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
  105. package/plugin/src/helpers/native-files/ios/fcm/PushService.swift +59 -0
  106. package/{src → plugin/src}/helpers/utils/codeInjection.ts +12 -1
  107. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +68 -0
  108. package/plugin/src/helpers/utils/pluginUtils.ts +22 -0
  109. package/plugin/src/ios/utils.ts +10 -0
  110. package/{src → plugin/src}/ios/withAppDelegateModifications.ts +133 -23
  111. package/{src → plugin/src}/ios/withCIOIos.ts +2 -0
  112. package/plugin/src/ios/withGoogleServicesJsonFile.ts +97 -0
  113. package/{src → plugin/src}/ios/withNotificationsXcodeProject.ts +97 -47
  114. package/{src → plugin/src}/ios/withXcodeProject.ts +2 -1
  115. package/plugin/src/postInstallHelper.js +32 -0
  116. package/{src → plugin/src}/types/cio-types.ts +11 -2
  117. package/lib/commonjs/android/withCIOAndroid.js.map +0 -1
  118. package/lib/commonjs/helpers/constants/android.js +0 -21
  119. package/lib/commonjs/helpers/constants/ios.js +0 -121
  120. package/lib/commonjs/helpers/constants/ios.js.map +0 -1
  121. package/lib/commonjs/helpers/native-files/ios/Env.swift +0 -8
  122. package/lib/commonjs/helpers/native-files/ios/NotificationService.swift +0 -22
  123. package/lib/commonjs/helpers/utils/codeInjection.js.map +0 -1
  124. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +0 -36
  125. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +0 -1
  126. package/lib/commonjs/ios/withAppDelegateModifications.js +0 -89
  127. package/lib/commonjs/ios/withAppDelegateModifications.js.map +0 -1
  128. package/lib/commonjs/ios/withCIOIos.js.map +0 -1
  129. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +0 -1
  130. package/lib/commonjs/ios/withXcodeProject.js.map +0 -1
  131. package/lib/commonjs/postInstallHelper.js +0 -20
  132. package/lib/commonjs/postInstallHelper.js.map +0 -1
  133. package/lib/commonjs/types/cio-types.js.map +0 -1
  134. package/lib/module/android/withCIOAndroid.js.map +0 -1
  135. package/lib/module/helpers/constants/ios.js +0 -84
  136. package/lib/module/helpers/constants/ios.js.map +0 -1
  137. package/lib/module/helpers/native-files/ios/Env.swift +0 -8
  138. package/lib/module/helpers/native-files/ios/NotificationService.swift +0 -22
  139. package/lib/module/helpers/utils/codeInjection.js.map +0 -1
  140. package/lib/module/helpers/utils/injectCIOPodfileCode.js +0 -29
  141. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +0 -1
  142. package/lib/module/ios/withAppDelegateModifications.js +0 -82
  143. package/lib/module/ios/withAppDelegateModifications.js.map +0 -1
  144. package/lib/module/ios/withCIOIos.js.map +0 -1
  145. package/lib/module/ios/withNotificationsXcodeProject.js.map +0 -1
  146. package/lib/module/ios/withXcodeProject.js.map +0 -1
  147. package/lib/module/postInstallHelper.js +0 -18
  148. package/lib/module/postInstallHelper.js.map +0 -1
  149. package/lib/module/types/cio-types.js.map +0 -1
  150. package/lib/typescript/helpers/constants/ios.d.ts +0 -31
  151. package/src/helpers/constants/ios.ts +0 -104
  152. package/src/helpers/native-files/ios/Env.swift +0 -8
  153. package/src/helpers/native-files/ios/NotificationService.swift +0 -22
  154. package/src/helpers/utils/injectCIOPodfileCode.ts +0 -54
  155. package/src/postInstallHelper.js +0 -22
  156. /package/{lib → plugin/lib}/commonjs/android/withAndroidManifestUpdates.js +0 -0
  157. /package/{lib → plugin/lib}/commonjs/android/withAppGoogleServices.js +0 -0
  158. /package/{lib → plugin/lib}/commonjs/android/withGistMavenRepository.js +0 -0
  159. /package/{lib → plugin/lib}/commonjs/android/withGoogleServicesJSON.js +0 -0
  160. /package/{lib → plugin/lib}/commonjs/android/withProjectGoogleServices.js +0 -0
  161. /package/{lib → plugin/lib}/commonjs/helpers/constants/globals.d.js +0 -0
  162. /package/{lib/commonjs/helpers/native-files/ios → plugin/lib/commonjs/helpers/native-files/ios/common}/NotificationService-Info.plist +0 -0
  163. /package/{lib/commonjs/helpers/native-files/ios → plugin/lib/commonjs/helpers/native-files/ios/common}/NotificationService.h +0 -0
  164. /package/{lib/commonjs/helpers/native-files/ios → plugin/lib/commonjs/helpers/native-files/ios/common}/NotificationService.m +0 -0
  165. /package/{lib → plugin/lib}/commonjs/helpers/utils/fileManagement.js +0 -0
  166. /package/{lib → plugin/lib}/commonjs/postInstall.js +0 -0
  167. /package/{lib → plugin/lib}/commonjs/types/cio-types.js +0 -0
  168. /package/{lib → plugin/lib}/module/android/withAndroidManifestUpdates.js +0 -0
  169. /package/{lib → plugin/lib}/module/android/withAppGoogleServices.js +0 -0
  170. /package/{lib → plugin/lib}/module/android/withGistMavenRepository.js +0 -0
  171. /package/{lib → plugin/lib}/module/android/withGoogleServicesJSON.js +0 -0
  172. /package/{lib → plugin/lib}/module/android/withProjectGoogleServices.js +0 -0
  173. /package/{lib → plugin/lib}/module/helpers/constants/android.js +0 -0
  174. /package/{lib → plugin/lib}/module/helpers/constants/globals.d.js +0 -0
  175. /package/{lib/module/helpers/native-files/ios → plugin/lib/module/helpers/native-files/ios/common}/NotificationService-Info.plist +0 -0
  176. /package/{lib/module/helpers/native-files/ios → plugin/lib/module/helpers/native-files/ios/common}/NotificationService.h +0 -0
  177. /package/{lib/module/helpers/native-files/ios → plugin/lib/module/helpers/native-files/ios/common}/NotificationService.m +0 -0
  178. /package/{lib → plugin/lib}/module/helpers/utils/fileManagement.js +0 -0
  179. /package/{lib → plugin/lib}/module/index.js +0 -0
  180. /package/{lib → plugin/lib}/module/postInstall.js +0 -0
  181. /package/{lib → plugin/lib}/module/types/cio-types.js +0 -0
  182. /package/{lib → plugin/lib}/typescript/android/withAndroidManifestUpdates.d.ts +0 -0
  183. /package/{lib → plugin/lib}/typescript/android/withAppGoogleServices.d.ts +0 -0
  184. /package/{lib → plugin/lib}/typescript/android/withCIOAndroid.d.ts +0 -0
  185. /package/{lib → plugin/lib}/typescript/android/withGistMavenRepository.d.ts +0 -0
  186. /package/{lib → plugin/lib}/typescript/android/withGoogleServicesJSON.d.ts +0 -0
  187. /package/{lib → plugin/lib}/typescript/android/withProjectGoogleServices.d.ts +0 -0
  188. /package/{lib → plugin/lib}/typescript/helpers/constants/android.d.ts +0 -0
  189. /package/{lib → plugin/lib}/typescript/helpers/utils/fileManagement.d.ts +0 -0
  190. /package/{lib → plugin/lib}/typescript/index.d.ts +0 -0
  191. /package/{lib → plugin/lib}/typescript/ios/withAppDelegateModifications.d.ts +0 -0
  192. /package/{lib → plugin/lib}/typescript/ios/withCIOIos.d.ts +0 -0
  193. /package/{lib → plugin/lib}/typescript/ios/withNotificationsXcodeProject.d.ts +0 -0
  194. /package/{lib → plugin/lib}/typescript/ios/withXcodeProject.d.ts +0 -0
  195. /package/{src → plugin/src}/android/withAndroidManifestUpdates.ts +0 -0
  196. /package/{src → plugin/src}/android/withAppGoogleServices.ts +0 -0
  197. /package/{src → plugin/src}/android/withGistMavenRepository.ts +0 -0
  198. /package/{src → plugin/src}/android/withGoogleServicesJSON.ts +0 -0
  199. /package/{src → plugin/src}/android/withProjectGoogleServices.ts +0 -0
  200. /package/{src → plugin/src}/helpers/constants/android.ts +0 -0
  201. /package/{src → plugin/src}/helpers/constants/globals.d.ts +0 -0
  202. /package/{src/helpers/native-files/ios → plugin/src/helpers/native-files/ios/common}/NotificationService-Info.plist +0 -0
  203. /package/{src/helpers/native-files/ios → plugin/src/helpers/native-files/ios/common}/NotificationService.h +0 -0
  204. /package/{src/helpers/native-files/ios → plugin/src/helpers/native-files/ios/common}/NotificationService.m +0 -0
  205. /package/{src → plugin/src}/helpers/utils/fileManagement.ts +0 -0
  206. /package/{src → plugin/src}/index.ts +0 -0
  207. /package/{src → plugin/src}/postInstall.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_DEEPLINK_COMMENT_REGEX","CIO_INITIALIZECIOSDK_SNIPPET","injectCodeBeforeMultiLineRegex","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","replaceCodeByRegex","matchRegexExists","FileManagement","isFcmPushProvider","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addInitializeNativeCioSdk","addHandleDeeplinkInKilledStateConfiguration","regex","addDidFailToRegisterForRemoteNotificationsWithError","addDidRegisterForRemoteNotificationsWithDeviceToken","addExpoNotificationsHeaderModification","addFirebaseDelegateForwardDeclarationIfNeeded","addAppdelegateHeaderModification","replace","interfaceDeclaration","_groupedDelegates","existingDelegates","includes","trim","addHandleDeeplinkInKilledState","snippet","withAppDelegateModifications","configOuter","props","config","modResults","contents","RegExp","modRequest","projectName","headerPath","projectRoot","headerContent","read","write","disableNotificationRegistration","handleDeeplinkInKilledState","console","log"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_IMPORT_SNIPPET,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET,\n CIO_DEEPLINK_COMMENT_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeBeforeMultiLineRegex,\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n replaceCodeByRegex,\n matchRegexExists,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n );\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addInitializeNativeCioSdk = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledStateConfiguration = (\n stringContents: string,\n regex: RegExp\n) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n regex,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\n// Adds required import for Expo Notifications package in AppDelegate.\n// Required to call functions from the package.\nconst addExpoNotificationsHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n `\n#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n#import <EXNotifications/EXNotificationCenterDelegate.h>\n#endif\n`\n );\n\n return stringContents;\n};\n\nconst addFirebaseDelegateForwardDeclarationIfNeeded = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n '@protocol FIRMessagingDelegate;'\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n // Add UNUserNotificationCenterDelegate if needed\n stringContents = stringContents.replace(\n CIO_APPDELEGATEHEADER_REGEX,\n (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {\n if (\n existingDelegates &&\n existingDelegates.includes(\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET\n )\n ) {\n // The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it\n return match;\n } else if (existingDelegates) {\n // Other delegates exist, append ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration}<${existingDelegates}, ${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n } else {\n // No delegates exist, add ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n }\n }\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledState = (stringContents: string) => {\n // Find if the deep link code snippet is already present\n if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {\n return stringContents;\n }\n\n // Check if the app delegate is using RCTBridge or LaunchOptions\n let snippet = undefined;\n let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n if (\n matchRegexExists(\n stringContents,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;\n regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n } else if (\n matchRegexExists(\n stringContents,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;\n }\n // Add code only if the app delegate is using RCTBridge or LaunchOptions\n if (snippet !== undefined) {\n stringContents = addHandleDeeplinkInKilledStateConfiguration(\n stringContents,\n regex\n );\n stringContents = replaceCodeByRegex(stringContents, regex, snippet);\n }\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n const match = stringContents.match(regex);\n\n if (!match) {\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(\n stringContents,\n config.modRequest.projectName as string\n );\n stringContents = addNotificationHandlerDeclaration(stringContents);\n\n // any other value would be treated as true, it has to be explicitly false to disable\n if (\n props.disableNotificationRegistration !== undefined &&\n props.disableNotificationRegistration === false\n ) {\n stringContents = addNotificationConfiguration(stringContents);\n }\n\n stringContents = addInitializeNativeCioSdk(stringContents);\n\n if (\n props.handleDeeplinkInKilledState !== undefined &&\n props.handleDeeplinkInKilledState === true\n ) {\n stringContents = addHandleDeeplinkInKilledState(stringContents);\n }\n\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n if (isFcmPushProvider(props)) {\n stringContents = addFirebaseDelegateForwardDeclarationIfNeeded(stringContents);\n } \n\n stringContents = addExpoNotificationsHeaderModification(stringContents);\n\n config.modResults.contents = stringContents;\n } else {\n console.log('Customerio AppDelegate changes already exist. Skipping...');\n }\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":"AAAA,SAAuBA,eAAe,QAAQ,sBAAsB;AACpE,SAASC,4BAA4B,QAAQ,sCAAsC;AAEnF,SACEC,gCAAgC,EAChCC,oCAAoC,EACpCC,2BAA2B,EAC3BC,sDAAsD,EACtDC,2CAA2C,EAC3CC,yCAAyC,EACzCC,4CAA4C,EAC5CC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,kCAAkC,EAClCC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,gDAAgD,EAChDC,8CAA8C,EAC9CC,yCAAyC,EACzCC,8CAA8C,EAC9CC,0BAA0B,EAC1BC,4BAA4B,QACvB,0BAA0B;AACjC,SACEC,8BAA8B,EAC9BC,sBAAsB,EACtBC,0BAA0B,EAC1BC,wCAAwC,EACxCC,kBAAkB,EAClBC,gBAAgB,QACX,gCAAgC;AACvC,SAASC,cAAc,QAAQ,iCAAiC;AAEhE,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,MAAMC,SAAS,GAAGA,CAACC,cAAsB,EAAEC,OAAe,KAAK;EAC7D,MAAMC,WAAW,GAAG,mBAAmB;EACvC,MAAMC,WAAW,GAAGC,gBAAgB,CAACH,OAAO,CAAC;EAE7C,MAAMI,KAAK,GAAGL,cAAc,CAACK,KAAK,CAACH,WAAW,CAAC;EAC/C,IAAII,eAAuB;EAC3B,IAAI,CAACD,KAAK,IAAIA,KAAK,CAACE,KAAK,KAAK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AAyB,CAACZ,cAAc,CAAC;MAE1D,IACE8B,KAAK,CAACa,2BAA2B,KAAKnC,SAAS,IAC/CsB,KAAK,CAACa,2BAA2B,KAAK,IAAI,EAC1C;QACA3C,cAAc,GAAG0B,8BAA8B,CAAC1B,cAAc,CAAC;MACjE;MAEAA,cAAc,GACZe,mDAAmD,CAACf,cAAc,CAAC;MACrEA,cAAc,GACZgB,mDAAmD,CAAChB,cAAc,CAAC;MAErE,IAAIF,iBAAiB,CAACgC,KAAK,CAAC,EAAE;QAC5B9B,cAAc,GAAGkB,6CAA6C,CAAClB,cAAc,CAAC;MAChF;MAEAA,cAAc,GAAGiB,sCAAsC,CAACjB,cAAc,CAAC;MAEvE+B,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGjC,cAAc;IAC7C,CAAC,MAAM;MACL4C,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOd,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AACD,SAAS3B,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAO;AACT;AACA;AACA,WAAWA,OAAO;AAClB,GAAG;AACH","ignoreList":[]}
@@ -1,11 +1,13 @@
1
1
  import { withAppDelegateModifications } from './withAppDelegateModifications';
2
2
  import { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';
3
3
  import { withCioXcodeProject } from './withXcodeProject';
4
+ import { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';
4
5
  export function withCIOIos(config, props) {
5
6
  if (props.pushNotification) {
6
7
  config = withAppDelegateModifications(config, props);
7
8
  config = withCioNotificationsXcodeProject(config, props);
8
9
  config = withCioXcodeProject(config, props);
10
+ config = withGoogleServicesJsonFile(config, props);
9
11
  }
10
12
  return config;
11
13
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withAppDelegateModifications","withCioNotificationsXcodeProject","withCioXcodeProject","withGoogleServicesJsonFile","withCIOIos","config","props","pushNotification"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\nimport { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioNotificationsXcodeProject(config, props);\n config = withCioXcodeProject(config, props);\n config = withGoogleServicesJsonFile(config, props);\n }\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AACxD,SAASC,0BAA0B,QAAQ,8BAA8B;AAEzE,OAAO,SAASC,UAAUA,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EACA,IAAIA,KAAK,CAACC,gBAAgB,EAAE;IAC1BF,MAAM,GAAGL,4BAA4B,CAACK,MAAM,EAAEC,KAAK,CAAC;IACpDD,MAAM,GAAGJ,gCAAgC,CAACI,MAAM,EAAEC,KAAK,CAAC;IACxDD,MAAM,GAAGH,mBAAmB,CAACG,MAAM,EAAEC,KAAK,CAAC;IAC3CD,MAAM,GAAGF,0BAA0B,CAACE,MAAM,EAAEC,KAAK,CAAC;EACpD;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
@@ -0,0 +1,61 @@
1
+ import { withXcodeProject, IOSConfig } from '@expo/config-plugins';
2
+ import { FileManagement } from './../helpers/utils/fileManagement';
3
+ import { isFcmPushProvider } from './utils';
4
+ export const withGoogleServicesJsonFile = (config, cioProps) => {
5
+ return withXcodeProject(config, async props => {
6
+ var _cioProps$pushNotific;
7
+ const useFcm = isFcmPushProvider(cioProps);
8
+ if (!useFcm) {
9
+ // Nothing to do, for providers other than FCM, the Google services JSON file isn't needed
10
+ return props;
11
+ }
12
+ console.log('Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' + ' GoogleService-Info.plist as part of Firebase integration');
13
+
14
+ // googleServicesFile
15
+ const iosPath = props.modRequest.platformProjectRoot;
16
+ const googleServicesFile = (_cioProps$pushNotific = cioProps.pushNotification) === null || _cioProps$pushNotific === void 0 ? void 0 : _cioProps$pushNotific.googleServicesFile;
17
+ const appName = props.modRequest.projectName;
18
+ if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {
19
+ console.log(`File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`);
20
+ return props;
21
+ }
22
+ if (FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)) {
23
+ // This is where RN Firebase potentially copies GoogleService-Info.plist
24
+ // Do not copy if it's already done by Firebase to avoid conflict in Resources
25
+ console.log(`File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`);
26
+ return props;
27
+ }
28
+ if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
29
+ var _config$ios;
30
+ if ((_config$ios = config.ios) !== null && _config$ios !== void 0 && _config$ios.googleServicesFile) {
31
+ console.warn('Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' + ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile');
32
+ }
33
+ try {
34
+ FileManagement.copyFile(googleServicesFile, `${iosPath}/GoogleService-Info.plist`);
35
+ addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');
36
+ } catch (e) {
37
+ console.error(`There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`);
38
+ }
39
+ } else {
40
+ console.error(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`);
41
+ }
42
+ return props;
43
+ });
44
+ };
45
+ function addFileToXcodeProject(project, fileName) {
46
+ const groupName = 'Resources';
47
+ const filepath = fileName;
48
+ if (!IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {
49
+ console.error(`Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`);
50
+ return;
51
+ }
52
+
53
+ // Add GoogleService-Info.plist to the Xcode project
54
+ IOSConfig.XcodeUtils.addResourceFileToGroup({
55
+ project,
56
+ filepath,
57
+ groupName,
58
+ isBuildFile: true
59
+ });
60
+ }
61
+ //# sourceMappingURL=withGoogleServicesJsonFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withXcodeProject","IOSConfig","FileManagement","isFcmPushProvider","withGoogleServicesJsonFile","config","cioProps","props","_cioProps$pushNotific","useFcm","console","log","iosPath","modRequest","platformProjectRoot","googleServicesFile","pushNotification","appName","projectName","exists","_config$ios","ios","warn","copyFile","addFileToXcodeProject","modResults","e","error","project","fileName","groupName","filepath","XcodeUtils","ensureGroupRecursively","addResourceFileToGroup","isBuildFile"],"sources":["withGoogleServicesJsonFile.ts"],"sourcesContent":["import {\n withXcodeProject,\n IOSConfig,\n ConfigPlugin,\n} from '@expo/config-plugins';\n\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\n\nexport const withGoogleServicesJsonFile: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (config, cioProps) => {\n return withXcodeProject(config, async (props) => {\n const useFcm = isFcmPushProvider(cioProps);\n if (!useFcm) {\n // Nothing to do, for providers other than FCM, the Google services JSON file isn't needed\n return props;\n }\n\n console.log(\n 'Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' +\n ' GoogleService-Info.plist as part of Firebase integration'\n );\n\n // googleServicesFile\n const iosPath = props.modRequest.platformProjectRoot;\n const googleServicesFile = cioProps.pushNotification?.googleServicesFile;\n const appName = props.modRequest.projectName;\n\n if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {\n console.log(\n `File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (\n FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)\n ) {\n // This is where RN Firebase potentially copies GoogleService-Info.plist\n // Do not copy if it's already done by Firebase to avoid conflict in Resources\n console.log(\n `File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n if (config.ios?.googleServicesFile) {\n console.warn(\n 'Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' +\n ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile'\n );\n }\n\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${iosPath}/GoogleService-Info.plist`\n );\n\n addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');\n } catch (e) {\n console.error(\n `There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n } else {\n console.error(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n\n return props;\n });\n};\n\nfunction addFileToXcodeProject(project: any, fileName: string) {\n const groupName = 'Resources';\n const filepath = fileName;\n\n if (!IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {\n console.error(\n `Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`\n );\n return;\n }\n\n // Add GoogleService-Info.plist to the Xcode project\n IOSConfig.XcodeUtils.addResourceFileToGroup({\n project,\n filepath,\n groupName,\n isBuildFile: true,\n });\n}\n"],"mappings":"AAAA,SACEA,gBAAgB,EAChBC,SAAS,QAEJ,sBAAsB;AAE7B,SAASC,cAAc,QAAQ,mCAAmC;AAElE,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,OAAO,MAAMC,0BAEZ,GAAGA,CAACC,MAAM,EAAEC,QAAQ,KAAK;EACxB,OA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C,CAAC,OAAOC,CAAC,EAAE;QACVhB,OAAO,CAACiB,KAAK,CACX,gGAAgGf,OAAO,2BACzG,CAAC;MACH;IACF,CAAC,MAAM;MACLF,OAAO,CAACiB,KAAK,CACX,wCAAwCZ,kBAAkB,yDAAyDH,OAAO,2BAC5H,CAAC;IACH;IAEA,OAAOL,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAED,SAASiB,qBAAqBA,CAACI,OAAY,EAAEC,QAAgB,EAAE;EAC7D,MAAMC,SAAS,GAAG,WAAW;EAC7B,MAAMC,QAAQ,GAAGF,QAAQ;EAEzB,IAAI,CAAC5B,SAAS,CAAC+B,UAAU,CAACC,sBAAsB,CAACL,OAAO,EAAEE,SAAS,CAAC,EAAE;IACpEpB,OAAO,CAACiB,KAAK,CACX,qEAAqEG,SAAS,mBAChF,CAAC;IACD;EACF;;EAEA;EACA7B,SAAS,CAAC+B,UAAU,CAACE,sBAAsB,CAAC;IAC1CN,OAAO;IACPG,QAAQ;IACRD,SAAS;IACTK,WAAW,EAAE;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,34 +1,26 @@
1
1
  import { withXcodeProject } from '@expo/config-plugins';
2
- import xcode from 'xcode';
3
2
  import { CIO_NOTIFICATION_TARGET_NAME, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET, DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
4
3
  import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
5
4
  import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
6
5
  import { FileManagement } from './../helpers/utils/fileManagement';
6
+ import { isFcmPushProvider } from './utils';
7
7
  const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
8
8
  const ENV_FILENAME = 'Env.swift';
9
9
  const TARGETED_DEVICE_FAMILY = `"1,2"`;
10
- const addNotificationServiceExtension = async options => {
11
- // iosPath and appName are predefined from Expo config.
12
- // See function withCioNotificationsXcodeProject to get where the variabes are pulled from.
13
- const {
14
- iosPath,
15
- appName
16
- } = options;
17
- const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
18
- const xcodeProject = xcode.project(projPath);
19
- xcodeProject.parse(async function (err) {
10
+ const addNotificationServiceExtension = async (options, xcodeProject) => {
11
+ try {
20
12
  var _options$pushNotifica;
21
- if (err) {
22
- throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
23
- }
24
13
  if (options.pushNotification) {
25
14
  await addPushNotificationFile(options, xcodeProject);
26
15
  }
27
16
  if ((_options$pushNotifica = options.pushNotification) !== null && _options$pushNotifica !== void 0 && _options$pushNotifica.useRichPush) {
28
17
  await addRichPushXcodeProj(options, xcodeProject);
29
18
  }
30
- FileManagement.writeFile(projPath, xcodeProject.writeSync());
31
- });
19
+ return xcodeProject;
20
+ } catch (error) {
21
+ console.error(error);
22
+ return null;
23
+ }
32
24
  };
33
25
  export const withCioNotificationsXcodeProject = (configOuter, props) => {
34
26
  return withXcodeProject(configOuter, async config => {
@@ -75,7 +67,10 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
75
67
  iosDeploymentTarget,
76
68
  pushNotification
77
69
  };
78
- await addNotificationServiceExtension(options);
70
+ const modifiedProjectFile = await addNotificationServiceExtension(options, config.modResults);
71
+ if (modifiedProjectFile) {
72
+ config.modResults = modifiedProjectFile;
73
+ }
79
74
  return config;
80
75
  });
81
76
  };
@@ -89,7 +84,8 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
89
84
  iosDeploymentTarget,
90
85
  useFrameworks
91
86
  } = options;
92
- await injectCIONotificationPodfileCode(iosPath, useFrameworks);
87
+ const isFcmProvider = isFcmPushProvider(options);
88
+ await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);
93
89
 
94
90
  // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project
95
91
  // If true then skip creating a new group to avoid duplicate folders
@@ -101,11 +97,19 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
101
97
  FileManagement.mkdir(nsePath, {
102
98
  recursive: true
103
99
  });
104
- const files = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.swift', 'NotificationService.m', ENV_FILENAME];
100
+ const platformSpecificFiles = ['NotificationService.swift'];
101
+ const commonFiles = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.m', ENV_FILENAME];
105
102
  const getTargetFile = filename => `${nsePath}/${filename}`;
106
- files.forEach(filename => {
103
+ // Copy platform-specific files
104
+ platformSpecificFiles.forEach(filename => {
105
+ const targetFile = getTargetFile(filename);
106
+ FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${isFcmProvider ? "fcm" : "apn"}/${filename}`, targetFile);
107
+ });
108
+
109
+ // Copy common files
110
+ commonFiles.forEach(filename => {
107
111
  const targetFile = getTargetFile(filename);
108
- FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
112
+ FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/common/${filename}`, targetFile);
109
113
  });
110
114
 
111
115
  /* MODIFY COPIED EXTENSION FILES */
@@ -118,7 +122,9 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
118
122
  updateNseEnv(options, getTargetFile(ENV_FILENAME));
119
123
 
120
124
  // Create new PBXGroup for the extension
121
- const extGroup = xcodeProject.addPbxGroup(files, CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
125
+ const extGroup = xcodeProject.addPbxGroup([...platformSpecificFiles, ...commonFiles],
126
+ // Combine platform-specific and common files,
127
+ CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
122
128
 
123
129
  // Add the new PBXGroup to the top level group. This makes the
124
130
  // files / folder appear in the file explorer in Xcode.
@@ -156,7 +162,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
156
162
  if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${CIO_NOTIFICATION_TARGET_NAME}"`) {
157
163
  const buildSettingsObj = configurations[key].buildSettings;
158
164
  buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
159
- buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
165
+ buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '15.1';
160
166
  buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
161
167
  buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
162
168
  buildSettingsObj.SWIFT_VERSION = 4.2;
@@ -180,30 +186,25 @@ const updateNseInfoPlist = payload => {
180
186
  FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
181
187
  };
182
188
  const updateNseEnv = (options, envFileName) => {
183
- var _options$pushNotifica2, _options$pushNotifica3, _options$pushNotifica6, _options$pushNotifica7, _options$pushNotifica10, _options$pushNotifica11;
184
- const SITE_ID_RE = /\{\{SITE_ID\}\}/;
185
- const API_KEY_RE = /\{\{API_KEY\}\}/;
189
+ var _options$pushNotifica2, _options$pushNotifica4;
190
+ const CDP_API_KEY_RE = /\{\{CDP_API_KEY\}\}/;
186
191
  const REGION_RE = /\{\{REGION\}\}/;
187
192
  let envFileContent = FileManagement.readFile(envFileName);
188
- if ((_options$pushNotifica2 = options.pushNotification) !== null && _options$pushNotifica2 !== void 0 && (_options$pushNotifica3 = _options$pushNotifica2.env) !== null && _options$pushNotifica3 !== void 0 && _options$pushNotifica3.siteId) {
189
- var _options$pushNotifica4, _options$pushNotifica5;
190
- envFileContent = replaceCodeByRegex(envFileContent, SITE_ID_RE, (_options$pushNotifica4 = options.pushNotification) === null || _options$pushNotifica4 === void 0 ? void 0 : (_options$pushNotifica5 = _options$pushNotifica4.env) === null || _options$pushNotifica5 === void 0 ? void 0 : _options$pushNotifica5.siteId);
191
- }
192
- if ((_options$pushNotifica6 = options.pushNotification) !== null && _options$pushNotifica6 !== void 0 && (_options$pushNotifica7 = _options$pushNotifica6.env) !== null && _options$pushNotifica7 !== void 0 && _options$pushNotifica7.apiKey) {
193
- var _options$pushNotifica8, _options$pushNotifica9;
194
- envFileContent = replaceCodeByRegex(envFileContent, API_KEY_RE, (_options$pushNotifica8 = options.pushNotification) === null || _options$pushNotifica8 === void 0 ? void 0 : (_options$pushNotifica9 = _options$pushNotifica8.env) === null || _options$pushNotifica9 === void 0 ? void 0 : _options$pushNotifica9.apiKey);
193
+ if ((_options$pushNotifica2 = options.pushNotification) !== null && _options$pushNotifica2 !== void 0 && (_options$pushNotifica2 = _options$pushNotifica2.env) !== null && _options$pushNotifica2 !== void 0 && _options$pushNotifica2.cdpApiKey) {
194
+ var _options$pushNotifica3;
195
+ envFileContent = replaceCodeByRegex(envFileContent, CDP_API_KEY_RE, (_options$pushNotifica3 = options.pushNotification) === null || _options$pushNotifica3 === void 0 || (_options$pushNotifica3 = _options$pushNotifica3.env) === null || _options$pushNotifica3 === void 0 ? void 0 : _options$pushNotifica3.cdpApiKey);
195
196
  }
196
- if ((_options$pushNotifica10 = options.pushNotification) !== null && _options$pushNotifica10 !== void 0 && (_options$pushNotifica11 = _options$pushNotifica10.env) !== null && _options$pushNotifica11 !== void 0 && _options$pushNotifica11.region) {
197
- var _options$pushNotifica12, _options$pushNotifica13, _options$pushNotifica14;
197
+ if ((_options$pushNotifica4 = options.pushNotification) !== null && _options$pushNotifica4 !== void 0 && (_options$pushNotifica4 = _options$pushNotifica4.env) !== null && _options$pushNotifica4 !== void 0 && _options$pushNotifica4.region) {
198
+ var _options$pushNotifica5;
198
199
  const regionMap = {
199
200
  us: 'Region.US',
200
201
  eu: 'Region.EU'
201
202
  };
202
- const region = (_options$pushNotifica12 = options.pushNotification) === null || _options$pushNotifica12 === void 0 ? void 0 : (_options$pushNotifica13 = _options$pushNotifica12.env) === null || _options$pushNotifica13 === void 0 ? void 0 : (_options$pushNotifica14 = _options$pushNotifica13.region) === null || _options$pushNotifica14 === void 0 ? void 0 : _options$pushNotifica14.toLowerCase();
203
+ const region = (_options$pushNotifica5 = options.pushNotification) === null || _options$pushNotifica5 === void 0 || (_options$pushNotifica5 = _options$pushNotifica5.env) === null || _options$pushNotifica5 === void 0 || (_options$pushNotifica5 = _options$pushNotifica5.region) === null || _options$pushNotifica5 === void 0 ? void 0 : _options$pushNotifica5.toLowerCase();
203
204
  const mappedRegion = regionMap[region] || '';
204
205
  if (!mappedRegion) {
205
- var _options$pushNotifica15, _options$pushNotifica16;
206
- console.warn(`${(_options$pushNotifica15 = options.pushNotification) === null || _options$pushNotifica15 === void 0 ? void 0 : (_options$pushNotifica16 = _options$pushNotifica15.env) === null || _options$pushNotifica16 === void 0 ? void 0 : _options$pushNotifica16.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`);
206
+ var _options$pushNotifica6;
207
+ console.warn(`${(_options$pushNotifica6 = options.pushNotification) === null || _options$pushNotifica6 === void 0 || (_options$pushNotifica6 = _options$pushNotifica6.env) === null || _options$pushNotifica6 === void 0 ? void 0 : _options$pushNotifica6.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`);
207
208
  } else {
208
209
  envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);
209
210
  }
@@ -211,24 +212,28 @@ const updateNseEnv = (options, envFileName) => {
211
212
  FileManagement.writeFile(envFileName, envFileContent);
212
213
  };
213
214
  async function addPushNotificationFile(options, xcodeProject) {
215
+ // Maybe copy a different file with FCM config based on config
214
216
  const {
215
217
  iosPath,
216
218
  appName
217
219
  } = options;
218
- const file = 'PushService.swift';
220
+ const isFcmProvider = isFcmPushProvider(options);
221
+ // PushService.swift is platform-specific and always lives in the platform folder
222
+ const sourceFile = `${isFcmProvider ? "fcm" : "apn"}/PushService.swift`;
223
+ const targetFileName = 'PushService.swift';
219
224
  const appPath = `${iosPath}/${appName}`;
220
225
  const getTargetFile = filename => `${appPath}/${filename}`;
221
- const targetFile = getTargetFile(file);
226
+ const targetFile = getTargetFile(targetFileName);
222
227
 
223
228
  // Check whether {file} exists in the project. If false, then add the file
224
229
  // If {file} exists then skip and return
225
- if (!FileManagement.exists(getTargetFile(file))) {
230
+ if (!FileManagement.exists(getTargetFile(targetFileName))) {
226
231
  FileManagement.mkdir(appPath, {
227
232
  recursive: true
228
233
  });
229
- FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
234
+ FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${sourceFile}`, targetFile);
230
235
  } else {
231
- console.log(`${getTargetFile(file)} already exists. Skipping...`);
236
+ console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);
232
237
  return;
233
238
  }
234
239
  updatePushFile(options, targetFile);
@@ -237,7 +242,7 @@ async function addPushNotificationFile(options, xcodeProject) {
237
242
  name: `${appName}`
238
243
  });
239
244
  xcodeProject.addToPbxGroup(group, classesKey);
240
- xcodeProject.addSourceFile(`${appName}/${file}`, null, group);
245
+ xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);
241
246
  }
242
247
  const updatePushFile = (options, envFileName) => {
243
248
  const REGISTER_RE = /\{\{REGISTER_SNIPPET\}\}/;
@@ -247,6 +252,16 @@ const updatePushFile = (options, envFileName) => {
247
252
  snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;
248
253
  }
249
254
  envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);
255
+ if (options.pushNotification) {
256
+ envFileContent = replaceCodeByRegex(envFileContent, /\{\{CDP_API_KEY\}\}/, options.pushNotification.env.cdpApiKey);
257
+ envFileContent = replaceCodeByRegex(envFileContent, /\{\{REGION\}\}/, options.pushNotification.env.region.toUpperCase());
258
+ }
259
+ const autoTrackPushEvents = options.autoTrackPushEvents === undefined || options.autoTrackPushEvents === true;
260
+ envFileContent = replaceCodeByRegex(envFileContent, /\{\{AUTO_TRACK_PUSH_EVENTS\}\}/, autoTrackPushEvents.toString());
261
+ const autoFetchDeviceToken = options.autoFetchDeviceToken === undefined || options.autoFetchDeviceToken === true;
262
+ envFileContent = replaceCodeByRegex(envFileContent, /\{\{AUTO_FETCH_DEVICE_TOKEN\}\}/, autoFetchDeviceToken.toString());
263
+ const showPushAppInForeground = options.showPushAppInForeground === undefined || options.showPushAppInForeground === true;
264
+ envFileContent = replaceCodeByRegex(envFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
250
265
  FileManagement.writeFile(envFileName, envFileContent);
251
266
  };
252
267
  //# sourceMappingURL=withNotificationsXcodeProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","replaceCodeByRegex","injectCIONotificationPodfileCode","FileManagement","isFcmPushProvider","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","console","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","isFcmProvider","pbxTargetByName","warn","nsePath","mkdir","recursive","platformSpecificFiles","commonFiles","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","extGroup","addPbxGroup","groups","hash","project","objects","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","writeFile","envFileName","_options$pushNotifica2","_options$pushNotifica4","CDP_API_KEY_RE","REGION_RE","envFileContent","env","cdpApiKey","_options$pushNotifica3","region","_options$pushNotifica5","regionMap","us","eu","toLowerCase","mappedRegion","_options$pushNotifica6","sourceFile","targetFileName","appPath","exists","log","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","REGISTER_RE","snippet","disableNotificationRegistration","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import {\n ConfigPlugin,\n XcodeProject,\n withXcodeProject,\n} from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport { isFcmPushProvider } from './utils';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) => {\n try {\n if (options.pushNotification) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: any) {\n console.error(error);\n return null;\n }\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const {\n appleTeamId,\n iosDeploymentTarget,\n pushNotification,\n useFrameworks,\n } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n pushNotification,\n };\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const platformSpecificFiles = [\n 'NotificationService.swift',\n ];\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${isFcmProvider ? \"fcm\" : \"apn\"}/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/common/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(options, getTargetFile(ENV_FILENAME));\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};\n projObjects['PBXContainerItemProxy'] =\n projObjects['PBXTargetDependency'] || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n if (options.pushNotification?.env?.cdpApiKey) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n options.pushNotification?.env?.cdpApiKey\n );\n }\n\n if (options.pushNotification?.env?.region) {\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const region = options.pushNotification?.env?.region?.toLowerCase();\n const mappedRegion = (regionMap as any)[region] || '';\n if (!mappedRegion) {\n console.warn(\n `${options.pushNotification?.env?.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`\n );\n } else {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n REGION_RE,\n mappedRegion\n );\n }\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) {\n // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? \"fcm\" : \"apn\"}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${sourceFile}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n let snippet = '';\n if (\n options.disableNotificationRegistration !== undefined &&\n options.disableNotificationRegistration === false\n ) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n if (options.pushNotification) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n options.pushNotification.env.cdpApiKey\n );\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n options.pushNotification.env.region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.autoTrackPushEvents === undefined ||\n options.autoTrackPushEvents === true;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken = \n options.autoFetchDeviceToken === undefined ||\n options.autoFetchDeviceToken === true;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n \n const showPushAppInForeground =\n options.showPushAppInForeground === undefined ||\n options.showPushAppInForeground === true;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AAAA,SAGEA,gBAAgB,QACX,sBAAsB;AAE7B,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,MAAMC,cAAc,GAAG,GAAGR,4BAA4B,aAAa;AACnE,MAAMS,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAG,OAAO;AAEtC,MAAMC,+BAA+B,GAAG,MAAAA,CACtCC,OAAmC,EACnCC,YAA0B,KACvB;EACH,IAAI;IAAA,IAAAC,qBAAA;IACF,IAAIF,OAAO,CAACG,gBAAgB,EAAE;MAC5B,MAAMC,uBAAuB,CAACJ,OAAO,EAAEC,YAAY,CAAC;IACtD;IAEA,KAAAC,qBAAA,GAAIF,OAAO,CAACG,gBAAgB,cAAAD,qBAAA,eAAxBA,qBAAA,CAA0BG,WAAW,EAAE;MACzC,MAAMC,oBAAoB,CAACN,OAAO,EAAEC,YAAY,CAAC;IACnD;IACA,OAAOA,YAAY;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Ac,CAAC;AACvD,CAAC","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import { withXcodeProject } from '@expo/config-plugins';
2
2
  import { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
3
+ import { isFcmPushProvider } from './utils';
3
4
  export const withCioXcodeProject = (config, cioProps) => {
4
5
  return withXcodeProject(config, async props => {
5
6
  var _props$ios, _props$ios2;
@@ -14,7 +15,7 @@ export const withCioXcodeProject = (config, cioProps) => {
14
15
  const {
15
16
  iosPath
16
17
  } = options;
17
- await injectCIOPodfileCode(iosPath);
18
+ await injectCIOPodfileCode(iosPath, isFcmPushProvider(cioProps));
18
19
  return props;
19
20
  });
20
21
  };
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withXcodeProject","injectCIOPodfileCode","isFcmPushProvider","withCioXcodeProject","config","cioProps","props","_props$ios","_props$ios2","options","iosPath","modRequest","platformProjectRoot","bundleIdentifier","ios","devTeam","bundleVersion","buildNumber","bundleShortVersion","version","iosDeploymentTarget"],"sources":["withXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\n\nimport { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\n\nexport const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n config,\n cioProps\n) => {\n return withXcodeProject(config, async (props) => {\n const options: CustomerIOPluginOptionsIOS = {\n iosPath: props.modRequest.platformProjectRoot,\n bundleIdentifier: props.ios?.bundleIdentifier,\n devTeam: cioProps?.devTeam,\n bundleVersion: props.ios?.buildNumber,\n bundleShortVersion: props?.version,\n iosDeploymentTarget: cioProps?.iosDeploymentTarget,\n };\n const { iosPath } = options;\n\n await injectCIOPodfileCode(iosPath, isFcmPushProvider(cioProps));\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AAErE,SAASC,oBAAoB,QAAQ,uCAAuC;AAE5E,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,OAAO,MAAMC,mBAA6D,GAAGA,CAC3EC,MAAM,EACNC,QAAQ,KACL;EACH,OAAOL,gBAAgB,CAACI,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA,IAAAC,UAAA,EAAAC,WAAA;IAC/C,MAAMC,OAAmC,GAAG;MAC1CC,OAAO,EAAEJ,KAAK,CAACK,UAAU,CAACC,mBAAmB;MAC7CC,gBAAgB,GAAAN,UAAA,GAAED,KAAK,CAACQ,GAAG,cAAAP,UAAA,uBAATA,UAAA,CAAWM,gBAAgB;MAC7CE,OAAO,EAAEV,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEU,OAAO;MAC1BC,aAAa,GAAAR,WAAA,GAAEF,KAAK,CAACQ,GAAG,cAAAN,WAAA,uBAATA,WAAA,CAAWS,WAAW;MACrCC,kBAAkB,EAAEZ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEa,OAAO;MAClCC,mBAAmB,EAAEf,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEe;IACjC,CAAC;IACD,MAAM;MAAEV;IAAQ,CAAC,GAAGD,OAAO;IAE3B,MAAMR,oBAAoB,CAACS,OAAO,EAAER,iBAAiB,CAACG,QAAQ,CAAC,CAAC;IAEhE,OAAOC,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["ph","require","runPostInstall","error"],"sources":["postInstall.js"],"sourcesContent":["try {\n const ph = require('./postInstallHelper');\n\n ph.runPostInstall();\n} catch (error) {}\n"],"mappings":"AAAA,IAAI;EACF,MAAMA,EAAE,GAAGC,OAAO,CAAC,qBAAqB,CAAC;EAEzCD,EAAE,CAACE,cAAc,CAAC,CAAC;AACrB,CAAC,CAAC,OAAOC,KAAK,EAAE,CAAC"}
1
+ {"version":3,"names":["ph","require","runPostInstall","error"],"sources":["postInstall.js"],"sourcesContent":["try {\n const ph = require('./postInstallHelper');\n\n ph.runPostInstall();\n} catch (error) {}\n"],"mappings":"AAAA,IAAI;EACF,MAAMA,EAAE,GAAGC,OAAO,CAAC,qBAAqB,CAAC;EAEzCD,EAAE,CAACE,cAAc,CAAC,CAAC;AACrB,CAAC,CAAC,OAAOC,KAAK,EAAE,CAAC","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ const fs = require('fs');
2
+ function runPostInstall() {
3
+ // react native SDK package.json path
4
+ const reactNativePackageJsonFile = `${__dirname}/../../../customerio-reactnative/package.json`;
5
+ const expoPackageJsonFile = `${__dirname}/../../package.json`;
6
+ try {
7
+ // if react native SDK is installed
8
+ if (fs.existsSync(reactNativePackageJsonFile)) {
9
+ const reactNativePackageJson = fs.readFileSync(reactNativePackageJsonFile, 'utf8');
10
+ const expoPackageJson = require(expoPackageJsonFile);
11
+ const reactNativePackage = JSON.parse(reactNativePackageJson);
12
+ reactNativePackage.expoVersion = expoPackageJson.version;
13
+ fs.writeFileSync(reactNativePackageJsonFile, JSON.stringify(reactNativePackage, null, 2));
14
+ }
15
+ } catch (error) {
16
+ console.warn('Unable to find customerio-reactnative package.json file. Please make sure you have installed the customerio-reactnative package.', error);
17
+ }
18
+ }
19
+ exports.runPostInstall = runPostInstall;
20
+ //# sourceMappingURL=postInstallHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fs","require","runPostInstall","reactNativePackageJsonFile","__dirname","expoPackageJsonFile","existsSync","reactNativePackageJson","readFileSync","expoPackageJson","reactNativePackage","JSON","parse","expoVersion","version","writeFileSync","stringify","error","console","warn","exports"],"sources":["postInstallHelper.js"],"sourcesContent":["const fs = require('fs');\n\nfunction runPostInstall() {\n // react native SDK package.json path\n const reactNativePackageJsonFile = `${__dirname}/../../../customerio-reactnative/package.json`;\n const expoPackageJsonFile = `${__dirname}/../../package.json`;\n try {\n // if react native SDK is installed\n if (fs.existsSync(reactNativePackageJsonFile)) {\n const reactNativePackageJson = fs.readFileSync(\n reactNativePackageJsonFile,\n 'utf8'\n );\n const expoPackageJson = require(expoPackageJsonFile);\n\n const reactNativePackage = JSON.parse(reactNativePackageJson);\n reactNativePackage.expoVersion = expoPackageJson.version;\n\n fs.writeFileSync(\n reactNativePackageJsonFile,\n JSON.stringify(reactNativePackage, null, 2)\n );\n }\n } catch (error) {\n console.warn(\n 'Unable to find customerio-reactnative package.json file. Please make sure you have installed the customerio-reactnative package.',\n error\n );\n }\n}\n\nexports.runPostInstall = runPostInstall;"],"mappings":"AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AAExB,SAASC,cAAcA,CAAA,EAAG;EACxB;EACA,MAAMC,0BAA0B,GAAG,GAAGC,SAAS,+CAA+C;EAC9F,MAAMC,mBAAmB,GAAG,GAAGD,SAAS,qBAAqB;EAC7D,IAAI;IACF;IACA,IAAIJ,EAAE,CAACM,UAAU,CAACH,0BAA0B,CAAC,EAAE;MAC7C,MAAMI,sBAAsB,GAAGP,EAAE,CAACQ,YAAY,CAC5CL,0BAA0B,EAC1B,MACF,CAAC;MACD,MAAMM,eAAe,GAAGR,OAAO,CAACI,mBAAmB,CAAC;MAEpD,MAAMK,kBAAkB,GAAGC,IAAI,CAACC,KAAK,CAACL,sBAAsB,CAAC;MAC7DG,kBAAkB,CAACG,WAAW,GAAGJ,eAAe,CAACK,OAAO;MAExDd,EAAE,CAACe,aAAa,CACdZ,0BAA0B,EAC1BQ,IAAI,CAACK,SAAS,CAACN,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAC5C,CAAC;IACH;EACF,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CACV,kIAAkI,EAClIF,KACF,CAAC;EACH;AACF;AAEAG,OAAO,CAAClB,cAAc,GAAGA,cAAc","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["// properties set by the user in their app config file (e.g: app.json or app.plugin.js)\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n// Plugin options for pre-build\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n disableNotificationRegistration?: boolean;\n /**\n * @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.\n */\n handleNotificationClick?: boolean;\n showPushAppInForeground?: boolean;\n autoTrackPushEvents?: boolean;\n autoFetchDeviceToken?: boolean;\n handleDeeplinkInKilledState?: boolean;\n useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n provider?: 'apn' | 'fcm';\n googleServicesFile?: string;\n useRichPush: boolean;\n env: {\n cdpApiKey: string;\n region: string;\n };\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ /**
3
+ * Adds or updates string resources in Android's strings.xml required by the plugin
4
+ */
5
+ export declare const withProjectStrings: ConfigPlugin;
6
+ /**
7
+ * Adds or updates multiple string resources in Android's strings.xml
8
+ * @param stringsXml - Parsed strings.xml object
9
+ * @param stringResources - Array of string resources to add or update
10
+ * @returns Updated strings.xml object
11
+ */
12
+ export declare function addStringsToXml(stringsXml: any, stringResources: {
13
+ name: string;
14
+ value: string;
15
+ }[]): void;
@@ -0,0 +1,30 @@
1
+ export declare const LOCAL_PATH_TO_CIO_NSE_FILES: any;
2
+ export declare function getRelativePathToRNSDK(iosPath: string): any;
3
+ export declare const IOS_DEPLOYMENT_TARGET = "13.0";
4
+ export declare const GROUP_IDENTIFIER_TEMPLATE_REGEX: RegExp;
5
+ export declare const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX: RegExp;
6
+ export declare const BUNDLE_VERSION_TEMPLATE_REGEX: RegExp;
7
+ export declare const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX: RegExp;
8
+ export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX: RegExp;
9
+ export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX: RegExp;
10
+ export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX: RegExp;
11
+ export declare const CIO_APPDELEGATEDECLARATION_REGEX: RegExp;
12
+ export declare const CIO_APPDELEGATEHEADER_REGEX: RegExp;
13
+ export declare const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX: RegExp;
14
+ export declare const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX: RegExp;
15
+ export declare const CIO_DEEPLINK_COMMENT_REGEX: RegExp;
16
+ export declare const DEFAULT_BUNDLE_VERSION = "1";
17
+ export declare const DEFAULT_BUNDLE_SHORT_VERSION = "1.0";
18
+ export declare const CIO_TARGET_NAME = "CustomerIOSDK";
19
+ export declare const CIO_NOTIFICATION_TARGET_NAME = "NotificationService";
20
+ export declare const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = "#import <UserNotifications/UserNotifications.h>";
21
+ export declare const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = "UNUserNotificationCenterDelegate";
22
+ export declare const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = "\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n";
23
+ export declare const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = "\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n";
24
+ export declare const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = "\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];";
25
+ export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = "\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n";
26
+ export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = "\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n";
27
+ export declare const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = "\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n";
28
+ export declare 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";
29
+ export declare 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";
30
+ export declare 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 }";
@@ -1,5 +1,7 @@
1
1
  export declare function injectCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string[];
2
2
  export declare function injectCodeByMultiLineRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
3
+ export declare function injectCodeBeforeMultiLineRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
3
4
  export declare function replaceCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
5
+ export declare function matchRegexExists(fileContent: string, regex: RegExp): boolean;
4
6
  export declare function injectCodeByMultiLineRegexAndReplaceLine(fileContent: string, lineRegex: RegExp, snippet: string): string;
5
- export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string[];
7
+ export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string;
@@ -1,3 +1,3 @@
1
1
  import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';
2
- export declare function injectCIOPodfileCode(iosPath: string): Promise<void>;
3
- export declare function injectCIONotificationPodfileCode(iosPath: string, useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']): Promise<void>;
2
+ export declare function injectCIOPodfileCode(iosPath: string, isFcmPushProvider: boolean): Promise<void>;
3
+ export declare function injectCIONotificationPodfileCode(iosPath: string, useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'], isFcmPushProvider: boolean): Promise<void>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Reads the version of the plugin from its `package.json` and returns it as a string.
3
+ */
4
+ export declare const getPluginVersion: () => string;
@@ -0,0 +1,7 @@
1
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
2
+ /**
3
+ * Returns t
4
+ * @param iosOptions The plugin iOS configuration options
5
+ * @returns true if FCM is configured to be used as push provider
6
+ */
7
+ export declare const isFcmPushProvider: (iosOptions?: CustomerIOPluginOptionsIOS) => boolean;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
+ export declare const withGoogleServicesJsonFile: ConfigPlugin<CustomerIOPluginOptionsIOS>;
@@ -12,12 +12,21 @@ export type CustomerIOPluginOptionsIOS = {
12
12
  appleTeamId?: string;
13
13
  appName?: string;
14
14
  disableNotificationRegistration?: boolean;
15
+ /**
16
+ * @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.
17
+ */
18
+ handleNotificationClick?: boolean;
19
+ showPushAppInForeground?: boolean;
20
+ autoTrackPushEvents?: boolean;
21
+ autoFetchDeviceToken?: boolean;
22
+ handleDeeplinkInKilledState?: boolean;
15
23
  useFrameworks?: 'static' | 'dynamic';
16
24
  pushNotification?: {
25
+ provider?: 'apn' | 'fcm';
26
+ googleServicesFile?: string;
17
27
  useRichPush: boolean;
18
28
  env: {
19
- siteId: string;
20
- apiKey: string;
29
+ cdpApiKey: string;
21
30
  region: string;
22
31
  };
23
32
  };