onesignal-expo-plugin 2.0.3 → 2.0.4

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 (41) hide show
  1. package/README.md +44 -36
  2. package/build/onesignal/withOneSignalAndroid.js +6 -12
  3. package/build/onesignal/withOneSignalIos.js +35 -25
  4. package/build/support/FileManager.js +22 -8
  5. package/build/support/NseUpdaterManager.js +1 -1
  6. package/build/support/eas/getEasManagedCredentialsConfigExtra.js +8 -9
  7. package/build/support/helpers.js +1 -2
  8. package/build/support/updatePodfile.js +1 -2
  9. package/build/types/types.js +1 -1
  10. package/package.json +12 -11
  11. package/.eslintignore +0 -6
  12. package/.eslintrc.js +0 -18
  13. package/.github/ISSUE_TEMPLATE/ask-question.yml +0 -50
  14. package/.github/ISSUE_TEMPLATE/bug-report.yml +0 -71
  15. package/.github/ISSUE_TEMPLATE/general-feedback.yml +0 -27
  16. package/.github/os_probot_metadata.js +0 -58
  17. package/.github/pull_request_template.md +0 -46
  18. package/.github/release-drafter.yml +0 -27
  19. package/.github/set_response_times.js +0 -47
  20. package/.github/workflows/Zapier.yml +0 -34
  21. package/.github/workflows/release-drafter.yml +0 -42
  22. package/.github/workflows/set_response_time.yml +0 -32
  23. package/CHANGELOG.md +0 -83
  24. package/EAS.md +0 -21
  25. package/IOS_CREDENTIALS_EAS.md +0 -170
  26. package/onesignal/withOneSignal.ts +0 -28
  27. package/onesignal/withOneSignalAndroid.ts +0 -147
  28. package/onesignal/withOneSignalIos.ts +0 -235
  29. package/support/FileManager.ts +0 -42
  30. package/support/NseUpdaterManager.ts +0 -40
  31. package/support/OneSignalLog.ts +0 -9
  32. package/support/eas/getEasManagedCredentialsConfigExtra.ts +0 -33
  33. package/support/helpers.ts +0 -41
  34. package/support/iosConstants.ts +0 -25
  35. package/support/serviceExtensionFiles/NotificationService.h +0 -8
  36. package/support/serviceExtensionFiles/NotificationService.m +0 -29
  37. package/support/serviceExtensionFiles/OneSignalNotificationServiceExtension-Info.plist +0 -31
  38. package/support/serviceExtensionFiles/OneSignalNotificationServiceExtension.entitlements +0 -10
  39. package/support/updatePodfile.ts +0 -19
  40. package/tsconfig.json +0 -16
  41. package/types/types.ts +0 -58
package/README.md CHANGED
@@ -16,44 +16,40 @@
16
16
 
17
17
  > The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.
18
18
 
