customerio-expo-plugin 1.0.0-beta.1 → 1.0.0-beta.11

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 (65) hide show
  1. package/README.md +5 -166
  2. package/lib/commonjs/android/withAndroidManifestUpdates.js +37 -0
  3. package/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -0
  4. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
  5. package/lib/commonjs/android/withCIOAndroid.js +4 -0
  6. package/lib/commonjs/android/withCIOAndroid.js.map +1 -1
  7. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
  8. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  9. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
  10. package/lib/commonjs/helpers/constants/android.js.map +1 -1
  11. package/lib/commonjs/helpers/constants/ios.js +25 -25
  12. package/lib/commonjs/helpers/constants/ios.js.map +1 -1
  13. package/lib/commonjs/helpers/native-files/ios/PushService.swift +1 -13
  14. package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -1
  15. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
  16. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +28 -15
  17. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  18. package/lib/commonjs/index.js.map +1 -1
  19. package/lib/commonjs/ios/withAppDelegateModifications.js +8 -4
  20. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  21. package/lib/commonjs/ios/withCIOIos.js.map +1 -1
  22. package/lib/commonjs/ios/withNotificationsXcodeProject.js +48 -27
  23. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  24. package/lib/commonjs/ios/withXcodeProject.js.map +1 -1
  25. package/lib/commonjs/postInstall.js.map +1 -1
  26. package/lib/commonjs/postInstallHelper.js.map +1 -1
  27. package/lib/commonjs/types/cio-types.js.map +1 -1
  28. package/lib/module/android/withAndroidManifestUpdates.js +30 -0
  29. package/lib/module/android/withAndroidManifestUpdates.js.map +1 -0
  30. package/lib/module/android/withAppGoogleServices.js.map +1 -1
  31. package/lib/module/android/withCIOAndroid.js +4 -0
  32. package/lib/module/android/withCIOAndroid.js.map +1 -1
  33. package/lib/module/android/withGistMavenRepository.js.map +1 -1
  34. package/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  35. package/lib/module/android/withProjectGoogleServices.js.map +1 -1
  36. package/lib/module/helpers/constants/ios.js +23 -16
  37. package/lib/module/helpers/constants/ios.js.map +1 -1
  38. package/lib/module/helpers/native-files/ios/PushService.swift +1 -13
  39. package/lib/module/helpers/utils/codeInjection.js.map +1 -1
  40. package/lib/module/helpers/utils/fileManagement.js.map +1 -1
  41. package/lib/module/helpers/utils/injectCIOPodfileCode.js +28 -15
  42. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/module/ios/withAppDelegateModifications.js +8 -4
  45. package/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  46. package/lib/module/ios/withCIOIos.js.map +1 -1
  47. package/lib/module/ios/withNotificationsXcodeProject.js +49 -27
  48. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  49. package/lib/module/ios/withXcodeProject.js.map +1 -1
  50. package/lib/module/postInstall.js.map +1 -1
  51. package/lib/module/postInstallHelper.js.map +1 -1
  52. package/lib/module/types/cio-types.js.map +1 -1
  53. package/lib/typescript/android/withAndroidManifestUpdates.d.ts +3 -0
  54. package/lib/typescript/helpers/constants/ios.d.ts +4 -11
  55. package/lib/typescript/ios/withAppDelegateModifications.d.ts +2 -1
  56. package/lib/typescript/types/cio-types.d.ts +2 -0
  57. package/package.json +5 -2
  58. package/src/android/withAndroidManifestUpdates.ts +49 -0
  59. package/src/android/withCIOAndroid.ts +4 -0
  60. package/src/helpers/constants/ios.ts +28 -16
  61. package/src/helpers/native-files/ios/PushService.swift +1 -13
  62. package/src/helpers/utils/injectCIOPodfileCode.ts +40 -32
  63. package/src/ios/withAppDelegateModifications.ts +14 -6
  64. package/src/ios/withNotificationsXcodeProject.ts +76 -28
  65. package/src/types/cio-types.ts +2 -0
package/README.md CHANGED
@@ -5,180 +5,19 @@
5
5
  <p align="center">Power automated communication that people like to receive.</p>
6
6
  </p>
7
7
 
