Skip to content

Commit 91d7cdf

Browse files
fix: [SDK-4728] normalize location opt-out env parsing
Accept ONESIGNAL_DISABLE_LOCATION values consistently across Android and iOS by treating true case-insensitively and accepting 1. Also remove the remaining iOS demo sound asset and references after the sound resource cleanup. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b598054 commit 91d7cdf

8 files changed

Lines changed: 5 additions & 9 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ See the [Setup Guide](https://documentation.onesignal.com/docs/react-native-sdk-
3535

3636
By default, `react-native-onesignal` includes OneSignal's native location module so `OneSignal.Location` works without extra setup. If your app does not use location features, you can exclude the native location module from iOS and Android builds.
3737

38-
Set `ONESIGNAL_DISABLE_LOCATION=true` in the environment before resolving or building, for both CocoaPods (iOS) and Gradle (Android):
38+
Set `ONESIGNAL_DISABLE_LOCATION=true` in the environment before resolving or building, for both CocoaPods (iOS) and Gradle (Android). The value is case-insensitive, and `1` is also accepted:
3939

4040
```sh
4141
ONESIGNAL_DISABLE_LOCATION=true pod install # iOS, from the ios directory

‎android/build.gradle‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ def safeExtGet(prop, fallback) {
77

88
def safeEnvFlagGet(prop) {
99
def value = System.getenv(prop)
10-
return value != null && value.toString().toBoolean()
10+
def normalizedValue = value?.toString()?.trim()
11+
return normalizedValue != null && (normalizedValue.equalsIgnoreCase('true') || normalizedValue == '1')
1112
}
1213

1314
def oneSignalVersion = '5.9.3'

‎examples/build.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ Create `src/theme.ts` with `AppColors`, `AppSpacing`, `AppTheme`, `AppDialogStyl
353353
### Custom Notification Sound
354354

355355
- **Android**: the WITH SOUND push sends `android_channel_id` (`ONESIGNAL_ANDROID_CHANNEL_ID` env var, with a hardcoded fallback) in `OneSignalApiService.ts`. The demo bundles `android/app/src/main/res/raw/vine_boom.wav` so the sound is available on-device; the channel itself is also configured server-side on the OneSignal app.
356-
- **iOS**: the WITH SOUND push sends `ios_sound: 'vine_boom.wav'`. The asset is bundled at `ios/demo/vine_boom.wav` and wired into the `demo` Xcode target. If you start from a fresh clone and the asset is missing, copy it from [sdk-shared/assets](https://github.com/OneSignal/sdk-shared/tree/main/assets) and drag into Xcode as a bundle resource.
357356

358357
---
359358

‎examples/demo/assets/vine_boom.wav‎

-783 KB
Binary file not shown.

‎examples/demo/ios/demo.xcodeproj/project.pbxproj‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
A10000000000000000000007 /* libPods-OneSignalWidgetExtension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A20000000000000000000010 /* libPods-OneSignalWidgetExtension.a */; };
2222
A10000000000000000000008 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A20000000000000000000009 /* WidgetKit.framework */; };
2323
A10000000000000000000009 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2000000000000000000000A /* SwiftUI.framework */; };
24-
B10000000000000000000001 /* vine_boom.wav in Resources */ = {isa = PBXBuildFile; fileRef = B20000000000000000000001 /* vine_boom.wav */; };
2524
/* End PBXBuildFile section */
2625

2726
/* Begin PBXContainerItemProxy section */
@@ -83,7 +82,6 @@
8382
A2000000000000000000000F /* libPods-OneSignalNotificationServiceExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OneSignalNotificationServiceExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8483
A20000000000000000000010 /* libPods-OneSignalWidgetExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OneSignalWidgetExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8584
A20000000000000000000011 /* demo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = demo.entitlements; path = demo/demo.entitlements; sourceTree = "<group>"; };
86-
B20000000000000000000001 /* vine_boom.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = vine_boom.wav; path = demo/vine_boom.wav; sourceTree = "<group>"; };
8785
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
8886
/* End PBXFileReference section */
8987

@@ -126,7 +124,6 @@
126124
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
127125
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */,
128126
A20000000000000000000011 /* demo.entitlements */,
129-
B20000000000000000000001 /* vine_boom.wav */,
130127
);
131128
name = demo;
132129
sourceTree = "<group>";
@@ -320,7 +317,6 @@
320317
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
321318
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
322319
5F8F7D5C84F8947D278D5B06 /* PrivacyInfo.xcprivacy in Resources */,
323-
B10000000000000000000001 /* vine_boom.wav in Resources */,
324320
);
325321
runOnlyForDeploymentPostprocessing = 0;
326322
};
-783 KB
Binary file not shown.

‎examples/demo/src/services/OneSignalApiService.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class OneSignalApiService {
6262
case NotificationType.WithSound:
6363
headings = { en: 'Sound Notification' };
6464
contents = { en: 'This notification plays a custom sound' };
65-
extra.ios_sound = 'vine_boom.wav';
6665
extra.android_channel_id =
6766
ONESIGNAL_ANDROID_CHANNEL_ID?.trim() || DEFAULT_ANDROID_CHANNEL_ID;
6867
break;

‎react-native-onesignal.podspec‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
require 'json'
22
package_json = JSON.parse(File.read('package.json'))
33
onesignal_xcframework_version = '5.5.2'
4-
onesignal_disable_location = ENV['ONESIGNAL_DISABLE_LOCATION'] == 'true'
4+
onesignal_disable_location_env = ENV['ONESIGNAL_DISABLE_LOCATION'].to_s.strip.downcase
5+
onesignal_disable_location = ['true', '1'].include?(onesignal_disable_location_env)
56

67
Pod::Spec.new do |s|
78
s.name = "react-native-onesignal"

0 commit comments

Comments
 (0)