customerio-expo-plugin 0.0.5 → 1.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/lib/commonjs/analytics/injectAnalytics.js +31 -0
  2. package/lib/commonjs/analytics/injectAnalytics.js.map +1 -0
  3. package/lib/commonjs/android/withAppGoogleServices.js +22 -0
  4. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -0
  5. package/lib/commonjs/android/withCIOAndroid.js +18 -0
  6. package/lib/commonjs/android/withCIOAndroid.js.map +1 -0
  7. package/lib/commonjs/android/withGistMavenRepository.js +21 -0
  8. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -0
  9. package/lib/commonjs/android/withGoogleServicesJSON.js +34 -0
  10. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -0
  11. package/lib/commonjs/android/withProjectGoogleServices.js +20 -0
  12. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -0
  13. package/lib/commonjs/helpers/constants/android.js +21 -0
  14. package/lib/commonjs/helpers/constants/android.js.map +1 -0
  15. package/lib/commonjs/helpers/constants/globals.d.js +2 -0
  16. package/lib/commonjs/helpers/constants/globals.d.js.map +1 -0
  17. package/lib/commonjs/helpers/constants/ios.js +140 -0
  18. package/lib/commonjs/helpers/constants/ios.js.map +1 -0
  19. package/{build/helpers/ios/CIONotificationService-Info.plist → lib/commonjs/helpers/native-files/ios/NotificationService-Info.plist} +2 -2
  20. package/{build/helpers/ios/CIONotificationService.h → lib/commonjs/helpers/native-files/ios/NotificationService.h} +0 -0
  21. package/{build/helpers/ios/CIONotificationService.m → lib/commonjs/helpers/native-files/ios/NotificationService.m} +2 -6
  22. package/{build/helpers/ios/CIONotificationService.swift → lib/commonjs/helpers/native-files/ios/NotificationService.swift} +0 -2
  23. package/{build/helpers → lib/commonjs/helpers/native-files}/ios/PushNotification.swift +1 -10
  24. package/lib/commonjs/helpers/utils/codeInjection.js +33 -0
  25. package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
  26. package/lib/commonjs/helpers/utils/fileManagement.js +76 -0
  27. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -0
  28. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +37 -0
  29. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  30. package/lib/commonjs/index.js +23 -0
  31. package/lib/commonjs/index.js.map +1 -0
  32. package/lib/commonjs/ios/withAppDelegateModifications.js +85 -0
  33. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
  34. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +79 -0
  35. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -0
  36. package/lib/commonjs/ios/withCIOIos.js +23 -0
  37. package/lib/commonjs/ios/withCIOIos.js.map +1 -0
  38. package/lib/commonjs/ios/withNotificationsXcodeProject.js +158 -0
  39. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
  40. package/lib/commonjs/ios/withXcodeProject.js +28 -0
  41. package/lib/commonjs/ios/withXcodeProject.js.map +1 -0
  42. package/lib/commonjs/types/cio-types.js +2 -0
  43. package/lib/commonjs/types/cio-types.js.map +1 -0
  44. package/lib/commonjs/version.js +9 -0
  45. package/lib/commonjs/version.js.map +1 -0
  46. package/lib/module/analytics/injectAnalytics.js +24 -0
  47. package/lib/module/analytics/injectAnalytics.js.map +1 -0
  48. package/lib/module/android/withAppGoogleServices.js +15 -0
  49. package/lib/module/android/withAppGoogleServices.js.map +1 -0
  50. package/lib/module/android/withCIOAndroid.js +12 -0
  51. package/lib/module/android/withCIOAndroid.js.map +1 -0
  52. package/lib/module/android/withGistMavenRepository.js +14 -0
  53. package/lib/module/android/withGistMavenRepository.js.map +1 -0
  54. package/lib/module/android/withGoogleServicesJSON.js +27 -0
  55. package/lib/module/android/withGoogleServicesJSON.js.map +1 -0
  56. package/lib/module/android/withProjectGoogleServices.js +13 -0
  57. package/lib/module/android/withProjectGoogleServices.js.map +1 -0
  58. package/lib/module/helpers/constants/android.js +8 -0
  59. package/lib/module/helpers/constants/android.js.map +1 -0
  60. package/lib/module/helpers/constants/globals.d.js +2 -0
  61. package/lib/module/helpers/constants/globals.d.js.map +1 -0
  62. package/lib/module/helpers/constants/ios.js +103 -0
  63. package/lib/module/helpers/constants/ios.js.map +1 -0
  64. package/lib/module/helpers/native-files/ios/NotificationService-Info.plist +31 -0
  65. package/lib/module/helpers/native-files/ios/NotificationService.h +5 -0
  66. package/lib/module/helpers/native-files/ios/NotificationService.m +26 -0
  67. package/lib/module/helpers/native-files/ios/NotificationService.swift +19 -0
  68. package/lib/module/helpers/native-files/ios/PushNotification.swift +47 -0
  69. package/lib/module/helpers/utils/codeInjection.js +24 -0
  70. package/lib/module/helpers/utils/codeInjection.js.map +1 -0
  71. package/lib/module/helpers/utils/fileManagement.js +69 -0
  72. package/lib/module/helpers/utils/fileManagement.js.map +1 -0
  73. package/lib/module/helpers/utils/injectCIOPodfileCode.js +30 -0
  74. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
  75. package/lib/module/index.js +16 -0
  76. package/lib/module/index.js.map +1 -0
  77. package/lib/module/ios/withAppDelegateModifications.js +78 -0
  78. package/lib/module/ios/withAppDelegateModifications.js.map +1 -0
  79. package/lib/module/ios/withAppDelegateXcodeProject.js +71 -0
  80. package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -0
  81. package/lib/module/ios/withCIOIos.js +17 -0
  82. package/lib/module/ios/withCIOIos.js.map +1 -0
  83. package/lib/module/ios/withNotificationsXcodeProject.js +150 -0
  84. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
  85. package/lib/module/ios/withXcodeProject.js +21 -0
  86. package/lib/module/ios/withXcodeProject.js.map +1 -0
  87. package/lib/module/types/cio-types.js +2 -0
  88. package/lib/module/types/cio-types.js.map +1 -0
  89. package/lib/module/version.js +2 -0
  90. package/lib/module/version.js.map +1 -0
  91. package/lib/typescript/analytics/injectAnalytics.d.ts +3 -0
  92. package/lib/typescript/android/withAppGoogleServices.d.ts +3 -0
  93. package/lib/typescript/android/withCIOAndroid.d.ts +3 -0
  94. package/lib/typescript/android/withGistMavenRepository.d.ts +3 -0
  95. package/lib/typescript/android/withGoogleServicesJSON.d.ts +3 -0
  96. package/lib/typescript/android/withProjectGoogleServices.d.ts +3 -0
  97. package/lib/typescript/helpers/constants/android.d.ts +7 -0
  98. package/lib/typescript/helpers/constants/ios.d.ts +31 -0
  99. package/lib/typescript/helpers/utils/codeInjection.d.ts +4 -0
  100. package/lib/typescript/helpers/utils/fileManagement.d.ts +12 -0
  101. package/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -0
  102. package/lib/typescript/index.d.ts +4 -0
  103. package/lib/typescript/ios/withAppDelegateModifications.d.ts +2 -0
  104. package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +3 -0
  105. package/lib/typescript/ios/withCIOIos.d.ts +3 -0
  106. package/lib/typescript/ios/withNotificationsXcodeProject.d.ts +3 -0
  107. package/lib/typescript/ios/withXcodeProject.d.ts +3 -0
  108. package/lib/typescript/types/cio-types.d.ts +25 -0
  109. package/lib/typescript/version.d.ts +1 -0
  110. package/package.json +88 -13
  111. package/src/analytics/injectAnalytics.ts +36 -0
  112. package/src/android/withAppGoogleServices.ts +26 -0
  113. package/src/android/withCIOAndroid.ts +19 -0
  114. package/src/android/withGistMavenRepository.ts +26 -0
  115. package/src/android/withGoogleServicesJSON.ts +36 -0
  116. package/src/android/withProjectGoogleServices.ts +24 -0
  117. package/src/helpers/constants/android.ts +14 -0
  118. package/src/helpers/constants/globals.d.ts +8 -0
  119. package/src/helpers/constants/ios.ts +116 -0
  120. package/src/helpers/native-files/ios/NotificationService-Info.plist +31 -0
  121. package/src/helpers/native-files/ios/NotificationService.h +5 -0
  122. package/src/helpers/native-files/ios/NotificationService.m +26 -0
  123. package/src/helpers/native-files/ios/NotificationService.swift +19 -0
  124. package/src/helpers/native-files/ios/PushNotification.swift +47 -0
  125. package/src/helpers/utils/codeInjection.ts +46 -0
  126. package/src/helpers/utils/fileManagement.ts +87 -0
  127. package/src/helpers/utils/injectCIOPodfileCode.ts +53 -0
  128. package/src/index.ts +26 -0
  129. package/src/ios/withAppDelegateModifications.ts +166 -0
  130. package/src/ios/withAppDelegateXcodeProject.ts +89 -0
  131. package/src/ios/withCIOIos.ts +25 -0
  132. package/src/ios/withNotificationsXcodeProject.ts +237 -0
  133. package/src/ios/withXcodeProject.ts +25 -0
  134. package/src/types/cio-types.ts +31 -0
  135. package/src/version.ts +1 -0
  136. package/build/helpers/.DS_Store +0 -0
  137. package/build/helpers/ios/.DS_Store +0 -0
  138. package/build/package.json +0 -36
  139. package/build/src/android/withAppGoogleServices.js +0 -12
  140. package/build/src/android/withCIOAndroid.js +0 -15
  141. package/build/src/android/withGistMavenRepository.js +0 -12
  142. package/build/src/android/withGoogleServicesJSON.js +0 -24
  143. package/build/src/android/withProjectGoogleServices.js +0 -12
  144. package/build/src/helpers/constants/android.js +0 -9
  145. package/build/src/helpers/constants/ios.js +0 -102
  146. package/build/src/helpers/utils/codeInjection.js +0 -30
  147. package/build/src/helpers/utils/fileManagement.js +0 -40
  148. package/build/src/helpers/utils/injectCIOPodfileCode.js +0 -37
  149. package/build/src/index.js +0 -11
  150. package/build/src/ios/withAppDelegateModifications.js +0 -77
  151. package/build/src/ios/withAppDelegateXcodeProject.js +0 -78
  152. package/build/src/ios/withCIOIos.js +0 -15
  153. package/build/src/ios/withNotificationsXcodeProject.js +0 -133
  154. package/build/src/ios/withXcodeProject.js +0 -22
  155. package/build/src/types/cio-types.js +0 -8