19
- * 🏠 [Homepage](https://github.com/OneSignal/onesignal-expo-plugin#readme)
20
- * 🖤 [npm](https://www.npmjs.com/package/onesignal-expo-plugin)
19
+ - 🏠 [Homepage](https://github.com/OneSignal/onesignal-expo-plugin#readme)
20
+ - 🖤 [npm](https://www.npmjs.com/package/onesignal-expo-plugin)
21
21
 
22
22
  ## Overview
23
+
23
24
  This plugin is an [Expo Config Plugin](https://docs.expo.dev/guides/config-plugins/). It extends the Expo config to allow customizing the prebuild phase of managed workflow builds (no need to eject to a bare workflow). For the purposes of OneSignal integration, the plugin facilitates automatically generating/configuring the necessary native code files needed to get the [OneSignal React-Native SDK](https://github.com/OneSignal/react-native-onesignal) to work. You can think of adding a plugin as adding custom native code.
24
25
 
25
26
  ## Supported environments:
26
- * [The Expo run commands](https://docs.expo.dev/workflow/customizing/) (`expo run:[android|ios]`)
27
- * [Custom clients](https://blog.expo.dev/introducing-custom-development-clients-5a2c79a9ddf8)
28
- * [EAS Build](https://docs.expo.dev/build/introduction/)
27
+
28
+ - [The Expo run commands](https://docs.expo.dev/workflow/customizing/) (`expo run:[android|ios]`)
29
+ - [Custom clients](https://blog.expo.dev/introducing-custom-development-clients-5a2c79a9ddf8)
30
+ - [EAS Build](https://docs.expo.dev/build/introduction/)
29
31
 
30
32
  ---
31
33
 
32
34
  ## Install
33
- You need both the `onesignal-expo-plugin` *and* the `react-native-onesignal` npm package.
34
-
35
- ```sh
36
- npx expo install onesignal-expo-plugin
37
-
38
- # npm
39
- npm install react-native-onesignal
40
35
 
41
- # yarn
42
- yarn add react-native-onesignal
43
- ```
36
+ See the [Setup Guide](https://documentation.onesignal.com/docs/en/react-native-expo-sdk-setup) for setup instructions.
44
37
 
45
38
  ## Configuration in app.json / app.config.js
39
+
46
40
  ### Plugin
41
+
47
42
  Add the plugin to the **front** of the [plugin array](https://docs.expo.dev/versions/latest/config/app/). It should be added automatically if you ran `npx expo install`. Just make sure it is the first plugin in the array and to configure any desired plugin props:
48
43
 
49
44
  **app.json**
45
+
50
46
  ```json
51
47
  {
52
48
  "plugins": [
53
49
  [
54
50
  "onesignal-expo-plugin",
55
51
  {
56
- "mode": "development",
52
+ "mode": "development"
57
53
  }
58
54
  ]
59
55
  ]
@@ -63,6 +59,7 @@ Add the plugin to the **front** of the [plugin array](https://docs.expo.dev/vers
63
59
  or
64
60
 
65
61
  **app.config.js**
62
+
66
63
  ```js
67
64
  export default {
68
65
  ...
@@ -78,22 +75,25 @@ export default {
78
75
  ```
79
76
 
80
77
  #### Plugin Prop
78
+
81
79
  You can pass props to the plugin config object to configure:
82
80
 
83
- | Plugin Prop | | |
84
- |--------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
85
- | `mode` | **required** | Used to configure [APNs environment](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment) entitlement. `"development"` or `"production"` |
86
- | `devTeam` | optional | Used to configure Apple Team ID. You can find your Apple Team ID by running `expo credentials:manager` e.g: `"91SW8A37CR"` |
87
- | `iPhoneDeploymentTarget` | optional | Target `IPHONEOS_DEPLOYMENT_TARGET` value to be used when adding the iOS [NSE](https://documentation.onesignal.com/docs/service-extensions). A deployment target is nothing more than the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: `"12.0"`. |
88
- | `smallIcons` | optional | An array of local paths to small notification icons for Android. Image should be white, transparent, and 96x96 in size. Input images will be automatically scaled down and placed in the appropriate resource folders. e.g: `["./assets/ic_stat_onesignal_default.png"]`. See https://documentation.onesignal.com/docs/customize-notification-icons#small-notification-icons. |
89
- | `largeIcons` | optional | An array of local paths to large notification icons for Android. Image should be white, transparent, and 256x256 in size. e.g: `["./assets/ic_onesignal_large_icon_default.png"]`. See https://documentation.onesignal.com/docs/customize-notification-icons#large-notification-icons. |
90
- | `smallIconAccentColor` | optional | The accent color to use for notification icons on Android. Must be a valid hex value, e.g: `"#FF0000"` |
91
- | `iosNSEFilePath` | optional | The local path to a custom Notification Service Extension (NSE), written in Objective-C. The NSE will typically start as a copy of the [default NSE](https://github.com/OneSignal/onesignal-expo-plugin/blob/main/support/serviceExtensionFiles/NotificationService.m), then altered to support any custom logic required. e.g: `"./assets/NotificationService.m"`. |
81
+ | Plugin Prop | | |
82
+ | ------------------------ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
83
+ | `mode` | **required** | Used to configure [APNs environment](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment) entitlement. `"development"` or `"production"` |
84
+ | `devTeam` | optional | Used to configure Apple Team ID. You can find your Apple Team ID by running `expo credentials:manager` e.g: `"91SW8A37CR"` |
85
+ | `iPhoneDeploymentTarget` | optional | Target `IPHONEOS_DEPLOYMENT_TARGET` value to be used when adding the iOS [NSE](https://documentation.onesignal.com/docs/service-extensions). A deployment target is nothing more than the minimum version of the operating system the application can run on. This value should match the value in your Podfile e.g: `"12.0"`. |
86
+ | `smallIcons` | optional | An array of local paths to small notification icons for Android. Image should be white, transparent, and 96x96 in size. Input images will be automatically scaled down and placed in the appropriate resource folders. e.g: `["./assets/ic_stat_onesignal_default.png"]`. See https://documentation.onesignal.com/docs/customize-notification-icons#small-notification-icons. |
87
+ | `largeIcons` | optional | An array of local paths to large notification icons for Android. Image should be white, transparent, and 256x256 in size. e.g: `["./assets/ic_onesignal_large_icon_default.png"]`. See https://documentation.onesignal.com/docs/customize-notification-icons#large-notification-icons. |
88
+ | `smallIconAccentColor` | optional | The accent color to use for notification icons on Android. Must be a valid hex value, e.g: `"#FF0000"` |
89
+ | `iosNSEFilePath` | optional | The local path to a custom Notification Service Extension (NSE), written in Objective-C. The NSE will typically start as a copy of the [default NSE](https://github.com/OneSignal/onesignal-expo-plugin/blob/main/support/serviceExtensionFiles/NotificationService.m), then altered to support any custom logic required. e.g: `"./assets/NotificationService.m"`. |
92
90
 
93
91
  ### OneSignal App ID
92
+
94
93
  Add your OneSignal App ID to your [Expo constants via the `extra` param](https://docs.expo.dev/versions/latest/config/app/#extra):
95
94
 
96
95
  **Example:**
96
+
97
97
  ```json
98
98
  {
99
99
  "extra": {
@@ -105,7 +105,7 @@ Add your OneSignal App ID to your [Expo constants via the `extra` param](https:/
105
105
  You can then access the value to pass to the `initialize` function:
106
106
 
107
107
  ```js
108
- import { OneSignal } from 'react-native-onesignal';
108
+ import { OneSignal } from "react-native-onesignal";
109
109
  import Constants from "expo-constants";
110
110
  OneSignal.initialize(Constants.expoConfig.extra.oneSignalAppId);
111
111
  ```
@@ -117,31 +117,37 @@ OneSignal.initialize("YOUR-ONESIGNAL-APP-ID");
117
117
  ```
118
118
 
119
119
  ### Versioning
120
+
120
121
  In your configuration file, make sure you set:
121
122
 
122
- | Property | Details |
123
- |-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
124
- | `version` | Your app version. Corresponds to `CFBundleShortVersionString` on iOS. It is a human-readable version number of an iOS app, and is typically in the format of "X.X.X" (e.g. "1.0" or "2.3.1"). It is the version number that is typically displayed to users in the App Store and in the app itself. This value will be used in your NSE* target's plist file. |
125
- | `ios.buildNumber` | Build number for your iOS standalone app. Corresponds to `CFBundleVersion` and must match Apple's specified format (e.g: "42" or "100"). The build number is used by the App Store and iOS to identify and track different versions of an app, and is typically incremented for each new release. It is a number typically used for the developer's and system reference. This value will be used in your NSE* target's plist file. |
126
- | `ios.bundleIdentifier` | Bundle identifier for your iOS standalone app. Corresponds to `CFBundleIdentifier`. It's a unique identifier string that is used to identify an iOS app or bundle. It is typically in the format of `"com.companyname.appname"` (e.g. `"com.example.myapp"`). This value will be used in your NSE* target's plist and entitlements file. |
123
+ | Property | Details |
124
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
125
+ | `version` | Your app version. Corresponds to `CFBundleShortVersionString` on iOS. It is a human-readable version number of an iOS app, and is typically in the format of "X.X.X" (e.g. "1.0" or "2.3.1"). It is the version number that is typically displayed to users in the App Store and in the app itself. This value will be used in your NSE\* target's plist file. |
126
+ | `ios.buildNumber` | Build number for your iOS standalone app. Corresponds to `CFBundleVersion` and must match Apple's specified format (e.g: "42" or "100"). The build number is used by the App Store and iOS to identify and track different versions of an app, and is typically incremented for each new release. It is a number typically used for the developer's and system reference. This value will be used in your NSE\* target's plist file. |
127
+ | `ios.bundleIdentifier` | Bundle identifier for your iOS standalone app. Corresponds to `CFBundleIdentifier`. It's a unique identifier string that is used to identify an iOS app or bundle. It is typically in the format of `"com.companyname.appname"` (e.g. `"com.example.myapp"`). This value will be used in your NSE\* target's plist and entitlements file. |
127
128
 
128
129
  \* NSE = Notification Service Extension. Learn more about the NSE [here](https://documentation.onesignal.com/docs/service-extensions).
129
130
 
130
131
  ## EAS (Expo Application Services)
132
+
131
133
  See our [EAS documentation](EAS.md) for help with EAS.
132
134
 
133
135
  ### iOS Credentials: OneSignal + EAS
136
+
134
137
  To distribute your iOS application via EAS, you will need to ensure your credentials are set up correctly. See our [credentials setup guide for instructions](IOS_CREDENTIALS_EAS.md).
135
138
 
136
139
  ## Prebuild (optional)
140
+
137
141
  Prebuilding in Expo will result in the generation of the native runtime code for the project (and `ios` and `android` directories being built). By prebuilding, we automatically link and configure the native modules that have implemented CocoaPods, autolinking, and other config plugins. You can think of prebuild like a native code bundler.
138
142
 
139
143
  When you run `expo prebuild` we enter into a custom managed workflow which provides most of the benefits of bare workflows and managed workflows at the same time.
140
144
 
141
145
  #### Why should I prebuild?
146
+
142
147
  It may make sense to prebuild locally to inspect config plugin changes and help in debugging issues.
143
148
 
144
149
  #### Run
150
+
145
151
  ```sh
146
152
  npx expo prebuild
147
153
  ```
@@ -154,7 +160,9 @@ npx expo prebuild --clean
154
160
  **EAS Note:** if you choose to stay in a fully managed workflow by not prebuilding, EAS will still run `npx expo prebuild` at build time. You can also prebuild locally but remain in a fully managed workflow by adding the `android` and `ios` directories to your .gitignore.
155
161
 
156
162
  ## Run
157
- The following commands will prebuild *and* run your application. Note that for iOS, push notifications will **not** work in the Simulator.
163
+
164
+ The following commands will prebuild _and_ run your application. Note that for iOS, push notifications will **not** work in the Simulator.
165
+
158
166
  ```sh
159
167
  # Build and run your native iOS project
160
168
  npx expo run:ios
@@ -175,10 +183,10 @@ Give a ⭐️ if this project helped you!
175
183
 
176
184
  ## OneSignal
177
185
 
178
- * Website: https://onesignal.com
179
- * Twitter: [@onesignal](https://twitter.com/onesignal)
180
- * Github: [@OneSignal](https://github.com/OneSignal)
181
- * LinkedIn: [@onesignal](https://linkedin.com/company/onesignal)
186
+ - Website: https://onesignal.com
187
+ - Twitter: [@onesignal](https://twitter.com/onesignal)
188
+ - Github: [@OneSignal](https://github.com/OneSignal)
189
+ - LinkedIn: [@onesignal](https://linkedin.com/company/onesignal)
182
190
 
183
191
  ## 📝 License
184
192
 
@@ -24,16 +24,14 @@ const LARGE_ICON_DIRS_TO_SIZE = {
24
24
  'drawable-xxxhdpi': 256
25
25
  };
26
26
  const withSmallIcons = (config, onesignalProps) => {
27
- var _a;
28
- if (!onesignalProps.smallIcons && !((_a = config.notification) === null || _a === void 0 ? void 0 : _a.icon)) {
27
+ if (!onesignalProps.smallIcons && !config.notification?.icon) {
29
28
  return config;
30
29
  }
31
30
  // we are modifying the android build (adding files) without a base mod
32
31
  return (0, config_plugins_1.withDangerousMod)(config, [
33
32
  'android',
34
33
  async (config) => {
35
- var _a;
36
- if ((_a = config.notification) === null || _a === void 0 ? void 0 : _a.icon) {
34
+ if (config.notification?.icon) {
37
35
  await saveIconAsync(config.notification.icon, config.modRequest.projectRoot, SMALL_ICON_DIRS_TO_SIZE);
38
36
  }
39
37
  if (onesignalProps.smallIcons) {
@@ -63,15 +61,11 @@ const withSmallIconAccentColor = (config, onesignalProps) => {
63
61
  return config;
64
62
  }
65
63
  return (0, config_plugins_1.withStringsXml)(config, (config) => {
66
- var _a, _b;
67
- const colorInARGB = `FF${(_a = onesignalProps.smallIconAccentColor) === null || _a === void 0 ? void 0 : _a.replace('#', '')}`;
68
- const strings = (_b = config.modResults.resources.string) !== null && _b !== void 0 ? _b : [];
64
+ const colorInARGB = `FF${onesignalProps.smallIconAccentColor?.replace('#', '')}`;
65
+ const strings = config.modResults.resources.string ?? [];
69
66
  // Check if the accent color entry already exists
70
- const hasAccentColor = strings.some((stringEntry) => {
71
- var _a;
72
- return ((_a = stringEntry.$) === null || _a === void 0 ? void 0 : _a.name) === 'onesignal_notification_accent_color' &&
73
- stringEntry._ === colorInARGB;
74
- });
67
+ const hasAccentColor = strings.some((stringEntry) => stringEntry.$?.name === 'onesignal_notification_accent_color' &&
68
+ stringEntry._ === colorInARGB);
75
69
  if (!hasAccentColor) {
76
70
  const accentColorEntry = {
77
71
  $: { name: 'onesignal_notification_accent_color' },
@@ -5,7 +5,11 @@
5
5
  */
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
7
  if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
9
13
  }) : (function(o, m, k, k2) {
10
14
  if (k2 === undefined) k2 = k;
11
15
  o[k2] = m[k];
@@ -15,13 +19,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
19
  }) : function(o, v) {
16
20
  o["default"] = v;
17
21
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
25
39
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
40
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
41
  };
@@ -43,7 +57,7 @@ const getEasManagedCredentialsConfigExtra_1 = __importDefault(require("../suppor
43
57
  */
44
58
  const withAppEnvironment = (config, onesignalProps) => {
45
59
  return (0, config_plugins_1.withEntitlementsPlist)(config, (newConfig) => {
46
- if ((onesignalProps === null || onesignalProps === void 0 ? void 0 : onesignalProps.mode) == null) {
60
+ if (onesignalProps?.mode == null) {
47
61
  throw new Error(`
48
62
  Missing required "mode" key in your app.json or app.config.js file for "onesignal-expo-plugin".
49
63
  "mode" can be either "development" or "production".
@@ -78,12 +92,11 @@ const withRemoteNotificationsPermissions = (config) => {
78
92
  const withAppGroupPermissions = (config) => {
79
93
  const APP_GROUP_KEY = "com.apple.security.application-groups";
80
94
  return (0, config_plugins_1.withEntitlementsPlist)(config, newConfig => {
81
- var _a;
82
95
  if (!Array.isArray(newConfig.modResults[APP_GROUP_KEY])) {
83
96
  newConfig.modResults[APP_GROUP_KEY] = [];
84
97
  }
85
98
  const modResultsArray = newConfig.modResults[APP_GROUP_KEY];
86
- const entitlement = `group.${((_a = newConfig === null || newConfig === void 0 ? void 0 : newConfig.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier) || ""}.onesignal`;
99
+ const entitlement = `group.${newConfig?.ios?.bundleIdentifier || ""}.onesignal`;
87
100
  if (modResultsArray.indexOf(entitlement) !== -1) {
88
101
  return newConfig;
89
102
  }
@@ -92,8 +105,7 @@ const withAppGroupPermissions = (config) => {
92
105
  });
93
106
  };
94
107
  const withEasManagedCredentials = (config) => {
95
- var _a;
96
- (0, assert_1.default)((_a = config.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier, "Missing 'ios.bundleIdentifier' in app config.");
108
+ (0, assert_1.default)(config.ios?.bundleIdentifier, "Missing 'ios.bundleIdentifier' in app config.");
97
109
  config.extra = (0, getEasManagedCredentialsConfigExtra_1.default)(config);
98
110
  return config;
99
111
  };
@@ -115,7 +127,6 @@ const withOneSignalNSE = (config, props) => {
115
127
  return (0, config_plugins_1.withDangerousMod)(config, [
116
128
  'ios',
117
129
  async (config) => {
118
- var _a, _b, _c, _d, _e;
119
130
  const iosPath = path.join(config.modRequest.projectRoot, "ios");
120
131
  /* COPY OVER EXTENSION FILES */
121
132
  fs.mkdirSync(`${iosPath}/${iosConstants_1.NSE_TARGET_NAME}`, { recursive: true });
@@ -125,23 +136,22 @@ const withOneSignalNSE = (config, props) => {
125
136
  await FileManager_1.FileManager.copyFile(`${sourceDir}${extFile}`, targetFile);
126
137
  }
127
138
  // Copy NSE source file either from configuration-provided location, falling back to the default one.
128
- const sourcePath = (_a = props.iosNSEFilePath) !== null && _a !== void 0 ? _a : `${sourceDir}${iosConstants_1.NSE_SOURCE_FILE}`;
139
+ const sourcePath = props.iosNSEFilePath ?? `${sourceDir}${iosConstants_1.NSE_SOURCE_FILE}`;
129
140
  const targetFile = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}/${iosConstants_1.NSE_SOURCE_FILE}`;
130
141
  await FileManager_1.FileManager.copyFile(`${sourcePath}`, targetFile);
131
142
  /* MODIFY COPIED EXTENSION FILES */
132
143
  const nseUpdater = new NseUpdaterManager_1.default(iosPath);
133
- await nseUpdater.updateNSEEntitlements(`group.${(_b = config.ios) === null || _b === void 0 ? void 0 : _b.bundleIdentifier}.onesignal`);
134
- await nseUpdater.updateNSEBundleVersion((_d = (_c = config.ios) === null || _c === void 0 ? void 0 : _c.buildNumber) !== null && _d !== void 0 ? _d : iosConstants_1.DEFAULT_BUNDLE_VERSION);
135
- await nseUpdater.updateNSEBundleShortVersion((_e = config === null || config === void 0 ? void 0 : config.version) !== null && _e !== void 0 ? _e : iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION);
144
+ await nseUpdater.updateNSEEntitlements(`group.${config.ios?.bundleIdentifier}.onesignal`);
145
+ await nseUpdater.updateNSEBundleVersion(config.ios?.buildNumber ?? iosConstants_1.DEFAULT_BUNDLE_VERSION);
146
+ await nseUpdater.updateNSEBundleShortVersion(config?.version ?? iosConstants_1.DEFAULT_BUNDLE_SHORT_VERSION);
136
147
  return config;
137
148
  },
138
149
  ]);
139
150
  };
140
151
  const withOneSignalXcodeProject = (config, props) => {
141
152
  return (0, config_plugins_1.withXcodeProject)(config, newConfig => {
142
- var _a, _b;
143
153
  const xcodeProject = newConfig.modResults;
144
- if (!!xcodeProject.pbxTargetByName(iosConstants_1.NSE_TARGET_NAME)) {
154
+ if (xcodeProject.pbxTargetByName(iosConstants_1.NSE_TARGET_NAME)) {
145
155
  OneSignalLog_1.OneSignalLog.log(`${iosConstants_1.NSE_TARGET_NAME} already exists in project. Skipping...`);
146
156
  return newConfig;
147
157
  }
@@ -164,7 +174,7 @@ const withOneSignalXcodeProject = (config, props) => {
164
174
  projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
165
175
  // Add the NSE target
166
176
  // This adds PBXTargetDependency and PBXContainerItemProxy for you
167
- const nseTarget = xcodeProject.addTarget(iosConstants_1.NSE_TARGET_NAME, "app_extension", iosConstants_1.NSE_TARGET_NAME, `${(_a = config.ios) === null || _a === void 0 ? void 0 : _a.bundleIdentifier}.${iosConstants_1.NSE_TARGET_NAME}`);
177
+ const nseTarget = xcodeProject.addTarget(iosConstants_1.NSE_TARGET_NAME, "app_extension", iosConstants_1.NSE_TARGET_NAME, `${config.ios?.bundleIdentifier}.${iosConstants_1.NSE_TARGET_NAME}`);
168
178
  // Add build phases to the new target
169
179
  xcodeProject.addBuildPhase(["NotificationService.m"], "PBXSourcesBuildPhase", "Sources", nseTarget.uuid);
170
180
  xcodeProject.addBuildPhase([], "PBXResourcesBuildPhase", "Resources", nseTarget.uuid);
@@ -176,16 +186,16 @@ const withOneSignalXcodeProject = (config, props) => {
176
186
  if (typeof configurations[key].buildSettings !== "undefined" &&
177
187
  configurations[key].buildSettings.PRODUCT_NAME == `"${iosConstants_1.NSE_TARGET_NAME}"`) {
178
188
  const buildSettingsObj = configurations[key].buildSettings;
179
- buildSettingsObj.DEVELOPMENT_TEAM = props === null || props === void 0 ? void 0 : props.devTeam;
180
- buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = (_b = props === null || props === void 0 ? void 0 : props.iPhoneDeploymentTarget) !== null && _b !== void 0 ? _b : iosConstants_1.IPHONEOS_DEPLOYMENT_TARGET;
189
+ buildSettingsObj.DEVELOPMENT_TEAM = props?.devTeam;
190
+ buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = props?.iPhoneDeploymentTarget ?? iosConstants_1.IPHONEOS_DEPLOYMENT_TARGET;
181
191
  buildSettingsObj.TARGETED_DEVICE_FAMILY = iosConstants_1.TARGETED_DEVICE_FAMILY;
182
192
  buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${iosConstants_1.NSE_TARGET_NAME}/${iosConstants_1.NSE_TARGET_NAME}.entitlements`;
183
193
  buildSettingsObj.CODE_SIGN_STYLE = "Automatic";
184
194
  }
185
195
  }
186
196
  // Add development teams to both your target and the original project
187
- xcodeProject.addTargetAttribute("DevelopmentTeam", props === null || props === void 0 ? void 0 : props.devTeam, nseTarget);
188
- xcodeProject.addTargetAttribute("DevelopmentTeam", props === null || props === void 0 ? void 0 : props.devTeam);
197
+ xcodeProject.addTargetAttribute("DevelopmentTeam", props?.devTeam, nseTarget);
198
+ xcodeProject.addTargetAttribute("DevelopmentTeam", props?.devTeam);
189
199
  return newConfig;
190
200
  });
191
201
  };
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
11
15
  }) : function(o, v) {
12
16
  o["default"] = v;
13
17
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
21
35
  Object.defineProperty(exports, "__esModule", { value: true });
22
36
  exports.FileManager = void 0;
23
37
  const fs = __importStar(require("fs"));
@@ -6,8 +6,8 @@ const iosConstants_1 = require("./iosConstants");
6
6
  const entitlementsFileName = `OneSignalNotificationServiceExtension.entitlements`;
7
7
  const plistFileName = `OneSignalNotificationServiceExtension-Info.plist`;
8
8
  class NseUpdaterManager {
9
+ nsePath = '';
9
10
  constructor(iosPath) {
10
- this.nsePath = '';
11
11
  this.nsePath = `${iosPath}/${iosConstants_1.NSE_TARGET_NAME}`;
12
12
  }
13
13
  async updateNSEEntitlements(groupIdentifier) {
@@ -1,27 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = getEasManagedCredentialsConfigExtra;
3
4
  const iosConstants_1 = require("../iosConstants");
4
5
  function getEasManagedCredentialsConfigExtra(config) {
5
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
6
6
  return {
7
7
  ...config.extra,
8
8
  eas: {
9
- ...(_a = config.extra) === null || _a === void 0 ? void 0 : _a.eas,
9
+ ...config.extra?.eas,
10
10
  build: {
11
- ...(_c = (_b = config.extra) === null || _b === void 0 ? void 0 : _b.eas) === null || _c === void 0 ? void 0 : _c.build,
11
+ ...config.extra?.eas?.build,
12
12
  experimental: {
13
- ...(_f = (_e = (_d = config.extra) === null || _d === void 0 ? void 0 : _d.eas) === null || _e === void 0 ? void 0 : _e.build) === null || _f === void 0 ? void 0 : _f.experimental,
13
+ ...config.extra?.eas?.build?.experimental,
14
14
  ios: {
15
- ...(_k = (_j = (_h = (_g = config.extra) === null || _g === void 0 ? void 0 : _g.eas) === null || _h === void 0 ? void 0 : _h.build) === null || _j === void 0 ? void 0 : _j.experimental) === null || _k === void 0 ? void 0 : _k.ios,
15
+ ...config.extra?.eas?.build?.experimental?.ios,
16
16
  appExtensions: [
17
- ...((_r = (_q = (_p = (_o = (_m = (_l = config.extra) === null || _l === void 0 ? void 0 : _l.eas) === null || _m === void 0 ? void 0 : _m.build) === null || _o === void 0 ? void 0 : _o.experimental) === null || _p === void 0 ? void 0 : _p.ios) === null || _q === void 0 ? void 0 : _q.appExtensions) !== null && _r !== void 0 ? _r : []),
17
+ ...(config.extra?.eas?.build?.experimental?.ios?.appExtensions ?? []),
18
18
  {
19
19
  // keep in sync with native changes in NSE
20
20
  targetName: iosConstants_1.NSE_TARGET_NAME,
21
- bundleIdentifier: `${(_s = config === null || config === void 0 ? void 0 : config.ios) === null || _s === void 0 ? void 0 : _s.bundleIdentifier}.${iosConstants_1.NSE_TARGET_NAME}`,
21
+ bundleIdentifier: `${config?.ios?.bundleIdentifier}.${iosConstants_1.NSE_TARGET_NAME}`,
22
22
  entitlements: {
23
23
  'com.apple.security.application-groups': [
24
- `group.${(_t = config === null || config === void 0 ? void 0 : config.ios) === null || _t === void 0 ? void 0 : _t.bundleIdentifier}.onesignal`
24
+ `group.${config?.ios?.bundleIdentifier}.onesignal`
25
25
  ]
26
26
  },
27
27
  }
@@ -32,4 +32,3 @@ function getEasManagedCredentialsConfigExtra(config) {
32
32
  }
33
33
  };
34
34
  }
35
- exports.default = getEasManagedCredentialsConfigExtra;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validatePluginProps = void 0;
3
+ exports.validatePluginProps = validatePluginProps;
4
4
  const types_1 = require("../types/types");
5
5
  function validatePluginProps(props) {
6
6
  // check the type of each property
@@ -33,4 +33,3 @@ function validatePluginProps(props) {
33
33
  }
34
34
  }
35
35
  }
36
- exports.validatePluginProps = validatePluginProps;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.updatePodfile = void 0;
6
+ exports.updatePodfile = updatePodfile;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const iosConstants_1 = require("./iosConstants");
9
9
  const OneSignalLog_1 = require("./OneSignalLog");
@@ -22,4 +22,3 @@ async function updatePodfile(iosPath) {
22
22
  });
23
23
  }
24
24
  }
25
- exports.updatePodfile = updatePodfile;
@@ -14,4 +14,4 @@ var Mode;
14
14
  (function (Mode) {
15
15
  Mode["Dev"] = "development";
16
16
  Mode["Prod"] = "production";
17
- })(Mode = exports.Mode || (exports.Mode = {}));
17
+ })(Mode || (exports.Mode = Mode = {}));
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "onesignal-expo-plugin",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "The OneSignal Expo plugin allows you to use OneSignal without leaving the managed workflow. Developed in collaboration with SweetGreen.",
5
5
  "main": "./app.plugin.js",
6
+ "files": [
7
+ "build",
8
+ "app.plugin.js"
9
+ ],
6
10
  "scripts": {
7
11
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "build": "yarn run lint && rm -rf build && tsc && cp -a support/serviceExtensionFiles build/support/",
9
- "lint": "eslint . --ext .ts",
10
- "prepare": "yarn run build"
12
+ "build": "bun run lint && rm -rf build && tsc && cp -a src/support/serviceExtensionFiles build/support/",
13
+ "lint": "oxlint src examples",
14
+ "lint:fix": "oxlint src examples --fix"
11
15
  },
12
16
  "repository": {
13
17
  "type": "git",
@@ -34,14 +38,11 @@
34
38
  },
35
39
  "homepage": "https://github.com/OneSignal/onesignal-expo-plugin#readme",
36
40
  "devDependencies": {
37
- "@typescript-eslint/eslint-plugin": "^5.10.1",
38
- "@typescript-eslint/parser": "^5.10.1",
39
- "eslint": "^8.8.0",
40
- "expo-module-scripts": "^2.0.0",
41
- "readme-md-generator": "^1.0.0",
42
- "typescript": "^4.5.5"
41
+ "expo-module-scripts": "^5.0.8",
42
+ "oxlint": "^1.43.0",
43
+ "typescript": "^5.9.3"
43
44
  },
44
45
  "dependencies": {
45
- "@expo/image-utils": "^0.3.22"
46
+ "@expo/image-utils": "^0.8.8"
46
47
  }
47
48
  }
package/.eslintignore DELETED
@@ -1,6 +0,0 @@
1
- # don't ever lint node_modules
2
- node_modules
3
- # don't lint build output (make sure it's set to your correct build folder name)
4
- build
5
- # don't lint the examples projects
6
- examples
package/.eslintrc.js DELETED
@@ -1,18 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- parser: '@typescript-eslint/parser',
4
- plugins: [
5
- '@typescript-eslint',
6
- ],
7
- parserOptions: {
8
- project: "tsconfig.json",
9
- },
10
- extends: [
11
- 'eslint:recommended',
12
- 'plugin:@typescript-eslint/recommended',
13
- ],
14
- rules: {
15
- "@typescript-eslint/no-floating-promises": "error",
16
- "no-extra-boolean-cast": "off"
17
- }
18
- };
@@ -1,50 +0,0 @@
1
- name: 🙋‍♂️ Ask a question
2
- description: Tell us what's on your mind
3
- title: "[question]: "
4
- labels: ["triage"]
5
- # assignees:
6
- # - assign your sdk team e.g., onesignal/unity
7
- body:
8
- - type: markdown
9
- attributes:
10
- value: |
11
- Having issues integrating this SDK?
12
- - type: textarea
13
- id: question
14
- attributes:
15
- label: How can we help?
16
- description: Specific question regarding integrating this SDK.
17
- placeholder: How do I...?
18
- validations:
19
- required: true
20
- - type: textarea
21
- id: expo-sdk-version
22
- attributes:
23
- label: OneSignal Expo SDK version
24
- description: The version of the OneSignal Expo SDK you have a question for.
25
- placeholder: 1.0.0
26
- validations:
27
- required: true
28
- - type: dropdown
29
- id: platform
30
- attributes:
31
- label: Platform
32
- description: Which platform are you having an issue with?
33
- multiple: true
34
- options:
35
- - iOS
36
- - Android
37
- - type: textarea
38
- id: logs
39
- attributes:
40
- label: Relevant log output
41
- description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
42
- render: Shell
43
- - type: checkboxes
44
- id: terms
45
- attributes:
46
- label: Code of Conduct
47
- description: By submitting this issue, you agree to follow our [Code of Conduct](#insert-project-code-of-conduct-here)
48
- options:
49
- - label: I agree to follow this project's Code of Conduct
50
- required: true