onesignal-expo-plugin 2.6.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -89,9 +89,18 @@ You can pass props to the plugin config object to configure:
89
89
  | `appGroupName` | optional | Used to configure a custom iOS [App Group](https://documentation.onesignal.com/docs/ios-sdk-setup#step-3-create-an-app-group) name. If not provided, defaults to `"group.{ios.bundleIdentifier}.onesignal"`. e.g: `"group.com.example.myapp.onesignal2"`. |
90
90
  | `nseBundleIdentifier` | optional | Used to configure a custom bundle identifier suffix for the iOS Notification Service Extension. The full bundle identifier will be `"{ios.bundleIdentifier}.{nseBundleIdentifier}"`. If not provided, defaults to `"OneSignalNotificationServiceExtension"`. |
91
91
  | `disableNSE` | optional | If `true`, the iOS Notification Service Extension (NSE) will not be added to the project. The NSE is required for badges, confirmed delivery, media attachments, and action buttons. Only disable this if you only need basic push notifications. |
92
+ | `disableLocation` | optional | If `true`, the native OneSignal location module will be excluded from iOS and Android builds. Use this if your app does not call `OneSignal.Location` and should not link native location APIs. |
92
93
  | `sounds` | optional | An array of local paths to custom notification sound files (`.wav` only, ≤30 seconds). Files are copied into the app bundle on iOS and `res/raw/` on Android. e.g: `["./assets/notification_sound.wav"]`. See https://documentation.onesignal.com/docs/customize-notification-sounds. |
93
94
  | `liveActivities` | optional | Opt in to scaffolding an iOS Widget Extension target for OneSignal Live Activities. Use `{}` for the default `OneSignalWidget` target, or pass `targetName`, `bundleIdentifierSuffix`, `widgetFilePath`, or `deploymentTarget` to customize it. See [Live Activities](#live-activities). |
94
95
 
96
+ ### Disabling Location
97
+
98
+ When `disableLocation` is enabled, the plugin configures native dependency
99
+ resolution so `react-native-onesignal` excludes the location module. On iOS, it
100
+ writes the Podfile environment setting used during CocoaPods resolution. On
101
+ Android, it writes `onesignal.disableLocation=true` to the generated Gradle
102
+ properties.
103
+
95
104
  ### Live Activities
96
105
 
97
106
  Set `liveActivities` to an object to add the native iOS Widget Extension files and Podfile target required for OneSignal Live Activities.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as OneSignalPluginProps } from "./types-BKWSKFuI.js";
1
+ import { t as OneSignalPluginProps } from "./types-1HFwNzon.js";
2
2
  import { ConfigPlugin } from "expo/config-plugins.js";
3
3
 
4
4
  //#region src/onesignal/withOneSignal.d.ts
package/dist/index.js CHANGED
@@ -36,9 +36,10 @@ const NSE_PRINCIPAL_CLASS_TEMPLATE_REGEX = /{{NSE_PRINCIPAL_CLASS}}/gm;
36
36
  const NSE_TARGET_NAME = "OneSignalNotificationServiceExtension";
37
37
  /** Default Swift template shipped under serviceExtensionFiles/. */
38
38
  const NSE_SOURCE_FILE = "NotificationService.swift";
39
- const NSE_PODFILE_SNIPPET = `
39
+ const onesignalExtensionPodDependencies = (disableLocation) => disableLocation ? ["pod 'OneSignalXCFramework/OneSignal', '>= 5.0', '< 6.0'", "pod 'OneSignalXCFramework/OneSignalInAppMessages', '>= 5.0', '< 6.0'"].join("\n ") : "pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'";
40
+ const nsePodfileSnippet = (disableLocation = false) => `
40
41
  target '${NSE_TARGET_NAME}' do
41
- pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'
42
+ ${onesignalExtensionPodDependencies(disableLocation)}
42
43
  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
43
44
  end`;
44
45
  const NSE_PODFILE_REGEX = new RegExp(`target '${NSE_TARGET_NAME}'`);
@@ -48,9 +49,9 @@ const LIVE_ACTIVITY_DEPLOYMENT_TARGET = "16.2";
48
49
  const LIVE_ACTIVITY_BUNDLE_FILE = "OneSignalWidgetBundle.swift";
49
50
  const LIVE_ACTIVITY_WIDGET_FILE = "OneSignalWidgetLiveActivity.swift";
50
51
  const LIVE_ACTIVITY_INFO_PLIST_FILE = `${LIVE_ACTIVITY_TARGET_NAME}-Info.plist`;
51
- const liveActivityPodfileSnippet = (targetName) => `
52
+ const liveActivityPodfileSnippet = (targetName, disableLocation = false) => `
52
53
  target '${targetName}' do
53
- pod 'OneSignalXCFramework', '>= 5.0', '< 6.0'
54
+ ${onesignalExtensionPodDependencies(disableLocation)}
54
55
  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
55
56
  end`;
56
57
  const liveActivityPodfileRegex = (targetName) => new RegExp(`target '${targetName}'`);
@@ -79,6 +80,7 @@ const ONESIGNAL_PLUGIN_PROPS = [
79
80
  "appGroupName",
80
81
  "nseBundleIdentifier",
81
82
  "disableNSE",
83
+ "disableLocation",
82
84
  "sounds",
83
85
  "liveActivities"
84
86
  ];
@@ -113,6 +115,7 @@ function validatePluginProps(props) {
113
115
  if (props.appGroupName && typeof props.appGroupName !== "string") throw new Error("OneSignal Expo Plugin: 'appGroupName' must be a string.");
114
116
  if (props.nseBundleIdentifier && typeof props.nseBundleIdentifier !== "string") throw new Error("OneSignal Expo Plugin: 'nseBundleIdentifier' must be a string.");
115
117
  if (props.disableNSE !== void 0 && typeof props.disableNSE !== "boolean") throw new Error("OneSignal Expo Plugin: 'disableNSE' must be a boolean.");
118
+ if (props.disableLocation !== void 0 && typeof props.disableLocation !== "boolean") throw new Error("OneSignal Expo Plugin: 'disableLocation' must be a boolean.");
116
119
  if (props.sounds !== void 0) {
117
120
  if (!Array.isArray(props.sounds)) throw new Error("OneSignal Expo Plugin: 'sounds' must be an array.");
118
121
  for (const sound of props.sounds) {
@@ -174,6 +177,7 @@ function resolveDevTeam(config, props) {
174
177
  * @see https://documentation.onesignal.com/docs/react-native-sdk-setup#step-4-install-for-ios-using-cocoapods-for-ios-apps
175
178
  */
176
179
  const RESOURCE_ROOT_PATH = "android/app/src/main/res/";
180
+ const ONESIGNAL_DISABLE_LOCATION_GRADLE_PROPERTY = "onesignal.disableLocation";
177
181
  const SMALL_ICON_DIRS_TO_SIZE = {
178
182
  "drawable-mdpi": 24,
179
183
  "drawable-hdpi": 36,
@@ -217,6 +221,21 @@ const withSmallIconAccentColor = (config, onesignalProps) => {
217
221
  return config;
218
222
  });
219
223
  };
224
+ const withLocationModuleGradleProperty = (config, onesignalProps) => {
225
+ if (onesignalProps.disableLocation == null) return config;
226
+ return (0, expo_config_plugins_js.withGradleProperties)(config, (config) => {
227
+ const properties = config.modResults;
228
+ const existingIndex = properties.findIndex((entry) => entry.type === "property" && entry.key === ONESIGNAL_DISABLE_LOCATION_GRADLE_PROPERTY);
229
+ const property = {
230
+ type: "property",
231
+ key: ONESIGNAL_DISABLE_LOCATION_GRADLE_PROPERTY,
232
+ value: onesignalProps.disableLocation ? "true" : "false"
233
+ };
234
+ if (existingIndex === -1) properties.push(property);
235
+ else properties[existingIndex] = property;
236
+ return config;
237
+ });
238
+ };
220
239
  async function saveIconsArrayAsync(projectRoot, icons, dirsToSize, defaultName) {
221
240
  for (let i = 0; i < icons.length; i++) {
222
241
  const outputName = i === 0 ? defaultName : void 0;
@@ -261,6 +280,7 @@ const withOneSignalAndroid = (config, props) => {
261
280
  config = withSmallIcons(config, props);
262
281
  config = withLargeIcons(config, props);
263
282
  config = withSmallIconAccentColor(config, props);
283
+ config = withLocationModuleGradleProperty(config, props);
264
284
  config = withSoundFiles$1(config, props);
265
285
  return config;
266
286
  };
@@ -384,14 +404,26 @@ var NseUpdaterManager = class {
384
404
  };
385
405
  //#endregion
386
406
  //#region src/support/updatePodfile.ts
387
- async function updatePodfile(iosPath) {
407
+ const ONESIGNAL_DISABLE_LOCATION_ENV = "ENV['ONESIGNAL_DISABLE_LOCATION']";
408
+ const ONESIGNAL_DISABLE_LOCATION_REGEX = /^(?:ENV\[['"]ONESIGNAL_DISABLE_LOCATION['"]\]\s*=\s*['"](true|false)['"]|\$OneSignalDisableLocation\s*=\s*(true|false))\s*$/m;
409
+ async function updatePodfile(iosPath, disableLocation = false) {
388
410
  if ((await FileManager.readFile(`${iosPath}/Podfile`)).match(NSE_PODFILE_REGEX)) {
389
411
  OneSignalLog.log(`${NSE_TARGET_NAME} target already added to Podfile. Skipping...`);
390
412
  return;
391
413
  }
392
- await fs_promises.default.appendFile(`${iosPath}/Podfile`, NSE_PODFILE_SNIPPET);
414
+ await fs_promises.default.appendFile(`${iosPath}/Podfile`, nsePodfileSnippet(disableLocation));
393
415
  OneSignalLog.log(`${NSE_TARGET_NAME} target added to Podfile.`);
394
416
  }
417
+ async function updatePodfileLocationModule(iosPath, disableLocation) {
418
+ const podfilePath = `${iosPath}/Podfile`;
419
+ const podfile = await FileManager.readFile(podfilePath);
420
+ const nextValue = `${ONESIGNAL_DISABLE_LOCATION_ENV} = '${disableLocation ? "true" : "false"}'`;
421
+ if (ONESIGNAL_DISABLE_LOCATION_REGEX.test(podfile)) {
422
+ await fs_promises.default.writeFile(podfilePath, podfile.replace(ONESIGNAL_DISABLE_LOCATION_REGEX, nextValue));
423
+ return;
424
+ }
425
+ await fs_promises.default.writeFile(podfilePath, `${nextValue}\n${podfile}`);
426
+ }
395
427
  //#endregion
396
428
  //#region src/onesignal/withOneSignalLiveActivity.ts
397
429
  /**
@@ -435,7 +467,7 @@ const withLiveActivityPodfile = (config, props) => {
435
467
  OneSignalLog.log(`${targetName} target already added to Podfile. Skipping...`);
436
468
  return config;
437
469
  }
438
- await fs.promises.appendFile(podfilePath, liveActivityPodfileSnippet(targetName));
470
+ await fs.promises.appendFile(podfilePath, liveActivityPodfileSnippet(targetName, props.disableLocation === true));
439
471
  OneSignalLog.log(`${targetName} target added to Podfile.`);
440
472
  return config;
441
473
  }]);
@@ -580,9 +612,17 @@ const withEasManagedCredentials = (config, props) => {
580
612
  config.extra = getEasManagedCredentialsConfigExtra(config, props?.appGroupName, props?.nseBundleIdentifier, props?.liveActivities, props?.disableNSE);
581
613
  return config;
582
614
  };
583
- const withOneSignalPodfile = (config) => {
615
+ const withOneSignalPodfile = (config, props) => {
616
+ return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
617
+ await updatePodfile(path.join(config.modRequest.projectRoot, "ios"), props.disableLocation === true);
618
+ return config;
619
+ }]);
620
+ };
621
+ const withLocationModulePodfile = (config, props) => {
622
+ const disableLocation = props.disableLocation;
623
+ if (disableLocation == null) return config;
584
624
  return (0, expo_config_plugins_js.withDangerousMod)(config, ["ios", async (config) => {
585
- await updatePodfile(path.join(config.modRequest.projectRoot, "ios"));
625
+ await updatePodfileLocationModule(path.join(config.modRequest.projectRoot, "ios"), disableLocation);
586
626
  return config;
587
627
  }]);
588
628
  };
@@ -685,6 +725,7 @@ const withSoundFiles = (config, onesignalProps) => {
685
725
  const withOneSignalIos = (config, props) => {
686
726
  config = withAppEnvironment(config, props);
687
727
  config = withRemoteNotificationsPermissions(config, props);
728
+ config = withLocationModulePodfile(config, props);
688
729
  if (!props.disableNSE) {
689
730
  config = withCustomAppGroupsKey(config, props);
690
731
  config = withAppGroupPermissions(config, props);
package/dist/plugin.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as OneSignalPluginProps } from "./types-BKWSKFuI.js";
1
+ import { t as OneSignalPluginProps } from "./types-1HFwNzon.js";
2
2
 
3
3
  //#region package.json.d.ts
4
4
  declare let name: string;
@@ -79,6 +79,11 @@ type OneSignalPluginProps = {
79
79
  * Only disable if you only need basic push notifications.
80
80
  */
81
81
  disableNSE?: boolean;
82
+ /**
83
+ * (optional) If true, the native OneSignal location module will be excluded from iOS and Android builds.
84
+ * OneSignal.Location APIs will not collect location and will no-op or return false.
85
+ */
86
+ disableLocation?: boolean;
82
87
  /**
83
88
  * (optional) An array of local paths to custom notification sound files (.wav only).
84
89
  * Files are added to the iOS app bundle and Android res/raw/.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onesignal-expo-plugin",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "OneSignal Expo config plugin for adding iOS and Android push notification support to managed Expo apps.",
5
5
  "keywords": [
6
6
  "EAS",