@@ -0,0 +1,78 @@
1
+ import { withAppDelegate } from '@expo/config-plugins';
2
+ import { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';
3
+ import { CIO_APPDELEGATEDECLARATION_REGEX, CIO_APPDELEGATEHEADER_REGEX, CIO_APPDELEGATEHEADER_SNIPPET, CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET, CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET, CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET, CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET } from '../helpers/constants/ios';
4
+ import { injectCodeByLineNumber, injectCodeByMultiLineRegex, injectCodeByMultiLineRegexAndReplaceLine } from '../helpers/utils/codeInjection';
5
+ import { FileManagement } from '../helpers/utils/fileManagement';
6
+ const pushCodeSnippets = [CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET, CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET];
7
+ const additionalMethodsForPushNotifications = `${pushCodeSnippets.join('\n')}\n`; // Join newlines and ensure a newline at the end.
8
+
9
+ const addImport = (stringContents, appName) => {
10
+ const importRegex = /^(#import .*)\n/gm;
11
+ const addedImport = getImportSnippet(appName);
12
+ const match = stringContents.match(importRegex);
13
+ let endOfMatchIndex;
14
+ if (!match || match.index === undefined) {
15
+ // No imports found, just add to start of file:
16
+ endOfMatchIndex = 0;
17
+ } else {
18
+ // Add after first import:
19
+ endOfMatchIndex = match.index + match[0].length;
20
+ }
21
+ stringContents = injectCodeByLineNumber(stringContents, endOfMatchIndex, addedImport).join('\n');
22
+ return stringContents;
23
+ };
24
+ const addNotificationHandlerDeclaration = stringContents => {
25
+ stringContents = injectCodeByMultiLineRegex(stringContents, CIO_APPDELEGATEDECLARATION_REGEX, CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET);
26
+ return stringContents;
27
+ };
28
+ const addNotificationConfiguration = stringContents => {
29
+ stringContents = injectCodeByMultiLineRegex(stringContents, CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET);
30
+ return stringContents;
31
+ };
32
+ const addDidFailToRegisterForRemoteNotificationsWithError = stringContents => {
33
+ stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET);
34
+ return stringContents;
35
+ };
36
+ const AddDidRegisterForRemoteNotificationsWithDeviceToken = stringContents => {
37
+ stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET);
38
+ return stringContents;
39
+ };
40
+ const addAdditionalMethodsForPushNotifications = stringContents => {
41
+ stringContents = injectCodeByMultiLineRegex(stringContents, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX, additionalMethodsForPushNotifications);
42
+ return stringContents;
43
+ };
44
+ const addAppdelegateHeaderModification = stringContents => {
45
+ stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_APPDELEGATEHEADER_REGEX, CIO_APPDELEGATEHEADER_SNIPPET);
46
+ return stringContents;
47
+ };
48
+ export const withAppDelegateModifications = configOuter => {
49
+ return withAppDelegate(configOuter, async config => {
50
+ let stringContents = config.modResults.contents;
51
+ const regex = new RegExp(`#import <${config.modRequest.projectName}-Swift.h>`);
52
+ const match = stringContents.match(regex);
53
+ if (!match) {
54
+ const headerPath = getAppDelegateHeaderFilePath(config.modRequest.projectRoot);
55
+ let headerContent = await FileManagement.read(headerPath);
56
+ headerContent = addAppdelegateHeaderModification(headerContent);
57
+ FileManagement.write(headerPath, headerContent);
58
+ stringContents = addImport(stringContents, config.modRequest.projectName);
59
+ stringContents = addNotificationHandlerDeclaration(stringContents);
60
+ stringContents = addNotificationConfiguration(stringContents);
61
+ stringContents = addAdditionalMethodsForPushNotifications(stringContents);
62
+ stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
63
+ stringContents = AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
64
+ config.modResults.contents = stringContents;
65
+ } else {
66
+ console.log('Customerio AppDelegate changes already exist. Skipping...');
67
+ }
68
+ return config;
69
+ });
70
+ };
71
+ function getImportSnippet(appName) {
72
+ return `
73
+ // Add swift bridge imports
74
+ #import <ExpoModulesCore-Swift.h>
75
+ #import <${appName}-Swift.h>
76
+ `;
77
+ }
78
+ //# sourceMappingURL=withAppDelegateModifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","FileManagement","pushCodeSnippets","additionalMethodsForPushNotifications","join","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addDidFailToRegisterForRemoteNotificationsWithError","AddDidRegisterForRemoteNotificationsWithDeviceToken","addAdditionalMethodsForPushNotifications","addAppdelegateHeaderModification","withAppDelegateModifications","configOuter","config","modResults","contents","regex","RegExp","modRequest","projectName","headerPath","projectRoot","headerContent","read","write","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_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\n\nconst pushCodeSnippets = [\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n];\n\nconst additionalMethodsForPushNotifications = `${pushCodeSnippets.join(\n '\\n'\n)}\\n`; // Join newlines and ensure a newline at the end.\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 ).join('\\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 = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_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\nconst addAdditionalMethodsForPushNotifications = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n additionalMethodsForPushNotifications\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET\n );\n\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<any> = (\n configOuter\n) => {\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 stringContents = addNotificationConfiguration(stringContents);\n stringContents = addAdditionalMethodsForPushNotifications(stringContents);\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n AddDidRegisterForRemoteNotificationsWithDeviceToken(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,2BAA2B,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,aAAa,GAAGZ,gCAAgC,CAACY,aAAa,CAAC;MAC/DhC,cAAc,CAACkC,KAAK,CAACJ,UAAU,EAAEE,aAAa,CAAC;MAE/C3B,cAAc,GAAGD,SAAS,CACxBC,cAAc,EACdkB,MAAM,CAACK,UAAU,CAACC,WAAW,CAC9B;MACDxB,cAAc,GAAGU,iCAAiC,CAACV,cAAc,CAAC;MAClEA,cAAc,GAAGW,4BAA4B,CAACX,cAAc,CAAC;MAC7DA,cAAc,GAAGc,wCAAwC,CAACd,cAAc,CAAC;MACzEA,cAAc,GACZY,mDAAmD,CAACZ,cAAc,CAAC;MACrEA,cAAc,GACZa,mDAAmD,CAACb,cAAc,CAAC;MAErEkB,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGpB,cAAc;IAC7C,CAAC,MAAM;MACL8B,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOb,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AACD,SAASd,gBAAgB,CAACH,OAAe,EAAE;EACzC,OAAQ;AACV;AACA;AACA,WAAWA,OAAQ;AACnB,GAAG;AACH"}
@@ -0,0 +1,71 @@
1
+ import { withXcodeProject } from '@expo/config-plugins';
2
+ import xcode from 'xcode';
3
+ import { DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
4
+ import { FileManagement } from './../helpers/utils/fileManagement';
5
+ const addNotificationSwiftFile = async options => {
6
+ const {
7
+ iosPath,
8
+ appName
9
+ } = options;
10
+ const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
11
+ const xcodeProject = xcode.project(projPath);
12
+ xcodeProject.parse(async function (err) {
13
+ const file = 'PushNotification.swift';
14
+ const getTargetFile = filename => `${iosPath}/${appName}/${filename}`;
15
+ if (err) {
16
+ throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
17
+ }
18
+ if (!FileManagement.exists(getTargetFile(file))) {
19
+ FileManagement.mkdir(`${iosPath}/${appName}`, {
20
+ recursive: true
21
+ });
22
+ const targetFile = getTargetFile(file);
23
+ FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
24
+ } else {
25
+ console.log(`${getTargetFile(file)} already exists. Skipping...`);
26
+ }
27
+ });
28
+ };
29
+ export const withCioAppdelegateXcodeProject = (configOuter, props) => {
30
+ return withXcodeProject(configOuter, async config => {
31
+ const {
32
+ modRequest,
33
+ ios,
34
+ version: bundleShortVersion
35
+ } = config;
36
+ const {
37
+ appleTeamId,
38
+ iosDeploymentTarget
39
+ } = props;
40
+ if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js.');
41
+ const {
42
+ projectName,
43
+ platformProjectRoot
44
+ } = modRequest;
45
+ const {
46
+ bundleIdentifier,
47
+ buildNumber
48
+ } = ios;
49
+ if (bundleShortVersion === undefined) {
50
+ throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js');
51
+ }
52
+ if (bundleIdentifier === undefined) {
53
+ throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js');
54
+ }
55
+ if (projectName === undefined) {
56
+ throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js');
57
+ }
58
+ const options = {
59
+ appleTeamId,
60
+ bundleIdentifier,
61
+ bundleShortVersion,
62
+ bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,
63
+ iosPath: platformProjectRoot,
64
+ appName: projectName,
65
+ iosDeploymentTarget
66
+ };
67
+ await addNotificationSwiftFile(options);
68
+ return config;
69
+ });
70
+ };
71
+ //# sourceMappingURL=withAppDelegateXcodeProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withXcodeProject","xcode","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","FileManagement","addNotificationSwiftFile","options","iosPath","appName","projPath","xcodeProject","project","parse","err","file","getTargetFile","filename","Error","JSON","stringify","exists","mkdir","recursive","targetFile","copyFile","console","log","withCioAppdelegateXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","undefined","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion"],"sources":["withAppDelegateXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport xcode from 'xcode';\n\nimport {\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst addNotificationSwiftFile = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const { iosPath, appName } = options;\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n const file = 'PushNotification.swift';\n const getTargetFile = (filename: string) =>\n `${iosPath}/${appName}/${filename}`;\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(`${iosPath}/${appName}`, {\n recursive: true,\n });\n\n const targetFile = getTargetFile(file);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(file)} already exists. Skipping...`);\n }\n });\n};\n\nexport const withCioAppdelegateXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js.'\n );\n\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'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js'\n );\n }\n\n const options = {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n iosDeploymentTarget,\n };\n\n await addNotificationSwiftFile(options);\n\n return config;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AAEjC,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,wBAAwB,GAAG,MAC/BC,OAAmC,IAChC;EACH,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EACpC,MAAMG,QAAQ,GAAI,GAAEF,OAAQ,IAAGC,OAAQ,4BAA2B;EAClE,MAAME,YAAY,GAAGT,KAAK,CAACU,OAAO,CAACF,QAAQ,CAAC;EAE5CC,YAAY,CAACE,KAAK,CAAC,gBAAgBC,GAAU,EAAE;IAC7C,MAAMC,IAAI,GAAG,wBAAwB;IACrC,MAAMC,aAAa,GAAIC,QAAgB,IACpC,GAAET,OAAQ,IAAGC,OAAQ,IAAGQ,QAAS,EAAC;IACrC,IAAIH,GAAG,EAAE;MACP,MAAM,IAAII,KAAK,CAAE,8BAA6BC,IAAI,CAACC,SAAS,CAACN,GAAG,CAAE,EAAC,CAAC;IACtE;IAEA,IAAI,CAACT,cAAc,CAACgB,MAAM,CAACL,aAAa,CAACD,IAAI,CAAC,CAAC,EAAE;MAC/CV,cAAc,CAACiB,KAAK,CAAE,GAAEd,OAAQ,IAAGC,OAAQ,EAAC,EAAE;QAC5Cc,SAAS,EAAE;MACb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wBAAwB,CAACC,OAAO,CAAC;IAEvC,OAAOwB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { withAppDelegateModifications } from './withAppDelegateModifications';
2
+ import { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';
3
+ import { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';
4
+ import { withCioXcodeProject } from './withXcodeProject';
5
+ export function withCIOIos(config, props) {
6
+ var _props$pushNotificati;
7
+ if ((_props$pushNotificati = props.pushNotification) !== null && _props$pushNotificati !== void 0 && _props$pushNotificati.useRichPush) {
8
+ config = withCioNotificationsXcodeProject(config, props);
9
+ }
10
+ if (props.pushNotification) {
11
+ config = withAppDelegateModifications(config, props);
12
+ config = withCioAppdelegateXcodeProject(config, props);
13
+ }
14
+ config = withCioXcodeProject(config, props);
15
+ return config;
16
+ }
17
+ //# sourceMappingURL=withCIOIos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withAppDelegateModifications","withCioAppdelegateXcodeProject","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","props","pushNotification","useRichPush"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification?.useRichPush) {\n config = withCioNotificationsXcodeProject(config, props);\n }\n\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioAppdelegateXcodeProject(config, props);\n }\n\n config = withCioXcodeProject(config, props);\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,8BAA8B,QAAQ,+BAA+B;AAC9E,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAU,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EAAA;EACA,6BAAIA,KAAK,CAACC,gBAAgB,kDAAtB,sBAAwBC,WAAW,EAAE;IACvCH,MAAM,GAAGH,gCAAgC,CAACG,MAAM,EAAEC,KAAK,CAAC;EAC1D;EAEA,IAAIA,KAAK,CAACC,gBAAgB,EAAE;IAC1BF,MAAM,GAAGL,4BAA4B,CAACK,MAAM,EAAEC,KAAK,CAAC;IACpDD,MAAM,GAAGJ,8BAA8B,CAACI,MAAM,EAAEC,KAAK,CAAC;EACxD;EAEAD,MAAM,GAAGF,mBAAmB,CAACE,MAAM,EAAEC,KAAK,CAAC;EAE3C,OAAOD,MAAM;AACf"}
@@ -0,0 +1,150 @@
1
+ import { withXcodeProject } from '@expo/config-plugins';
2
+ import xcode from 'xcode';
3
+ import { CIO_NOTIFICATION_TARGET_NAME, DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
4
+ import { injectCodeByMultiLineRegex } from '../helpers/utils/codeInjection';
5
+ import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
6
+ import { FileManagement } from './../helpers/utils/fileManagement';
7
+ const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
8
+ const TARGETED_DEVICE_FAMILY = `"1,2"`;
9
+ const addNotificationServiceExtension = async options => {
10
+ const {
11
+ appleTeamId,
12
+ bundleIdentifier,
13
+ bundleShortVersion,
14
+ bundleVersion,
15
+ iosPath,
16
+ appName,
17
+ iosDeploymentTarget
18
+ } = options;
19
+ const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
20
+ const xcodeProject = xcode.project(projPath);
21
+ xcodeProject.parse(async function (err) {
22
+ if (err) {
23
+ throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
24
+ }
25
+ await injectCIONotificationPodfileCode(iosPath);
26
+ FileManagement.mkdir(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {
27
+ recursive: true
28
+ });
29
+ const files = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.swift', 'NotificationService.m'];
30
+ const getTargetFile = filename => `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${filename}`;
31
+ files.forEach(filename => {
32
+ const targetFile = getTargetFile(filename);
33
+ FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
34
+ });
35
+
36
+ /* MODIFY COPIED EXTENSION FILES */
37
+ const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);
38
+ updateNseInfoPlist({
39
+ bundleVersion,
40
+ bundleShortVersion,
41
+ infoPlistTargetFile
42
+ });
43
+
44
+ // Create new PBXGroup for the extension
45
+ const extGroup = xcodeProject.addPbxGroup(files, CIO_NOTIFICATION_TARGET_NAME, CIO_NOTIFICATION_TARGET_NAME);
46
+
47
+ // Add the new PBXGroup to the top level group. This makes the
48
+ // files / folder appear in the file explorer in Xcode.
49
+ const groups = xcodeProject.hash.project.objects['PBXGroup'];
50
+ Object.keys(groups).forEach(key => {
51
+ if (groups[key].name === undefined) {
52
+ xcodeProject.addToPbxGroup(extGroup.uuid, key);
53
+ }
54
+ });
55
+
56
+ // WORK AROUND for codeProject.addTarget BUG
57
+ // Xcode projects don't contain these if there is only one target
58
+ // An upstream fix should be made to the code referenced in this link:
59
+ // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
60
+ const projObjects = xcodeProject.hash.project.objects;
61
+ projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
62
+ projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
63
+ if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
64
+ console.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
65
+ return;
66
+ }
67
+
68
+ // Add the NSE target
69
+ // This also adds PBXTargetDependency and PBXContainerItemProxy
70
+ const nseTarget = xcodeProject.addTarget(CIO_NOTIFICATION_TARGET_NAME, 'app_extension', CIO_NOTIFICATION_TARGET_NAME, `${bundleIdentifier}.richpush`);
71
+
72
+ // Add build phases to the new target
73
+ xcodeProject.addBuildPhase(['NotificationService.m', 'NotificationService.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
74
+ xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
75
+ xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
76
+
77
+ // Edit the Deployment info of the target
78
+ const configurations = xcodeProject.pbxXCBuildConfigurationSection();
79
+ for (const key in configurations) {
80
+ if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${CIO_NOTIFICATION_TARGET_NAME}"`) {
81
+ const buildSettingsObj = configurations[key].buildSettings;
82
+ buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
83
+ buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
84
+ buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
85
+ buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
86
+ buildSettingsObj.SWIFT_VERSION = 4.2;
87
+ }
88
+ }
89
+
90
+ // Add development team to the target & the main
91
+ xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
92
+ xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
93
+ FileManagement.writeFile(projPath, xcodeProject.writeSync());
94
+ });
95
+ };
96
+ export const withCioNotificationsXcodeProject = (configOuter, props) => {
97
+ return withXcodeProject(configOuter, async config => {
98
+ const {
99
+ modRequest,
100
+ ios,
101
+ version: bundleShortVersion
102
+ } = config;
103
+ const {
104
+ appleTeamId,
105
+ iosDeploymentTarget
106
+ } = props;
107
+ if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.');
108
+ const {
109
+ projectName,
110
+ platformProjectRoot
111
+ } = modRequest;
112
+ const {
113
+ bundleIdentifier,
114
+ buildNumber
115
+ } = ios;
116
+ if (bundleShortVersion === undefined) {
117
+ throw new Error('Adding NotificationServiceExtension failed: version missing from app.config.js or app.json');
118
+ }
119
+ if (bundleIdentifier === undefined) {
120
+ throw new Error('Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json');
121
+ }
122
+ if (projectName === undefined) {
123
+ throw new Error('Adding NotificationServiceExtension failed: name missing from app.config.js or app.json');
124
+ }
125
+ const options = {
126
+ appleTeamId,
127
+ bundleIdentifier,
128
+ bundleShortVersion,
129
+ bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,
130
+ iosPath: platformProjectRoot,
131
+ appName: projectName,
132
+ iosDeploymentTarget
133
+ };
134
+ await addNotificationServiceExtension(options);
135
+ return config;
136
+ });
137
+ };
138
+ const updateNseInfoPlist = payload => {
139
+ const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
140
+ const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
141
+ let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);
142
+ if (payload.bundleVersion) {
143
+ plistFileString = injectCodeByMultiLineRegex(plistFileString, BUNDLE_VERSION_RE, payload.bundleVersion);
144
+ }
145
+ if (payload.bundleShortVersion) {
146
+ plistFileString = injectCodeByMultiLineRegex(plistFileString, BUNDLE_SHORT_VERSION_RE, payload.bundleShortVersion);
147
+ }
148
+ FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
149
+ };
150
+ //# sourceMappingURL=withNotificationsXcodeProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withXcodeProject","xcode","CIO_NOTIFICATION_TARGET_NAME","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","injectCodeByMultiLineRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","appleTeamId","bundleIdentifier","bundleShortVersion","bundleVersion","iosPath","appName","iosDeploymentTarget","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","extGroup","addPbxGroup","groups","hash","objects","Object","keys","key","name","undefined","addToPbxGroup","uuid","projObjects","pbxTargetByName","console","warn","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","writeFile","writeSync","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","projectName","platformProjectRoot","buildNumber","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport xcode from 'xcode';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { injectCodeByMultiLineRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n appName,\n iosDeploymentTarget,\n } = options;\n\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n await injectCIONotificationPodfileCode(iosPath);\n\n FileManagement.mkdir(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ];\n\n const getTargetFile = (filename: string) =>\n `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${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\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n 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) {\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'] =\n 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'],\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 || '13.0';\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 FileManagement.writeFile(projPath, xcodeProject.writeSync());\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 { appleTeamId, iosDeploymentTarget } = 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 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 appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n iosDeploymentTarget,\n };\n\n await addNotificationServiceExtension(options);\n\n return config;\n });\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 = injectCodeByMultiLineRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = injectCodeByMultiLineRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);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EAAE;IACzBkE,eAAe,GAAG5E,0BAA0B,CAC1C4E,eAAe,EACfD,iBAAiB,EACjBF,OAAO,CAAC/D,aAAa,CACtB;EACH;EAEA,IAAI+D,OAAO,CAAChE,kBAAkB,EAAE;IAC9BmE,eAAe,GAAG5E,0BAA0B,CAC1C4E,eAAe,EACfF,uBAAuB,EACvBD,OAAO,CAAChE,kBAAkB,CAC3B;EACH;EAEAP,cAAc,CAAC2D,SAAS,CAACY,OAAO,CAAC3C,mBAAmB,EAAE8C,eAAe,CAAC;AACxE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { withXcodeProject } from '@expo/config-plugins';
2
+ import { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
3
+ export const withCioXcodeProject = (config, cioProps) => {
4
+ return withXcodeProject(config, async props => {
5
+ var _props$ios, _props$ios2;
6
+ const options = {
7
+ iosPath: props.modRequest.platformProjectRoot,
8
+ bundleIdentifier: (_props$ios = props.ios) === null || _props$ios === void 0 ? void 0 : _props$ios.bundleIdentifier,
9
+ devTeam: cioProps === null || cioProps === void 0 ? void 0 : cioProps.devTeam,
10
+ bundleVersion: (_props$ios2 = props.ios) === null || _props$ios2 === void 0 ? void 0 : _props$ios2.buildNumber,
11
+ bundleShortVersion: props === null || props === void 0 ? void 0 : props.version,
12
+ iosDeploymentTarget: cioProps === null || cioProps === void 0 ? void 0 : cioProps.iosDeploymentTarget
13
+ };
14
+ const {
15
+ iosPath
16
+ } = options;
17
+ await injectCIOPodfileCode(iosPath);
18
+ return props;
19
+ });
20
+ };
21
+ //# sourceMappingURL=withXcodeProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withXcodeProject","injectCIOPodfileCode","withCioXcodeProject","config","cioProps","props","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';\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);\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AAErE,SAASC,oBAAoB,QAAQ,uCAAuC;AAG5E,OAAO,MAAMC,mBAA6D,GAAG,CAC3EC,MAAM,EACNC,QAAQ,KACL;EACH,OAAOJ,gBAAgB,CAACG,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA;IAC/C,MAAMC,OAAmC,GAAG;MAC1CC,OAAO,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MAC7CC,gBAAgB,gBAAEL,KAAK,CAACM,GAAG,+CAAT,WAAWD,gBAAgB;MAC7CE,OAAO,EAAER,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEQ,OAAO;MAC1BC,aAAa,iBAAER,KAAK,CAACM,GAAG,gDAAT,YAAWG,WAAW;MACrCC,kBAAkB,EAAEV,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEW,OAAO;MAClCC,mBAAmB,EAAEb,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEa;IACjC,CAAC;IACD,MAAM;MAAEV;IAAQ,CAAC,GAAGD,OAAO;IAE3B,MAAML,oBAAoB,CAACM,OAAO,CAAC;IAEnC,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=cio-types.js.map
@@ -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 pushNotification?: {\n useRichPush: boolean;\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFilePath?: string;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export const LIB_VERSION = "1.0.0-alpha.2";
2
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LIB_VERSION"],"sources":["version.ts"],"sourcesContent":["export const LIB_VERSION = \"1.0.0-alpha.2\";\n"],"mappings":"AAAA,OAAO,MAAMA,WAAW,GAAG,eAAe"}
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptions } from '../types/cio-types';
3
+ export declare const withAnalytics: ConfigPlugin<CustomerIOPluginOptions>;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
3
+ export declare const withAppGoogleServices: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -0,0 +1,3 @@
1
+ import type { ExpoConfig } from '@expo/config-types';
2
+ import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
3
+ export declare function withCIOAndroid(config: ExpoConfig, props: CustomerIOPluginOptionsAndroid): ExpoConfig;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
3
+ export declare const withGistMavenRepository: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
3
+ export declare const withGoogleServicesJSON: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
3
+ export declare const withProjectGoogleServices: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
@@ -0,0 +1,7 @@
1
+ export declare const CIO_PROJECT_BUILDSCRIPTS_REGEX: RegExp;
2
+ export declare const CIO_APP_APPLY_REGEX: RegExp;
3
+ export declare const CIO_GIST_MAVEN_REGEX: RegExp;
4
+ export declare const CIO_PROJECT_ALLPROJECTS_REGEX: RegExp;
5
+ export declare const CIO_PROJECT_GIST_MAVEN_SNIPPET = " maven { url \"https://maven.gist.build\" }";
6
+ export declare const CIO_APP_GOOGLE_SNIPPET = "apply plugin: \"com.google.gms.google-services\" // Google Services plugin";
7
+ export declare const CIO_PROJECT_GOOGLE_SNIPPET = " classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin";
@@ -0,0 +1,31 @@
1
+ export declare const LOCAL_PATH_TO_CIO_NSE_FILES = "node_modules/customerio-expo-plugin/src/helpers/native-files/ios";
2
+ export declare const IOS_DEPLOYMENT_TARGET = "13.0";
3
+ export declare const CIO_PODFILE_REGEX: RegExp;
4
+ export declare const CIO_CIO_TARGET_REGEX: RegExp;
5
+ export declare const CIO_PODFILE_NOTIFICATION_REGEX: RegExp;
6
+ export declare const GROUP_IDENTIFIER_TEMPLATE_REGEX: RegExp;
7
+ export declare const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX: RegExp;
8
+ export declare const BUNDLE_VERSION_TEMPLATE_REGEX: RegExp;
9
+ export declare const CIO_PODFILE_POST_INSTALL_REGEX: RegExp;
10
+ export declare const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX: RegExp;
11
+ export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX: RegExp;
12
+ export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX: RegExp;
13
+ export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX: RegExp;
14
+ export declare const CIO_APPDELEGATEDECLARATION_REGEX: RegExp;
15
+ export declare const CIO_APPDELEGATEHEADER_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_SNIPPET = "\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n";
21
+ export declare const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = "\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n";
22
+ export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = "\n [pnHandlerObj application:application error:error];\n";
23
+ export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = "\n return [pnHandlerObj application:application deviceToken:deviceToken];\n";
24
+ export declare const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = "\n // Register for push notifications\n [pnHandlerObj registerPushNotification:self];\n";
25
+ export declare const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = "\n- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {\n [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];\n}";
26
+ export declare const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = "\n// show push when the app is in foreground\n- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {\n completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);\n}";
27
+ export declare const CIO_PODFILE_NOTIFICATION_SNIPPET: string;
28
+ export declare const CIO_PODFILE_SNIPPET = "\n pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec'\n pod 'boost', :podspec => '../node_modules/react-native/third-party-podspecs/boost.podspec'\n pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'";
29
+ export declare const CIO_PODFILE_TARGET_NAMES_SNIPPET = "\n cio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n ]";
30
+ export declare const CIO_PODFILE_POST_INSTALL_SNIPPET = "\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end";
31
+ export declare const CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = "\ncio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n]\n\npost_install do |installer|\n\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end\n react_native_post_install(installer)\n __apply_Xcode_12_5_M1_post_install_workaround(installer)\nend";
@@ -0,0 +1,4 @@
1
+ export declare function injectCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string[];
2
+ export declare function injectCodeByMultiLineRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
3
+ export declare function injectCodeByMultiLineRegexAndReplaceLine(fileContent: string, lineRegex: RegExp, snippet: string): string;
4
+ export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string[];
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { MakeDirectoryOptions } from 'fs';
3
+ export declare class FileManagement {
4
+ static read(path: string): Promise<string>;
5
+ static write(path: string, contents: string): Promise<void>;
6
+ static append(path: string, contents: string): Promise<void>;
7
+ static exists(path: string): boolean;
8
+ static copyFile(src: string, dest: string): void;
9
+ static mkdir(path: string, options: MakeDirectoryOptions): void;
10
+ static writeFile(path: string, data: string): void;
11
+ static readFile(path: string): string;
12
+ }
@@ -0,0 +1,2 @@
1
+ export declare function injectCIOPodfileCode(iosPath: string): Promise<void>;
2
+ export declare function injectCIONotificationPodfileCode(iosPath: string): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import type { ExpoConfig } from '@expo/config-types';
2
+ import type { CustomerIOPluginOptions } from './types/cio-types';
3
+ declare function withCustomerIOPlugin(config: ExpoConfig, props: CustomerIOPluginOptions): ExpoConfig;
4
+ export default withCustomerIOPlugin;
@@ -0,0 +1,2 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ export declare const withAppDelegateModifications: ConfigPlugin<any>;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
+ export declare const withCioAppdelegateXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS>;
@@ -0,0 +1,3 @@
1
+ import type { ExpoConfig } from '@expo/config-types';
2
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
+ export declare function withCIOIos(config: ExpoConfig, props: CustomerIOPluginOptionsIOS): ExpoConfig;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
+ export declare const withCioNotificationsXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS>;
@@ -0,0 +1,3 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
3
+ export declare const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS>;
@@ -0,0 +1,25 @@
1
+ export declare type CustomerIOPluginProperties = {
2
+ devTeam: string;
3
+ iosDeploymentTarget: string;
4
+ };
5
+ export declare type CustomerIOPluginOptionsIOS = {
6
+ iosPath: string;
7
+ devTeam?: string;
8
+ bundleVersion?: string;
9
+ bundleShortVersion?: string;
10
+ bundleIdentifier?: string;
11
+ iosDeploymentTarget?: string;
12
+ appleTeamId?: string;
13
+ appName?: string;
14
+ pushNotification?: {
15
+ useRichPush: boolean;
16
+ };
17
+ };
18
+ export declare type CustomerIOPluginOptionsAndroid = {
19
+ androidPath: string;
20
+ googleServicesFilePath?: string;
21
+ };
22
+ export declare type CustomerIOPluginOptions = {
23
+ android: CustomerIOPluginOptionsAndroid;
24
+ ios: CustomerIOPluginOptionsIOS;
25
+ };
@@ -0,0 +1 @@
1
+ export declare const LIB_VERSION = "1.0.0-alpha.2";