8
- ![min swift version is 5.3](https://img.shields.io/badge/min%20Swift%20version-5.3-orange)
9
- ![min ios version is 13](https://img.shields.io/badge/min%20iOS%20version-13-blue)
10
8
  [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](code_of_conduct.md)
11
- [![codecov](https://codecov.io/gh/customerio/customerio-expo-plugin/branch/develop/graph/badge.svg?token=IZ9RP9XD1O)](https://codecov.io/gh/customerio/customerio-expo-plugin)
12
9
 
13
10
  # Customer.io Expo Plugin
14
11
 
15
12
  This is the official Customer.io Expo plugin, supporting mobile apps.
16
13
 
17
- You'll find our [complete SDK documentation at https://customer.io/docs/sdk/expo](https://customer.io/docs/sdk/expo/). This readme only contains basic information to help you install the plugin and handle the pre-build.
14
+ The Expo plugin takes advantage of our [React Native SDK](https://github.com/customerio/customerio-reactnative), and requires very little setup. It extends the Expo config to let you customize the pre-build phase of managed workflow builds, which means you don't need to eject to a bare workflow.
18
15
 
19
- The Expo plugin takes advantage of our [React Native SDK](https://github.com/customerio/customerio-reactnative), and requires very little setup. It extends the Expo config to let you customize the prebuild phase of managed workflow builds, which means you don't need to eject to a bare workflow.
16
+ After you add the plugin to your project, you'll need to install our React Native SDK and run pre-build. The plugin automatically generates and configures the necessary native code files required to make our React Native SDK to work on your project.
20
17
 
21
- After you add the plugin to your project, you'll need to install our React Native SDK and run prebuild. The plugin automatically generates and configures the necessary native code files required to make our React Native SDK to work on your project. We've tested with Expo SDK versions `45` and `46`, Using `eas` build with EAS managed credentials and a limited set of Android and iOS versions.
18
+ # Getting started
22
19
 
23
- By default, the plugin expects to use Apple's Push Notification service (APNs) for iOS and Firebase Cloud Messaging (FCM) for Android. We plan to add FCM support for iOS in a future release.
24
-
25
- # Install and configure the plugin
26
-
27
- 1. Run an installation command:
28
- * `expo install customerio-expo-plugin`
29
- * `npm install customerio-expo-plugin`
30
- * `yarn add customerio-expo-plugin`
31
-
32
- 1. Add `customerio-expo-plugin` plugin in your `app.json` or `app.config.js` and set configuration options. In most cases, you'll want to stick to our default options. When you configure the plugin, you can [pass options](#plugin-configuration-options). In most cases, you'll want to stick with the defaults, which enables all the SDK features. However you might want to disable rich push for `iOS`.
33
- ```json
34
- // app.json
35
- {
36
- ...
37
- "plugins": [
38
- ...
39
- [
40
- "customerio-expo-plugin",
41
- {
42
- "android": {
43
- "googleServicesFile": "./files/google-services.json",
44
- },
45
- "ios": {
46
- "pushNotification": {
47
- "useRichPush": true
48
- }
49
- }
50
- }
51
- ]
52
- ]
53
- }
54
- ```
55
- 1. Set the iOS build target. Our React Native SDK requires iOS deployment target `13`. You can install `expo-build-properties` and add the following to `app.json` or `app.plugin.js` to set your build target.
56
-
57
- ```json
58
- {
59
- ...
60
- "plugins": [
61
- ...
62
- [
63
- "expo-build-properties",
64
- {
65
- "ios": {
66
- "deploymentTarget": "13.0"
67
- }
68
- }
69
- ]
70
- ]
71
- }
72
- ```
73
-
74
- 1. Add an import statement to your project for the react native library. We haven't included it below, but you can import `CioLogLevel` to set log outputs to something other than `error`; this may help you debug your application.
75
- ```javascript
76
- import { CustomerIO, CustomerioConfig, CustomerIOEnv, Region } from ‘customerio-reactnative’;
77
- ```
78
- 1. In `useEffect`, initialize the package with your `CustomerioConfig` options and `CustomerIOEnv` variables. You can find your Site ID and API Key credentials—or create new ones—under *Data & Integrations* > *Integrations* > *Customer.io API*:
79
- ```javascript
80
- useEffect(() => {
81
- const data = new CustomerioConfig()
82
- data.logLevel = CioLogLevel.debug
83
-
84
- const env = new CustomerIOEnv()
85
- env.siteId = Env.siteId
86
- env.apiKey = Env.apiKey
87
- env.organizationId = Env.organizationId
88
- //organizationId is used to send in-app messages.
89
- env.region = Region.US
90
- //Region is optional, defaults to Region.US. Use Region.EU for EU-based workspaces.
91
-
92
- CustomerIO.initialize(env, data)
93
- }, [])
94
- ```
95
- ## Plugin configuration options
96
-
97
- The `customerio-expo-plugin` supports the following configuration options. In most cases, you'll want to use the [default options shown in the installation instructions](#install-and-configure-the-plugin).
98
-
99
- <table class="settings-table mrg-t-lg">
100
- <thead>
101
- <tr>
102
- <td>Option</td>
103
- <td>Type</td>
104
- <td>Default</td>
105
- <td>Description</td>
106
- </tr>
107
- </thead>
108
- <tbody>
109
- <tr>
110
- <td><code>android</code></td>
111
- <td>object</td>
112
- <td><code>undefined</code></td>
113
- <td>Required if you want to setup Android even if it is empty. Eg (<code>"android": {}</code>).</td>
114
- </tr>
115
- <tr>
116
- <td><code>ios</code></td>
117
- <td>object</td>
118
- <td><code>undefined</code></td>
119
- <td>Required if you want to setup iOS even if it is empty. Eg (<code>"ios": {}</code>).</td>
120
- </tr>
121
- <tr>
122
- <td><code>android.googleServicesFile</code></td>
123
- <td>string</td>
124
- <td><code>undefined</code></td>
125
- <td>Set the path to the folder that contains your <code>google-services.json</code> file with a trailing slash (<code>/</code>).</td>
126
- </tr>
127
- <tr>
128
- <td><code>ios.pushNotification</code></td>
129
- <td>object</td>
130
- <td style="white-space:nowrap;"><code>undefined</code></td>
131
- <td>Enables push notifications for iOS, even if it is an empty object</td>
132
- </tr>
133
- <tr>
134
- <td style="white-space:nowrap;"><code>ios.pushNotification.useRichPush</code></td>
135
- <td>boolean</td>
136
- <td><code>false</code></td>
137
- <td>Enables rich push for iOS</td>
138
- </tr>
139
- <tr>
140
- <td style="white-space:nowrap;"><code>ios.useFrameworks</code></td>
141
- <td>string</td>
142
- <td><code>undefined</code></td>
143
- <td>This is optional, it allows the plugin to work with static libraries. Options are <code>static</code> and <code>dynamic</code></td>
144
- </tr>
145
- </tbody>
146
- </table>
147
-
148
- # Run the prebuild
149
-
150
- After you [install and configure the plugin](#install-and-configure-the-plugin), run the prebuild.
151
-
152
- ```shell
153
- # Run prebuild
154
- expo prebuild
155
-
156
- # Delete ios and android folders before prebuild
157
- expo prebuild --clean
158
- ```
159
- Now your project is ready to use the React Native SDK.
160
-
161
- ## Enable Rich Push on iOS
162
- For now, you'll need to add a short workaround to take advantage of rich push features. Add the following to `ios/NotificationService/NotificationService.swift` after you run `prebuild --clean`.
163
-
164
- ```swift
165
- ...
166
- import CioTracking // <== Add import
167
-
168
- @objc
169
- public class NotificationServiceCioManager : NSObject {
170
-
171
- public override init() {}
172
-
173
- @objc(didReceive:withContentHandler:)
174
- public func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
175
- CustomerIO.initialize(siteId: "<YourSiteId>", apiKey: "<YourApiKey>", region: Region.US) // <== Workaround code
176
- ...
177
- ```
178
-
179
- # More information
180
-
181
- See our complete SDK documentation at [https://customer.io/docs/sdk/expo/](https://customer.io/docs/sdk/expo/)
20
+ You'll find our [complete SDK documentation at https://customer.io/docs/sdk/expo](https://customer.io/docs/sdk/expo/).
182
21
 
183
22
  # Contributing
184
23
 
@@ -188,4 +27,4 @@ We value an open, welcoming, diverse, inclusive, and healthy community for this
188
27
 
189
28
  # License
190
29
 
191
- [MIT](LICENSE)
30
+ [MIT](LICENSE)
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withAndroidManifestUpdates = void 0;
7
+ var _configPlugins = require("@expo/config-plugins");
8
+ const withAndroidManifestUpdates = configOuter => {
9
+ return (0, _configPlugins.withAndroidManifest)(configOuter, props => {
10
+ const application = props.modResults.manifest.application;
11
+ const customerIOMessagingpush = 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';
12
+ if (!application[0]['service']) {
13
+ application[0]['service'] = [];
14
+ }
15
+ const hasService = application[0]['service'].some(service => service['$']['android:name'] === customerIOMessagingpush);
16
+ if (!hasService) {
17
+ application[0]['service'].push({
18
+ '$': {
19
+ 'android:name': customerIOMessagingpush,
20
+ 'android:exported': 'false'
21
+ },
22
+ 'intent-filter': [{
23
+ action: [{
24
+ $: {
25
+ 'android:name': 'com.google.firebase.MESSAGING_EVENT'
26
+ }
27
+ }]
28
+ }]
29
+ });
30
+ console.log('Successfully set CustomerIO push handler as priority in AndroidManifest.xml');
31
+ }
32
+ props.modResults.manifest.application = application;
33
+ return props;
34
+ });
35
+ };
36
+ exports.withAndroidManifestUpdates = withAndroidManifestUpdates;
37
+ //# sourceMappingURL=withAndroidManifestUpdates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_configPlugins","require","withAndroidManifestUpdates","configOuter","withAndroidManifest","props","application","modResults","manifest","customerIOMessagingpush","hasService","some","service","push","action","$","console","log","exports"],"sources":["withAndroidManifestUpdates.ts"],"sourcesContent":["import { ConfigPlugin, withAndroidManifest } from '@expo/config-plugins';\nimport type { ManifestApplication } from '@expo/config-plugins/build/android/Manifest';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\nexport const withAndroidManifestUpdates: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAndroidManifest(configOuter, (props) => {\n const application = props.modResults.manifest\n .application as ManifestApplication[];\n const customerIOMessagingpush =\n 'io.customer.messagingpush.CustomerIOFirebaseMessagingService';\n\n if (!application[0]['service']) {\n application[0]['service'] = [];\n }\n\n const hasService = application[0]['service'].some(\n (service) => service['$']['android:name'] === customerIOMessagingpush\n );\n\n if (!hasService) {\n application[0]['service'].push({\n '$': {\n 'android:name': customerIOMessagingpush,\n 'android:exported': 'false',\n },\n 'intent-filter': [\n {\n action: [\n {\n $: {\n 'android:name': 'com.google.firebase.MESSAGING_EVENT',\n },\n },\n ],\n },\n ],\n });\n console.log(\n 'Successfully set CustomerIO push handler as priority in AndroidManifest.xml'\n );\n }\n\n props.modResults.manifest.application = application;\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAKO,MAAMC,0BAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,kCAAmB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACjD,MAAMC,WAAW,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,CAC1CF,WAAoC;IACvC,MAAMG,uBAAuB,GAC3B,8DAA8D;IAEhE,IAAI,CAACH,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;MAC9BA,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE;IAChC;IAEA,MAAMI,UAAU,GAAGJ,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAACK,IAAI,CAC9CC,OAAO,IAAKA,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,KAAKH,uBAChD,CAAC;IAED,IAAI,CAACC,UAAU,EAAE;MACfJ,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAACO,IAAI,CAAC;QAC7B,GAAG,EAAE;UACH,cAAc,EAAEJ,uBAAuB;UACvC,kBAAkB,EAAE;QACtB,CAAC;QACD,eAAe,EAAE,CACf;UACEK,MAAM,EAAE,CACN;YACEC,CAAC,EAAE;cACD,cAAc,EAAE;YAClB;UACF,CAAC;QAEL,CAAC;MAEL,CAAC,CAAC;MACFC,OAAO,CAACC,GAAG,CACT,6EACF,CAAC;IACH;IAEAZ,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACF,WAAW,GAAGA,WAAW;IACnD,OAAOD,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACa,OAAA,CAAAhB,0BAAA,GAAAA,0BAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["withAppGoogleServices","configOuter","withAppBuildGradle","props","regex","RegExp","CIO_APP_GOOGLE_SNIPPET","match","modResults","contents","replace","CIO_APP_APPLY_REGEX","console","log"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, withAppBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_APP_APPLY_REGEX,\n CIO_APP_GOOGLE_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\nexport const withAppGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAppBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_APP_APPLY_REGEX,\n `$1\\n${CIO_APP_GOOGLE_SNIPPET}`\n );\n } else {\n console.log('app/build.gradle snippet already exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAMO,MAAMA,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,iCAAkB,EAACD,WAAW,EAAGE,KAAK,IAAK;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACC,+BAAsB,CAAC;IAChD,MAAMC,KAAK,GAAGJ,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACH,KAAK,CAAC;IACpD,IAAI,CAACG,KAAK,EAAE;MACVJ,KAAK,CAACK,UAAU,CAACC,QAAQ,GAAGN,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DC,4BAAmB,EAClB,OAAML,+BAAuB,EAAC,CAChC;IACH,CAAC,MAAM;MACLM,OAAO,CAACC,GAAG,CAAC,sDAAsD,CAAC;IACrE;IAEA,OAAOV,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["_configPlugins","require","_android","withAppGoogleServices","configOuter","withAppBuildGradle","props","regex","RegExp","CIO_APP_GOOGLE_SNIPPET","match","modResults","contents","replace","CIO_APP_APPLY_REGEX","console","log","exports"],"sources":["withAppGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, withAppBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_APP_APPLY_REGEX,\n CIO_APP_GOOGLE_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\n\nexport const withAppGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withAppBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_APP_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_APP_APPLY_REGEX,\n `$1\\n${CIO_APP_GOOGLE_SNIPPET}`\n );\n } else {\n console.log('app/build.gradle snippet already exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAMO,MAAME,qBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,iCAAkB,EAACD,WAAW,EAAGE,KAAK,IAAK;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACC,+BAAsB,CAAC;IAChD,MAAMC,KAAK,GAAGJ,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACH,KAAK,CAAC;IACpD,IAAI,CAACG,KAAK,EAAE;MACVJ,KAAK,CAACK,UAAU,CAACC,QAAQ,GAAGN,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DC,4BAAmB,EAClB,OAAML,+BAAuB,EAChC,CAAC;IACH,CAAC,MAAM;MACLM,OAAO,CAACC,GAAG,CAAC,sDAAsD,CAAC;IACrE;IAEA,OAAOV,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACW,OAAA,CAAAd,qBAAA,GAAAA,qBAAA"}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.withCIOAndroid = withCIOAndroid;
7
+ var _withAndroidManifestUpdates = require("./withAndroidManifestUpdates");
7
8
  var _withAppGoogleServices = require("./withAppGoogleServices");
8
9
  var _withGistMavenRepository = require("./withGistMavenRepository");
9
10
  var _withGoogleServicesJSON = require("./withGoogleServicesJSON");
@@ -13,6 +14,9 @@ function withCIOAndroid(config, props) {
13
14
  config = (0, _withProjectGoogleServices.withProjectGoogleServices)(config, props);
14
15
  config = (0, _withAppGoogleServices.withAppGoogleServices)(config, props);
15
16
  config = (0, _withGoogleServicesJSON.withGoogleServicesJSON)(config, props);
17
+ if (props.setHighPriorityPushHandler) {
18
+ config = (0, _withAndroidManifestUpdates.withAndroidManifestUpdates)(config, props);
19
+ }
16
20
  return config;
17
21
  }
18
22
  //# sourceMappingURL=withCIOAndroid.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withCIOAndroid","config","props","withGistMavenRepository","withProjectGoogleServices","withAppGoogleServices","withGoogleServicesJSON"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGistMavenRepository } from './withGistMavenRepository';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsAndroid\n): ExpoConfig {\n config = withGistMavenRepository(config, props);\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n\n return config;\n}\n"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AAEO,SAASA,cAAc,CAC5BC,MAAkB,EAClBC,KAAqC,EACzB;EACZD,MAAM,GAAG,IAAAE,gDAAuB,EAACF,MAAM,EAAEC,KAAK,CAAC;EAC/CD,MAAM,GAAG,IAAAG,oDAAyB,EAACH,MAAM,EAAEC,KAAK,CAAC;EACjDD,MAAM,GAAG,IAAAI,4CAAqB,EAACJ,MAAM,EAAEC,KAAK,CAAC;EAC7CD,MAAM,GAAG,IAAAK,8CAAsB,EAACL,MAAM,EAAEC,KAAK,CAAC;EAE9C,OAAOD,MAAM;AACf"}
1
+ {"version":3,"names":["_withAndroidManifestUpdates","require","_withAppGoogleServices","_withGistMavenRepository","_withGoogleServicesJSON","_withProjectGoogleServices","withCIOAndroid","config","props","withGistMavenRepository","withProjectGoogleServices","withAppGoogleServices","withGoogleServicesJSON","setHighPriorityPushHandler","withAndroidManifestUpdates"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';\nimport { withAndroidManifestUpdates } from './withAndroidManifestUpdates';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGistMavenRepository } from './withGistMavenRepository';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsAndroid\n): ExpoConfig {\n config = withGistMavenRepository(config, props);\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n if (props.setHighPriorityPushHandler) {\n config = withAndroidManifestUpdates(config, props);\n }\n\n return config;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,2BAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AACA,IAAAI,0BAAA,GAAAJ,OAAA;AAEO,SAASK,cAAcA,CAC5BC,MAAkB,EAClBC,KAAqC,EACzB;EACZD,MAAM,GAAG,IAAAE,gDAAuB,EAACF,MAAM,EAAEC,KAAK,CAAC;EAC/CD,MAAM,GAAG,IAAAG,oDAAyB,EAACH,MAAM,EAAEC,KAAK,CAAC;EACjDD,MAAM,GAAG,IAAAI,4CAAqB,EAACJ,MAAM,EAAEC,KAAK,CAAC;EAC7CD,MAAM,GAAG,IAAAK,8CAAsB,EAACL,MAAM,EAAEC,KAAK,CAAC;EAC9C,IAAIA,KAAK,CAACK,0BAA0B,EAAE;IACpCN,MAAM,GAAG,IAAAO,sDAA0B,EAACP,MAAM,EAAEC,KAAK,CAAC;EACpD;EAEA,OAAOD,MAAM;AACf"}
@@ -1 +1 @@
1
- {"version":3,"names":["withGistMavenRepository","configOuter","withProjectBuildGradle","props","targetMatch","modResults","contents","match","CIO_GIST_MAVEN_REGEX","replace","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","console","log"],"sources":["withGistMavenRepository.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\nimport {\n CIO_GIST_MAVEN_REGEX,\n CIO_PROJECT_ALLPROJECTS_REGEX,\n CIO_PROJECT_GIST_MAVEN_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGistMavenRepository: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const targetMatch = props.modResults.contents.match(CIO_GIST_MAVEN_REGEX);\n if (!targetMatch) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_ALLPROJECTS_REGEX,\n `$1\\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`\n );\n } else {\n console.log('build.gradle snippet alreade exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAOO,MAAMA,uBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,qCAAsB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,WAAW,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACC,6BAAoB,CAAC;IACzE,IAAI,CAACJ,WAAW,EAAE;MAChBD,KAAK,CAACE,UAAU,CAACC,QAAQ,GAAGH,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACG,OAAO,CAC3DC,sCAA6B,EAC5B,OAAMC,uCAA+B,EAAC,CACxC;IACH,CAAC,MAAM;MACLC,OAAO,CAACC,GAAG,CAAC,kDAAkD,CAAC;IACjE;IAEA,OAAOV,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["_configPlugins","require","_android","withGistMavenRepository","configOuter","withProjectBuildGradle","props","targetMatch","modResults","contents","match","CIO_GIST_MAVEN_REGEX","replace","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","console","log","exports"],"sources":["withGistMavenRepository.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\nimport {\n CIO_GIST_MAVEN_REGEX,\n CIO_PROJECT_ALLPROJECTS_REGEX,\n CIO_PROJECT_GIST_MAVEN_SNIPPET,\n} from '../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGistMavenRepository: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const targetMatch = props.modResults.contents.match(CIO_GIST_MAVEN_REGEX);\n if (!targetMatch) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_ALLPROJECTS_REGEX,\n `$1\\n${CIO_PROJECT_GIST_MAVEN_SNIPPET}`\n );\n } else {\n console.log('build.gradle snippet alreade exists. Skipping...');\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAOO,MAAME,uBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,qCAAsB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,WAAW,GAAGD,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACC,KAAK,CAACC,6BAAoB,CAAC;IACzE,IAAI,CAACJ,WAAW,EAAE;MAChBD,KAAK,CAACE,UAAU,CAACC,QAAQ,GAAGH,KAAK,CAACE,UAAU,CAACC,QAAQ,CAACG,OAAO,CAC3DC,sCAA6B,EAC5B,OAAMC,uCAA+B,EACxC,CAAC;IACH,CAAC,MAAM;MACLC,OAAO,CAACC,GAAG,CAAC,kDAAkD,CAAC;IACjE;IAEA,OAAOV,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACW,OAAA,CAAAd,uBAAA,GAAAA,uBAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["withGoogleServicesJSON","configOuter","cioProps","withProjectBuildGradle","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","FileManagement","exists","copyFile","e","console","log"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const options: CustomerIOPluginOptionsAndroid = {\n androidPath: props.modRequest.platformProjectRoot,\n googleServicesFile: cioProps?.googleServicesFile,\n };\n const { androidPath, googleServicesFile } = options;\n if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${androidPath}/app/google-services.json`\n );\n } catch (e) {\n console.log(\n `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n console.log(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n console.log(\n `File already exists: ${androidPath}/app/google-services.json. Skipping...`\n );\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAGO,MAAMA,sBAEZ,GAAG,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAO,IAAAC,qCAAsB,EAACF,WAAW,EAAGG,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEP,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEO;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACK,8BAAc,CAACC,MAAM,CAAE,GAAEL,WAAY,2BAA0B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIC,8BAAc,CAACC,MAAM,CAACF,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFC,8BAAc,CAACE,QAAQ,CACrBH,kBAAkB,EACjB,GAAEH,WAAY,2BAA0B,CAC1C;QACH,CAAC,CAAC,OAAOO,CAAC,EAAE;UACVC,OAAO,CAACC,GAAG,CACR,4FAA2FT,WAAY,2BAA0B,CACnI;QACH;MACF,CAAC,MAAM;QACLQ,OAAO,CAACC,GAAG,CACR,wCAAuCN,kBAAmB,yDAAwDH,WAAY,2BAA0B,CAC1J;MACH;IACF,CAAC,MAAM;MACLQ,OAAO,CAACC,GAAG,CACR,wBAAuBT,WAAY,wCAAuC,CAC5E;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["_configPlugins","require","_fileManagement","withGoogleServicesJSON","configOuter","cioProps","withProjectBuildGradle","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","FileManagement","exists","copyFile","e","console","log","exports"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const options: CustomerIOPluginOptionsAndroid = {\n androidPath: props.modRequest.platformProjectRoot,\n googleServicesFile: cioProps?.googleServicesFile,\n };\n const { androidPath, googleServicesFile } = options;\n if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${androidPath}/app/google-services.json`\n );\n } catch (e) {\n console.log(\n `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n console.log(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n console.log(\n `File already exists: ${androidPath}/app/google-services.json. Skipping...`\n );\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAGO,MAAME,sBAEZ,GAAGA,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAO,IAAAC,qCAAsB,EAACF,WAAW,EAAGG,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEP,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEO;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACK,8BAAc,CAACC,MAAM,CAAE,GAAEL,WAAY,2BAA0B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIC,8BAAc,CAACC,MAAM,CAACF,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFC,8BAAc,CAACE,QAAQ,CACrBH,kBAAkB,EACjB,GAAEH,WAAY,2BACjB,CAAC;QACH,CAAC,CAAC,OAAOO,CAAC,EAAE;UACVC,OAAO,CAACC,GAAG,CACR,4FAA2FT,WAAY,2BAC1G,CAAC;QACH;MACF,CAAC,MAAM;QACLQ,OAAO,CAACC,GAAG,CACR,wCAAuCN,kBAAmB,yDAAwDH,WAAY,2BACjI,CAAC;MACH;IACF,CAAC,MAAM;MACLQ,OAAO,CAACC,GAAG,CACR,wBAAuBT,WAAY,wCACtC,CAAC;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACY,OAAA,CAAAhB,sBAAA,GAAAA,sBAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["withProjectGoogleServices","configOuter","withProjectBuildGradle","props","regex","RegExp","CIO_PROJECT_GOOGLE_SNIPPET","match","modResults","contents","replace","CIO_PROJECT_BUILDSCRIPTS_REGEX"],"sources":["withProjectGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, withProjectBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n CIO_PROJECT_GOOGLE_SNIPPET,\n} from './../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withProjectGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n `$1\\n${CIO_PROJECT_GOOGLE_SNIPPET}`\n );\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAMO,MAAMA,yBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,qCAAsB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACC,mCAA0B,CAAC;IACpD,MAAMC,KAAK,GAAGJ,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACH,KAAK,CAAC;IACpD,IAAI,CAACG,KAAK,EAAE;MACVJ,KAAK,CAACK,UAAU,CAACC,QAAQ,GAAGN,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DC,uCAA8B,EAC7B,OAAML,mCAA2B,EAAC,CACpC;IACH;IAEA,OAAOH,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAAC"}
1
+ {"version":3,"names":["_configPlugins","require","_android","withProjectGoogleServices","configOuter","withProjectBuildGradle","props","regex","RegExp","CIO_PROJECT_GOOGLE_SNIPPET","match","modResults","contents","replace","CIO_PROJECT_BUILDSCRIPTS_REGEX","exports"],"sources":["withProjectGoogleServices.ts"],"sourcesContent":["import { ConfigPlugin, withProjectBuildGradle } from '@expo/config-plugins';\n\nimport {\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n CIO_PROJECT_GOOGLE_SNIPPET,\n} from './../helpers/constants/android';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withProjectGoogleServices: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const regex = new RegExp(CIO_PROJECT_GOOGLE_SNIPPET);\n const match = props.modResults.contents.match(regex);\n if (!match) {\n props.modResults.contents = props.modResults.contents.replace(\n CIO_PROJECT_BUILDSCRIPTS_REGEX,\n `$1\\n${CIO_PROJECT_GOOGLE_SNIPPET}`\n );\n }\n\n return props;\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAMO,MAAME,yBAEZ,GAAIC,WAAW,IAAK;EACnB,OAAO,IAAAC,qCAAsB,EAACD,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAACC,mCAA0B,CAAC;IACpD,MAAMC,KAAK,GAAGJ,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACF,KAAK,CAACH,KAAK,CAAC;IACpD,IAAI,CAACG,KAAK,EAAE;MACVJ,KAAK,CAACK,UAAU,CAACC,QAAQ,GAAGN,KAAK,CAACK,UAAU,CAACC,QAAQ,CAACC,OAAO,CAC3DC,uCAA8B,EAC7B,OAAML,mCAA2B,EACpC,CAAC;IACH;IAEA,OAAOH,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACS,OAAA,CAAAZ,yBAAA,GAAAA,yBAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_APP_APPLY_REGEX","CIO_GIST_MAVEN_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","CIO_APP_GOOGLE_SNIPPET","CIO_PROJECT_GOOGLE_SNIPPET"],"sources":["android.ts"],"sourcesContent":["export const CIO_PROJECT_BUILDSCRIPTS_REGEX =\n /(buildscript\\s*\\{(.|\\n)*dependencies\\s*\\{)/;\nexport const CIO_APP_APPLY_REGEX = /(apply plugin: \"com.android.application\")/;\nexport const CIO_GIST_MAVEN_REGEX =\n /maven { url \"https:\\/\\/maven.gist.build\" }/;\nexport const CIO_PROJECT_ALLPROJECTS_REGEX =\n /(allprojects\\s*\\{(.|\\n){1,500}repositories\\s*\\{)/;\n\nexport const CIO_PROJECT_GIST_MAVEN_SNIPPET =\n ' maven { url \"https://maven.gist.build\" }';\nexport const CIO_APP_GOOGLE_SNIPPET =\n 'apply plugin: \"com.google.gms.google-services\" // Google Services plugin';\nexport const CIO_PROJECT_GOOGLE_SNIPPET =\n ' classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin';\n"],"mappings":";;;;;;AAAO,MAAMA,8BAA8B,GACzC,4CAA4C;AAAC;AACxC,MAAMC,mBAAmB,GAAG,2CAA2C;AAAC;AACxE,MAAMC,oBAAoB,GAC/B,4CAA4C;AAAC;AACxC,MAAMC,6BAA6B,GACxC,kDAAkD;AAAC;AAE9C,MAAMC,8BAA8B,GACzC,kDAAkD;AAAC;AAC9C,MAAMC,sBAAsB,GACjC,2EAA2E;AAAC;AACvE,MAAMC,0BAA0B,GACrC,sFAAsF;AAAC"}
1
+ {"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","exports","CIO_APP_APPLY_REGEX","CIO_GIST_MAVEN_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","CIO_APP_GOOGLE_SNIPPET","CIO_PROJECT_GOOGLE_SNIPPET"],"sources":["android.ts"],"sourcesContent":["export const CIO_PROJECT_BUILDSCRIPTS_REGEX =\n /(buildscript\\s*\\{(.|\\n)*dependencies\\s*\\{)/;\nexport const CIO_APP_APPLY_REGEX = /(apply plugin: \"com.android.application\")/;\nexport const CIO_GIST_MAVEN_REGEX =\n /maven { url \"https:\\/\\/maven.gist.build\" }/;\nexport const CIO_PROJECT_ALLPROJECTS_REGEX =\n /(allprojects\\s*\\{(.|\\n){1,500}repositories\\s*\\{)/;\n\nexport const CIO_PROJECT_GIST_MAVEN_SNIPPET =\n ' maven { url \"https://maven.gist.build\" }';\nexport const CIO_APP_GOOGLE_SNIPPET =\n 'apply plugin: \"com.google.gms.google-services\" // Google Services plugin';\nexport const CIO_PROJECT_GOOGLE_SNIPPET =\n ' classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin';\n"],"mappings":";;;;;;AAAO,MAAMA,8BAA8B,GACzC,4CAA4C;AAACC,OAAA,CAAAD,8BAAA,GAAAA,8BAAA;AACxC,MAAME,mBAAmB,GAAG,2CAA2C;AAACD,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AACxE,MAAMC,oBAAoB,GAC/B,4CAA4C;AAACF,OAAA,CAAAE,oBAAA,GAAAA,oBAAA;AACxC,MAAMC,6BAA6B,GACxC,kDAAkD;AAACH,OAAA,CAAAG,6BAAA,GAAAA,6BAAA;AAE9C,MAAMC,8BAA8B,GACzC,kDAAkD;AAACJ,OAAA,CAAAI,8BAAA,GAAAA,8BAAA;AAC9C,MAAMC,sBAAsB,GACjC,2EAA2E;AAACL,OAAA,CAAAK,sBAAA,GAAAA,sBAAA;AACvE,MAAMC,0BAA0B,GACrC,sFAAsF;AAACN,OAAA,CAAAM,0BAAA,GAAAA,0BAAA"}
@@ -3,21 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.LOCAL_PATH_TO_CIO_NSE_FILES = exports.IOS_DEPLOYMENT_TARGET = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = exports.CIO_TARGET_NAME = exports.CIO_SDK_VERSION = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_PODFILE_SNIPPET = exports.CIO_PODFILE_REGEX = exports.CIO_PODFILE_POST_INSTALL_REGEX = exports.CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET = exports.CIO_PODFILE_NOTIFICATION_SNIPPET = exports.CIO_PODFILE_NOTIFICATION_REGEX = exports.CIO_NOTIFICATION_TARGET_NAME = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_CIO_TARGET_REGEX = exports.CIO_APPDELEGATEHEADER_SNIPPET = exports.CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEDECLARATION_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = void 0;
7
- const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;
6
+ exports.LOCAL_PATH_TO_CIO_NSE_FILES = exports.IOS_DEPLOYMENT_TARGET = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = exports.CIO_TARGET_NAME = exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_NOTIFICATION_TARGET_NAME = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_APPDELEGATEHEADER_SNIPPET = exports.CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEDECLARATION_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = void 0;
7
+ const finder = require('find-package-json');
8
+ const path = require('path');
9
+ const f = finder(__dirname);
10
+ let pluginPackageRoot = f.next().filename;
11
+ // This is the path to the root of the customerio-expo-plugin package
12
+ pluginPackageRoot = path.dirname(pluginPackageRoot);
13
+ const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(pluginPackageRoot, 'src/helpers/native-files/ios');
8
14
  exports.LOCAL_PATH_TO_CIO_NSE_FILES = LOCAL_PATH_TO_CIO_NSE_FILES;
9
15
  const IOS_DEPLOYMENT_TARGET = '13.0';
10
16
  exports.IOS_DEPLOYMENT_TARGET = IOS_DEPLOYMENT_TARGET;
11
- const CIO_SDK_VERSION = '~> 2.0.0';
12
- exports.CIO_SDK_VERSION = CIO_SDK_VERSION;
13
- const CIO_PODFILE_REGEX = /pod 'CustomerIO\/MessagingPushAPN'/;
14
- exports.CIO_PODFILE_REGEX = CIO_PODFILE_REGEX;
15
- const CIO_CIO_TARGET_REGEX = /cio_target_names/;
16
- exports.CIO_CIO_TARGET_REGEX = CIO_CIO_TARGET_REGEX;
17
- const CIO_PODFILE_NOTIFICATION_REGEX = /target 'NotificationService' do/;
18
- exports.CIO_PODFILE_NOTIFICATION_REGEX = CIO_PODFILE_NOTIFICATION_REGEX;
19
- const CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \|installer\|/;
20
- exports.CIO_PODFILE_POST_INSTALL_REGEX = CIO_PODFILE_POST_INSTALL_REGEX;
21
17
  const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
22
18
  exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = GROUP_IDENTIFIER_TEMPLATE_REGEX;
23
19
  const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
@@ -55,10 +51,12 @@ CIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler
55
51
  `;
56
52
  exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET;
57
53
  const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `
54
+ [super application:application didFailToRegisterForRemoteNotificationsWithError:error];
58
55
  [pnHandlerObj application:application error:error];
59
56
  `;
60
57
  exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET;
61
58
  const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `
59
+ [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
62
60
  return [pnHandlerObj application:application deviceToken:deviceToken];
63
61
  `;
64
62
  exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET;
@@ -82,17 +80,19 @@ const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `
82
80
  completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);
83
81
  }`;
84
82
  exports.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET;
85
- const CIO_PODFILE_SNIPPET = ` pod 'CustomerIO/MessagingPushAPN', '${CIO_SDK_VERSION}'`;
86
- exports.CIO_PODFILE_SNIPPET = CIO_PODFILE_SNIPPET;
87
- const CIO_PODFILE_NOTIFICATION_SNIPPET = `
88
- target '${CIO_NOTIFICATION_TARGET_NAME}' do
89
- ${CIO_PODFILE_SNIPPET}
90
- end`;
91
- exports.CIO_PODFILE_NOTIFICATION_SNIPPET = CIO_PODFILE_NOTIFICATION_SNIPPET;
92
- const CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET = `
93
- target '${CIO_NOTIFICATION_TARGET_NAME}' do
94
- use_frameworks! :linkage => :static
95
- ${CIO_PODFILE_SNIPPET}
96
- end`;
97
- exports.CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET = CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET;
83
+ const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `
84
+ @objc(registerPushNotification:)
85
+ public func registerPushNotification(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {
86
+
87
+ let center = UNUserNotificationCenter.current()
88
+ center.delegate = notificationDelegate
89
+ center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
90
+ if error == nil{
91
+ DispatchQueue.main.async {
92
+ UIApplication.shared.registerForRemoteNotifications()
93
+ }
94
+ }
95
+ }
96
+ }`;
97
+ exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;
98
98
  //# sourceMappingURL=ios.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["LOCAL_PATH_TO_CIO_NSE_FILES","IOS_DEPLOYMENT_TARGET","CIO_SDK_VERSION","CIO_PODFILE_REGEX","CIO_CIO_TARGET_REGEX","CIO_PODFILE_NOTIFICATION_REGEX","CIO_PODFILE_POST_INSTALL_REGEX","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","CIO_PODFILE_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const CIO_SDK_VERSION = '~> 2.0.0';\nexport const CIO_PODFILE_REGEX = /pod 'CustomerIO\\/MessagingPushAPN'/;\nexport const CIO_CIO_TARGET_REGEX = /cio_target_names/;\nexport const CIO_PODFILE_NOTIFICATION_REGEX = /target 'NotificationService' do/;\nexport const CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \\|installer\\|/;\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /(- \\(BOOL\\)application:\\(UIApplication \\*\\)application didFinishLaunchingWithOptions:\\(NSDictionary \\*\\)launchOptions(\\s|\\n)*?\\{)((.|\\n)*)\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate>/;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';\nexport const CIO_APPDELEGATEHEADER_SNIPPET = `\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n`;\n\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification:self];\n`;\n\n// Enable push handling - notification response\nexport 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}`;\n\n// Foreground push handling\nexport 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}`;\nexport const CIO_PODFILE_SNIPPET = ` pod 'CustomerIO/MessagingPushAPN', '${CIO_SDK_VERSION}'`;\nexport const CIO_PODFILE_NOTIFICATION_SNIPPET = `\ntarget '${CIO_NOTIFICATION_TARGET_NAME}' do\n${CIO_PODFILE_SNIPPET}\nend`;\nexport const CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET = `\ntarget '${CIO_NOTIFICATION_TARGET_NAME}' do\n use_frameworks! :linkage => :static\n${CIO_PODFILE_SNIPPET}\nend`;\n"],"mappings":";;;;;;AAAO,MAAMA,2BAA2B,GAAI,kEAAiE;AAAC;AACvG,MAAMC,qBAAqB,GAAG,MAAM;AAAC;AACrC,MAAMC,eAAe,GAAG,UAAU;AAAC;AACnC,MAAMC,iBAAiB,GAAG,oCAAoC;AAAC;AAC/D,MAAMC,oBAAoB,GAAG,kBAAkB;AAAC;AAChD,MAAMC,8BAA8B,GAAG,iCAAiC;AAAC;AACzE,MAAMC,8BAA8B,GAAG,+BAA+B;AAAC;AACvE,MAAMC,+BAA+B,GAAG,wBAAwB;AAAC;AACjE,MAAMC,mCAAmC,GAAG,4BAA4B;AAAC;AACzE,MAAMC,6BAA6B,GAAG,sBAAsB;AAAC;AAC7D,MAAMC,kCAAkC,GAC7C,gOAAgO;AAAC;AAE5N,MAAMC,0DAA0D,GACrE,kGAAkG;AAAC;AAE9F,MAAMC,8DAA8D,GACzE,wJAAwJ;AAAC;AAEpJ,MAAMC,0DAA0D,GACrE,wGAAwG;AAAC;AAEpG,MAAMC,gCAAgC,GAC3C,mCAAmC;AAAC;AAE/B,MAAMC,2BAA2B,GACtC,mEAAmE;AAAC;AAC/D,MAAMC,sBAAsB,GAAG,GAAG;AAAC;AACnC,MAAMC,4BAA4B,GAAG,KAAK;AAAC;AAC3C,MAAMC,eAAe,GAAG,eAAe;AAAC;AACxC,MAAMC,4BAA4B,GAAG,qBAAqB;AAAC;AAC3D,MAAMC,6BAA6B,GAAI;AAC9C;AACA;AACA;AACA,CAAC;AAAC;AAEK,MAAMC,8CAA8C,GAAI;AAC/D;AACA,CAAC;AAAC;AAEK,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;AAAC;AAEK,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;AAAC;AAEK,MAAMC,2CAA2C,GAAI;AAC5D;AACA;AACA,CAAC;;AAED;AAAA;AACO,MAAMC,iDAAiD,GAAI;AAClE;AACA;AACA,EAAE;;AAEF;AAAA;AACO,MAAMC,0CAA0C,GAAI;AAC3D;AACA;AACA;AACA,EAAE;AAAC;AACI,MAAMC,mBAAmB,GAAI,yCAAwCzB,eAAgB,GAAE;AAAC;AACxF,MAAM0B,gCAAgC,GAAI;AACjD,UAAUT,4BAA6B;AACvC,EAAEQ,mBAAoB;AACtB,IAAI;AAAC;AACE,MAAME,iDAAiD,GAAI;AAClE,UAAUV,4BAA6B;AACvC;AACA,EAAEQ,mBAAoB;AACtB,IAAI;AAAC"}
1
+ {"version":3,"names":["finder","require","path","f","__dirname","pluginPackageRoot","next","filename","dirname","LOCAL_PATH_TO_CIO_NSE_FILES","join","exports","IOS_DEPLOYMENT_TARGET","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["const finder = require('find-package-json');\nconst path = require('path');\n\nconst f = finder(__dirname);\nlet pluginPackageRoot = f.next().filename;\n// This is the path to the root of the customerio-expo-plugin package\npluginPackageRoot = path.dirname(pluginPackageRoot);\n\nexport const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(\n pluginPackageRoot,\n 'src/helpers/native-files/ios'\n);\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /(- \\(BOOL\\)application:\\(UIApplication \\*\\)application didFinishLaunchingWithOptions:\\(NSDictionary \\*\\)launchOptions(\\s|\\n)*?\\{)((.|\\n)*)\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate>/;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';\nexport const CIO_APPDELEGATEHEADER_SNIPPET = `\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n`;\n\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification:self];\n`;\n\n// Enable push handling - notification response\nexport 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}`;\n\n// Foreground push handling\nexport 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}`;\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `\n@objc(registerPushNotification:)\n public func registerPushNotification(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {\n\n let center = UNUserNotificationCenter.current()\n center.delegate = notificationDelegate\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }`;\n"],"mappings":";;;;;;AAAA,MAAMA,MAAM,GAAGC,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAMC,IAAI,GAAGD,OAAO,CAAC,MAAM,CAAC;AAE5B,MAAME,CAAC,GAAGH,MAAM,CAACI,SAAS,CAAC;AAC3B,IAAIC,iBAAiB,GAAGF,CAAC,CAACG,IAAI,CAAC,CAAC,CAACC,QAAQ;AACzC;AACAF,iBAAiB,GAAGH,IAAI,CAACM,OAAO,CAACH,iBAAiB,CAAC;AAE5C,MAAMI,2BAA2B,GAAGP,IAAI,CAACQ,IAAI,CAClDL,iBAAiB,EACjB,8BACF,CAAC;AAACM,OAAA,CAAAF,2BAAA,GAAAA,2BAAA;AACK,MAAMG,qBAAqB,GAAG,MAAM;AAACD,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AACrC,MAAMC,+BAA+B,GAAG,wBAAwB;AAACF,OAAA,CAAAE,+BAAA,GAAAA,+BAAA;AACjE,MAAMC,mCAAmC,GAAG,4BAA4B;AAACH,OAAA,CAAAG,mCAAA,GAAAA,mCAAA;AACzE,MAAMC,6BAA6B,GAAG,sBAAsB;AAACJ,OAAA,CAAAI,6BAAA,GAAAA,6BAAA;AAC7D,MAAMC,kCAAkC,GAC7C,gOAAgO;AAACL,OAAA,CAAAK,kCAAA,GAAAA,kCAAA;AAE5N,MAAMC,0DAA0D,GACrE,kGAAkG;AAACN,OAAA,CAAAM,0DAAA,GAAAA,0DAAA;AAE9F,MAAMC,8DAA8D,GACzE,wJAAwJ;AAACP,OAAA,CAAAO,8DAAA,GAAAA,8DAAA;AAEpJ,MAAMC,0DAA0D,GACrE,wGAAwG;AAACR,OAAA,CAAAQ,0DAAA,GAAAA,0DAAA;AAEpG,MAAMC,gCAAgC,GAC3C,mCAAmC;AAACT,OAAA,CAAAS,gCAAA,GAAAA,gCAAA;AAE/B,MAAMC,2BAA2B,GACtC,mEAAmE;AAACV,OAAA,CAAAU,2BAAA,GAAAA,2BAAA;AAC/D,MAAMC,sBAAsB,GAAG,GAAG;AAACX,OAAA,CAAAW,sBAAA,GAAAA,sBAAA;AACnC,MAAMC,4BAA4B,GAAG,KAAK;AAACZ,OAAA,CAAAY,4BAAA,GAAAA,4BAAA;AAC3C,MAAMC,eAAe,GAAG,eAAe;AAACb,OAAA,CAAAa,eAAA,GAAAA,eAAA;AACxC,MAAMC,4BAA4B,GAAG,qBAAqB;AAACd,OAAA,CAAAc,4BAAA,GAAAA,4BAAA;AAC3D,MAAMC,6BAA6B,GAAI;AAC9C;AACA;AACA;AACA,CAAC;AAACf,OAAA,CAAAe,6BAAA,GAAAA,6BAAA;AAEK,MAAMC,8CAA8C,GAAI;AAC/D;AACA,CAAC;AAAChB,OAAA,CAAAgB,8CAAA,GAAAA,8CAAA;AAEK,MAAMC,4DAA4D,GAAI;AAC7E;AACA;AACA,CAAC;AAACjB,OAAA,CAAAiB,4DAAA,GAAAA,4DAAA;AAEK,MAAMC,4DAA4D,GAAI;AAC7E;AACA;AACA,CAAC;AAAClB,OAAA,CAAAkB,4DAAA,GAAAA,4DAAA;AAEK,MAAMC,2CAA2C,GAAI;AAC5D;AACA;AACA,CAAC;;AAED;AAAAnB,OAAA,CAAAmB,2CAAA,GAAAA,2CAAA;AACO,MAAMC,iDAAiD,GAAI;AAClE;AACA;AACA,EAAE;;AAEF;AAAApB,OAAA,CAAAoB,iDAAA,GAAAA,iDAAA;AACO,MAAMC,0CAA0C,GAAI;AAC3D;AACA;AACA;AACA,EAAE;AAACrB,OAAA,CAAAqB,0CAAA,GAAAA,0CAAA;AACI,MAAMC,qCAAqC,GAAI;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AAACtB,OAAA,CAAAsB,qCAAA,GAAAA,qCAAA"}
@@ -9,19 +9,7 @@ public class CIOAppPushNotificationsHandler : NSObject {
9
9
 
10
10
  public override init() {}
11
11
 
12
- @objc(registerPushNotification:)
13
- public func registerPushNotification(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {
14
-
15
- let center = UNUserNotificationCenter.current()
16
- center.delegate = notificationDelegate
17
- center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
18
- if error == nil{
19
- DispatchQueue.main.async {
20
- UIApplication.shared.registerForRemoteNotifications()
21
- }
22
- }
23
- }
24
- }
12
+ {{REGISTER_SNIPPET}}
25
13
 
26
14
  @objc(application:deviceToken:)
27
15
  public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
@@ -1 +1 @@
1
- {"version":3,"names":["injectCodeByRegex","fileContent","lineRegex","snippet","lines","split","index","findIndex","line","test","content","slice","injectCodeByMultiLineRegex","replace","replaceCodeByRegex","injectCodeByMultiLineRegexAndReplaceLine","injectCodeByLineNumber"],"sources":["codeInjection.ts"],"sourcesContent":["export function injectCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n const index = lines.findIndex((line) => lineRegex.test(line));\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n\nexport function injectCodeByMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `$&\\n${snippet}`);\n}\n\nexport function replaceCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, snippet);\n}\n\nexport function injectCodeByMultiLineRegexAndReplaceLine(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}`);\n}\n\nexport function injectCodeByLineNumber(\n fileContent: string,\n index: number,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n"],"mappings":";;;;;;;;;;AAAO,SAASA,iBAAiB,CAC/BC,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IAAKN,SAAS,CAACO,IAAI,CAACD,IAAI,CAAC,CAAC;EAC7D,IAAIE,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB;AAEO,SAASE,0BAA0B,CACxCX,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,OAAMC,OAAQ,EAAC,CAAC;AACzD;AAEO,SAASW,kBAAkB,CAChCb,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAEC,OAAO,CAAC;AAChD;AAEO,SAASY,wCAAwC,CACtDd,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,GAAEC,OAAQ,EAAC,CAAC;AACrD;AAEO,SAASa,sBAAsB,CACpCf,WAAmB,EACnBK,KAAa,EACbH,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,IAAIK,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB"}
1
+ {"version":3,"names":["injectCodeByRegex","fileContent","lineRegex","snippet","lines","split","index","findIndex","line","test","content","slice","injectCodeByMultiLineRegex","replace","replaceCodeByRegex","injectCodeByMultiLineRegexAndReplaceLine","injectCodeByLineNumber"],"sources":["codeInjection.ts"],"sourcesContent":["export function injectCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n const index = lines.findIndex((line) => lineRegex.test(line));\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n\nexport function injectCodeByMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `$&\\n${snippet}`);\n}\n\nexport function replaceCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, snippet);\n}\n\nexport function injectCodeByMultiLineRegexAndReplaceLine(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}`);\n}\n\nexport function injectCodeByLineNumber(\n fileContent: string,\n index: number,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n"],"mappings":";;;;;;;;;;AAAO,SAASA,iBAAiBA,CAC/BC,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IAAKN,SAAS,CAACO,IAAI,CAACD,IAAI,CAAC,CAAC;EAC7D,IAAIE,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB;AAEO,SAASE,0BAA0BA,CACxCX,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,OAAMC,OAAQ,EAAC,CAAC;AACzD;AAEO,SAASW,kBAAkBA,CAChCb,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAEC,OAAO,CAAC;AAChD;AAEO,SAASY,wCAAwCA,CACtDd,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,GAAEC,OAAQ,EAAC,CAAC;AACrD;AAEO,SAASa,sBAAsBA,CACpCf,WAAmB,EACnBK,KAAa,EACbH,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,IAAIK,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB"}
@@ -1 +1 @@
1
- {"version":3,"names":["FileManagement","read","path","Promise","resolve","reject","readFile","err","data","write","contents","writeFile","append","appendFile","exists","existsSync","copyFile","src","dest","copyFileSync","console","log","mkdir","options","mkdirSync","writeFileSync","readFileSync"],"sources":["fileManagement.ts"],"sourcesContent":["import {\n readFile,\n writeFile,\n appendFile,\n existsSync,\n copyFileSync,\n mkdirSync,\n writeFileSync,\n readFileSync,\n MakeDirectoryOptions,\n} from 'fs';\n\nexport class FileManagement {\n static async read(path: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n readFile(path, 'utf8', (err, data) => {\n if (err || !data) {\n reject(err);\n return;\n }\n resolve(data);\n });\n });\n }\n\n static async write(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n writeFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static async append(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n appendFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static exists(path: string) {\n return existsSync(path);\n }\n\n static copyFile(src: string, dest: string) {\n try {\n copyFileSync(src, dest);\n } catch (err) {\n console.log(`Error copying file from ${src} to ${dest}: `, err);\n }\n }\n\n static mkdir(path: string, options: MakeDirectoryOptions) {\n try {\n mkdirSync(path, options);\n } catch (err) {\n console.log(`Error creating directory ${path}: `, err);\n }\n }\n\n static writeFile(path: string, data: string) {\n try {\n writeFileSync(path, data);\n } catch (err) {\n console.log(`Error writing to file ${path}: `, err);\n }\n }\n\n static readFile(path: string) {\n try {\n return readFileSync(path, 'utf-8');\n } catch (err) {\n console.log(`Error reading file ${path}: `, err);\n }\n\n return '';\n }\n}\n"],"mappings":";;;;;;AAAA;AAYO,MAAMA,cAAc,CAAC;EAC1B,aAAaC,IAAI,CAACC,IAAY,EAAmB;IAC/C,OAAO,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC9C,IAAAC,YAAQ,EAACJ,IAAI,EAAE,MAAM,EAAE,CAACK,GAAG,EAAEC,IAAI,KAAK;QACpC,IAAID,GAAG,IAAI,CAACC,IAAI,EAAE;UAChBH,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,CAACI,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaC,KAAK,CAACP,IAAY,EAAEQ,QAAgB,EAAiB;IAChE,OAAO,IAAIP,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5C,IAAAM,aAAS,EAACT,IAAI,EAAEQ,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QACzC,IAAIA,GAAG,EAAE;UACPF,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,EAAE;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaQ,MAAM,CAACV,IAAY,EAAEQ,QAAgB,EAAiB;IACjE,OAAO,IAAIP,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5C,IAAAQ,cAAU,EAACX,IAAI,EAAEQ,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QAC1C,IAAIA,GAAG,EAAE;UACPF,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,EAAE;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,OAAOU,MAAM,CAACZ,IAAY,EAAE;IAC1B,OAAO,IAAAa,cAAU,EAACb,IAAI,CAAC;EACzB;EAEA,OAAOc,QAAQ,CAACC,GAAW,EAAEC,IAAY,EAAE;IACzC,IAAI;MACF,IAAAC,gBAAY,EAACF,GAAG,EAAEC,IAAI,CAAC;IACzB,CAAC,CAAC,OAAOX,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,2BAA0BJ,GAAI,OAAMC,IAAK,IAAG,EAAEX,GAAG,CAAC;IACjE;EACF;EAEA,OAAOe,KAAK,CAACpB,IAAY,EAAEqB,OAA6B,EAAE;IACxD,IAAI;MACF,IAAAC,aAAS,EAACtB,IAAI,EAAEqB,OAAO,CAAC;IAC1B,CAAC,CAAC,OAAOhB,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,4BAA2BnB,IAAK,IAAG,EAAEK,GAAG,CAAC;IACxD;EACF;EAEA,OAAOI,SAAS,CAACT,IAAY,EAAEM,IAAY,EAAE;IAC3C,IAAI;MACF,IAAAiB,iBAAa,EAACvB,IAAI,EAAEM,IAAI,CAAC;IAC3B,CAAC,CAAC,OAAOD,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,yBAAwBnB,IAAK,IAAG,EAAEK,GAAG,CAAC;IACrD;EACF;EAEA,OAAOD,QAAQ,CAACJ,IAAY,EAAE;IAC5B,IAAI;MACF,OAAO,IAAAwB,gBAAY,EAACxB,IAAI,EAAE,OAAO,CAAC;IACpC,CAAC,CAAC,OAAOK,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,sBAAqBnB,IAAK,IAAG,EAAEK,GAAG,CAAC;IAClD;IAEA,OAAO,EAAE;EACX;AACF;AAAC"}
1
+ {"version":3,"names":["_fs","require","FileManagement","read","path","Promise","resolve","reject","readFile","err","data","write","contents","writeFile","append","appendFile","exists","existsSync","copyFile","src","dest","copyFileSync","console","log","mkdir","options","mkdirSync","writeFileSync","readFileSync","exports"],"sources":["fileManagement.ts"],"sourcesContent":["import {\n readFile,\n writeFile,\n appendFile,\n existsSync,\n copyFileSync,\n mkdirSync,\n writeFileSync,\n readFileSync,\n MakeDirectoryOptions,\n} from 'fs';\n\nexport class FileManagement {\n static async read(path: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n readFile(path, 'utf8', (err, data) => {\n if (err || !data) {\n reject(err);\n return;\n }\n resolve(data);\n });\n });\n }\n\n static async write(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n writeFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static async append(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n appendFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static exists(path: string) {\n return existsSync(path);\n }\n\n static copyFile(src: string, dest: string) {\n try {\n copyFileSync(src, dest);\n } catch (err) {\n console.log(`Error copying file from ${src} to ${dest}: `, err);\n }\n }\n\n static mkdir(path: string, options: MakeDirectoryOptions) {\n try {\n mkdirSync(path, options);\n } catch (err) {\n console.log(`Error creating directory ${path}: `, err);\n }\n }\n\n static writeFile(path: string, data: string) {\n try {\n writeFileSync(path, data);\n } catch (err) {\n console.log(`Error writing to file ${path}: `, err);\n }\n }\n\n static readFile(path: string) {\n try {\n return readFileSync(path, 'utf-8');\n } catch (err) {\n console.log(`Error reading file ${path}: `, err);\n }\n\n return '';\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AAYO,MAAMC,cAAc,CAAC;EAC1B,aAAaC,IAAIA,CAACC,IAAY,EAAmB;IAC/C,OAAO,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC9C,IAAAC,YAAQ,EAACJ,IAAI,EAAE,MAAM,EAAE,CAACK,GAAG,EAAEC,IAAI,KAAK;QACpC,IAAID,GAAG,IAAI,CAACC,IAAI,EAAE;UAChBH,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,CAACI,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaC,KAAKA,CAACP,IAAY,EAAEQ,QAAgB,EAAiB;IAChE,OAAO,IAAIP,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5C,IAAAM,aAAS,EAACT,IAAI,EAAEQ,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QACzC,IAAIA,GAAG,EAAE;UACPF,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,CAAC,CAAC;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaQ,MAAMA,CAACV,IAAY,EAAEQ,QAAgB,EAAiB;IACjE,OAAO,IAAIP,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5C,IAAAQ,cAAU,EAACX,IAAI,EAAEQ,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QAC1C,IAAIA,GAAG,EAAE;UACPF,MAAM,CAACE,GAAG,CAAC;UACX;QACF;QACAH,OAAO,CAAC,CAAC;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,OAAOU,MAAMA,CAACZ,IAAY,EAAE;IAC1B,OAAO,IAAAa,cAAU,EAACb,IAAI,CAAC;EACzB;EAEA,OAAOc,QAAQA,CAACC,GAAW,EAAEC,IAAY,EAAE;IACzC,IAAI;MACF,IAAAC,gBAAY,EAACF,GAAG,EAAEC,IAAI,CAAC;IACzB,CAAC,CAAC,OAAOX,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,2BAA0BJ,GAAI,OAAMC,IAAK,IAAG,EAAEX,GAAG,CAAC;IACjE;EACF;EAEA,OAAOe,KAAKA,CAACpB,IAAY,EAAEqB,OAA6B,EAAE;IACxD,IAAI;MACF,IAAAC,aAAS,EAACtB,IAAI,EAAEqB,OAAO,CAAC;IAC1B,CAAC,CAAC,OAAOhB,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,4BAA2BnB,IAAK,IAAG,EAAEK,GAAG,CAAC;IACxD;EACF;EAEA,OAAOI,SAASA,CAACT,IAAY,EAAEM,IAAY,EAAE;IAC3C,IAAI;MACF,IAAAiB,iBAAa,EAACvB,IAAI,EAAEM,IAAI,CAAC;IAC3B,CAAC,CAAC,OAAOD,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,yBAAwBnB,IAAK,IAAG,EAAEK,GAAG,CAAC;IACrD;EACF;EAEA,OAAOD,QAAQA,CAACJ,IAAY,EAAE;IAC5B,IAAI;MACF,OAAO,IAAAwB,gBAAY,EAACxB,IAAI,EAAE,OAAO,CAAC;IACpC,CAAC,CAAC,OAAOK,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAE,sBAAqBnB,IAAK,IAAG,EAAEK,GAAG,CAAC;IAClD;IAEA,OAAO,EAAE;EACX;AACF;AAACoB,OAAA,CAAA3B,cAAA,GAAAA,cAAA"}
@@ -5,32 +5,45 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.injectCIONotificationPodfileCode = injectCIONotificationPodfileCode;
7
7
  exports.injectCIOPodfileCode = injectCIOPodfileCode;
8
- var _ios = require("../constants/ios");
8
+ var _codeInjection = require("./codeInjection");
9
9
  var _fileManagement = require("./fileManagement");
10
10
  async function injectCIOPodfileCode(iosPath) {
11
+ const blockStart = '# --- CustomerIO Host App START ---';
12
+ const blockEnd = '# --- CustomerIO Host App END ---';
11
13
  const filename = `${iosPath}/Podfile`;
12
14
  const podfile = await _fileManagement.FileManagement.read(filename);
13
- const matches = podfile.match(_ios.CIO_PODFILE_REGEX);
14
- const targetMatch = podfile.match(_ios.CIO_CIO_TARGET_REGEX);
15
- if (!targetMatch) {
16
- const lines = podfile.split('\n');
17
- const index = lines.findIndex(line => _ios.CIO_PODFILE_POST_INSTALL_REGEX.test(line));
18
- let content = lines;
19
- if (index > -1) {
20
- content = [...lines.slice(0, index - 1), !matches ? _ios.CIO_PODFILE_SNIPPET : '', ...lines.slice(index - 1)];
21
- }
22
- _fileManagement.FileManagement.write(filename, content.join('\n'));
15
+ const matches = podfile.match(new RegExp(blockStart));
16
+ if (!matches) {
17
+ // We need to decide what line of code in the Podfile to insert our native code.
18
+ // The "post_install" line is always present in an Expo project Podfile so it's reliable.
19
+ // Find that line in the Podfile and then we will insert our code above that line.
20
+ const lineInPodfileToInjectSnippetBefore = /post_install do \|installer\|/;
21
+ const snippetToInjectInPodfile = `
22
+ ${blockStart}
23
+ pod 'customerio-reactnative/apn', :path => '../node_modules/customerio-reactnative'
24
+ ${blockEnd}
25
+ `.trim();
26
+ _fileManagement.FileManagement.write(filename, (0, _codeInjection.injectCodeByRegex)(podfile, lineInPodfileToInjectSnippetBefore, snippetToInjectInPodfile).join('\n'));
23
27
  } else {
24
- console.log('Customerio Podfile snippets already exists. Skipping...');
28
+ console.log('CustomerIO Podfile snippets already exists. Skipping...');
25
29
  }
26
30
  }
27
31
  async function injectCIONotificationPodfileCode(iosPath, useFrameworks) {
28
32
  const filename = `${iosPath}/Podfile`;
29
33
  const podfile = await _fileManagement.FileManagement.read(filename);
30
- const matches = podfile.match(_ios.CIO_PODFILE_NOTIFICATION_REGEX);
34
+ const blockStart = '# --- CustomerIO Notification START ---';
35
+ const blockEnd = '# --- CustomerIO Notification END ---';
36
+ const matches = podfile.match(new RegExp(blockStart));
31
37
  if (!matches) {
32
- const snippet = useFrameworks === 'static' ? _ios.CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET : _ios.CIO_PODFILE_NOTIFICATION_SNIPPET;
33
- _fileManagement.FileManagement.append(filename, snippet);
38
+ const snippetToInjectInPodfile = `
39
+ ${blockStart}
40
+ target 'NotificationService' do
41
+ ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}
42
+ pod 'customerio-reactnative-richpush/apn', :path => '../node_modules/customerio-reactnative'
43
+ end
44
+ ${blockEnd}
45
+ `.trim();
46
+ _fileManagement.FileManagement.append(filename, snippetToInjectInPodfile);
34
47
  }
35
48
  }
36
49
  //# sourceMappingURL=injectCIOPodfileCode.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["injectCIOPodfileCode","iosPath","filename","podfile","FileManagement","read","matches","match","CIO_PODFILE_REGEX","targetMatch","CIO_CIO_TARGET_REGEX","lines","split","index","findIndex","line","CIO_PODFILE_POST_INSTALL_REGEX","test","content","slice","CIO_PODFILE_SNIPPET","write","join","console","log","injectCIONotificationPodfileCode","useFrameworks","CIO_PODFILE_NOTIFICATION_REGEX","snippet","CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport {\n CIO_PODFILE_REGEX,\n CIO_PODFILE_SNIPPET,\n CIO_PODFILE_NOTIFICATION_SNIPPET,\n CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET,\n CIO_PODFILE_NOTIFICATION_REGEX,\n CIO_CIO_TARGET_REGEX,\n CIO_PODFILE_POST_INSTALL_REGEX,\n} from '../constants/ios';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_REGEX);\n const targetMatch = podfile.match(CIO_CIO_TARGET_REGEX);\n\n if (!targetMatch) {\n const lines = podfile.split('\\n');\n const index = lines.findIndex((line) =>\n CIO_PODFILE_POST_INSTALL_REGEX.test(line)\n );\n let content: string[] = lines;\n if (index > -1) {\n content = [\n ...lines.slice(0, index - 1),\n !matches ? CIO_PODFILE_SNIPPET : '',\n ...lines.slice(index - 1),\n ];\n }\n\n FileManagement.write(filename, content.join('\\n'));\n } else {\n console.log('Customerio Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_NOTIFICATION_REGEX);\n\n if (!matches) {\n const snippet =\n useFrameworks === 'static'\n ? CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET\n : CIO_PODFILE_NOTIFICATION_SNIPPET;\n FileManagement.append(filename, snippet);\n }\n}\n"],"mappings":";;;;;;;AACA;AASA;AAEO,eAAeA,oBAAoB,CAACC,OAAe,EAAE;EAC1D,MAAMC,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EACnD,MAAMI,OAAO,GAAGH,OAAO,CAACI,KAAK,CAACC,sBAAiB,CAAC;EAChD,MAAMC,WAAW,GAAGN,OAAO,CAACI,KAAK,CAACG,yBAAoB,CAAC;EAEvD,IAAI,CAACD,WAAW,EAAE;IAChB,MAAME,KAAK,GAAGR,OAAO,CAACS,KAAK,CAAC,IAAI,CAAC;IACjC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IACjCC,mCAA8B,CAACC,IAAI,CAACF,IAAI,CAAC,CAC1C;IACD,IAAIG,OAAiB,GAAGP,KAAK;IAC7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;MACdK,OAAO,GAAG,CACR,GAAGP,KAAK,CAACQ,KAAK,CAAC,CAAC,EAAEN,KAAK,GAAG,CAAC,CAAC,EAC5B,CAACP,OAAO,GAAGc,wBAAmB,GAAG,EAAE,EACnC,GAAGT,KAAK,CAACQ,KAAK,CAACN,KAAK,GAAG,CAAC,CAAC,CAC1B;IACH;IAEAT,8BAAc,CAACiB,KAAK,CAACnB,QAAQ,EAAEgB,OAAO,CAACI,IAAI,CAAC,IAAI,CAAC,CAAC;EACpD,CAAC,MAAM;IACLC,OAAO,CAACC,GAAG,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEO,eAAeC,gCAAgC,CACpDxB,OAAe,EACfyB,aAA0D,EAC1D;EACA,MAAMxB,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EACnD,MAAMI,OAAO,GAAGH,OAAO,CAACI,KAAK,CAACoB,mCAA8B,CAAC;EAE7D,IAAI,CAACrB,OAAO,EAAE;IACZ,MAAMsB,OAAO,GACXF,aAAa,KAAK,QAAQ,GACtBG,sDAAiD,GACjDC,qCAAgC;IACtC1B,8BAAc,CAAC2B,MAAM,CAAC7B,QAAQ,EAAE0B,OAAO,CAAC;EAC1C;AACF"}
1
+ {"version":3,"names":["_codeInjection","require","_fileManagement","injectCIOPodfileCode","iosPath","blockStart","blockEnd","filename","podfile","FileManagement","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","trim","write","injectCodeByRegex","join","console","log","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const snippetToInjectInPodfile = `\n${blockStart}\n pod 'customerio-reactnative/apn', :path => '../node_modules/customerio-reactnative'\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n console.log('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/apn', :path => '../node_modules/customerio-reactnative'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEO,eAAeE,oBAAoBA,CAACC,OAAe,EAAE;EAC1D,MAAMC,UAAU,GAAG,qCAAqC;EACxD,MAAMC,QAAQ,GAAG,mCAAmC;EAEpD,MAAMC,QAAQ,GAAI,GAAEH,OAAQ,UAAS;EACrC,MAAMI,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EACnD,MAAMI,OAAO,GAAGH,OAAO,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACR,UAAU,CAAC,CAAC;EAErD,IAAI,CAACM,OAAO,EAAE;IACZ;IACA;IACA;IACA,MAAMG,kCAAkC,GAAG,+BAA+B;IAE1E,MAAMC,wBAAwB,GAAI;AACtC,EAAEV,UAAW;AACb;AACA,EAAEC,QAAS;AACX,CAAC,CAACU,IAAI,CAAC,CAAC;IAEJP,8BAAc,CAACQ,KAAK,CAClBV,QAAQ,EACR,IAAAW,gCAAiB,EACfV,OAAO,EACPM,kCAAkC,EAClCC,wBACF,CAAC,CAACI,IAAI,CAAC,IAAI,CACb,CAAC;EACH,CAAC,MAAM;IACLC,OAAO,CAACC,GAAG,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEO,eAAeC,gCAAgCA,CACpDlB,OAAe,EACfmB,aAA0D,EAC1D;EACA,MAAMhB,QAAQ,GAAI,GAAEH,OAAQ,UAAS;EACrC,MAAMI,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMK,OAAO,GAAGH,OAAO,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACR,UAAU,CAAC,CAAC;EAErD,IAAI,CAACM,OAAO,EAAE;IACZ,MAAMI,wBAAwB,GAAI;AACtC,EAAEV,UAAW;AACb;AACA,IAAIkB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAG;AAC5E;AACA;AACA,EAAEjB,QAAS;AACX,CAAC,CAACU,IAAI,CAAC,CAAC;IAEJP,8BAAc,CAACe,MAAM,CAACjB,QAAQ,EAAEQ,wBAAwB,CAAC;EAC3D;AACF"}