Skip to content

Commit 45095e3

Browse files
authored
chore(demo): add custom notification sound support (#1926)
1 parent 721a8e0 commit 45095e3

11 files changed

Lines changed: 29 additions & 4 deletions

File tree

examples/build.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ Create `src/theme.ts` with `AppColors`, `AppSpacing`, and `AppTheme` objects. Ex
275275
### iOS
276276
- Standard React Native setup with push notification entitlement
277277

278+
### Custom Notification Sound
279+
280+
Copy `vine_boom.wav` from [sdk-shared/assets](https://github.com/OneSignal/sdk-shared/tree/main/assets) and place in:
281+
282+
- **Android**: `android/app/src/main/res/raw/vine_boom.wav`
283+
- **iOS**: `ios/demo/vine_boom.wav` (add to Xcode project as a bundle resource)
284+
278285
---
279286

280287
## Key Files Structure
783 KB
Binary file not shown.

examples/demo/assets/vine_boom.wav

783 KB
Binary file not shown.

examples/demo/bun.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/demo/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ PODS:
14461446
- React-RCTFBReactNativeSpec
14471447
- ReactCommon/turbomodule/core
14481448
- ReactNativeDependencies
1449-
- react-native-onesignal (5.3.6):
1449+
- react-native-onesignal (5.4.0):
14501450
- hermes-engine
14511451
- OneSignalXCFramework (= 5.5.0)
14521452
- RCTRequired
@@ -2349,7 +2349,7 @@ SPEC CHECKSUMS:
23492349
React-logger: 9e51e01455f15cb3ef87a09a1ec773cdb22d56c1
23502350
React-Mapbuffer: 92b99e450e8ff598b27d6e4db3a75e04fd45e9a9
23512351
React-microtasksnativemodule: 2fe0f2bd2840dedbd66c0ac249c64f977f39cc18
2352-
react-native-onesignal: eb0b07478feb04abfc7a2504d34fec0df6317140
2352+
react-native-onesignal: 95e69fd48dbdd28700ee6ebe6a5548c107127bf3
23532353
react-native-safe-area-context: 37e680fc4cace3c0030ee46e8987d24f5d3bdab2
23542354
React-NativeModulesApple: 44a9474594566cd03659f92e38f42599c6b9dee4
23552355
React-networking: db73d91466cb134fcbdaaa579fb2de14e2c2ea01

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
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 */; };
2425
/* End PBXBuildFile section */
2526

2627
/* Begin PBXContainerItemProxy section */
@@ -82,6 +83,7 @@
8283
A2000000000000000000000F /* libPods-OneSignalNotificationServiceExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OneSignalNotificationServiceExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8384
A20000000000000000000010 /* libPods-OneSignalWidgetExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OneSignalWidgetExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8485
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>"; };
8587
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
8688
/* End PBXFileReference section */
8789

@@ -124,6 +126,7 @@
124126
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
125127
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */,
126128
A20000000000000000000011 /* demo.entitlements */,
129+
B20000000000000000000001 /* vine_boom.wav */,
127130
);
128131
name = demo;
129132
sourceTree = "<group>";
@@ -317,6 +320,7 @@
317320
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
318321
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
319322
5F8F7D5C84F8947D278D5B06 /* PrivacyInfo.xcprivacy in Resources */,
323+
B10000000000000000000001 /* vine_boom.wav in Resources */,
320324
);
321325
runOnlyForDeploymentPostprocessing = 0;
322326
};
783 KB
Binary file not shown.

examples/demo/src/components/sections/SendPushSection.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ export default function SendPushSection({
3131
onPress={() => onSendNotification(NotificationType.WithImage)}
3232
testID="send_image_push_button"
3333
/>
34+
<ActionButton
35+
label="WITH SOUND"
36+
onPress={() => onSendNotification(NotificationType.WithSound)}
37+
testID="send_sound_push_button"
38+
/>
3439
<ActionButton
3540
label="CUSTOM"
3641
onPress={() => setCustomVisible(true)}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export enum NotificationType {
22
Simple = 'Simple',
33
WithImage = 'With Image',
4+
WithSound = 'With Sound',
45
Custom = 'Custom',
56
}

examples/demo/src/services/OneSignalApiService.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ class OneSignalApiService {
4646
'https://media.onesignal.com/automated_push_templates/ratings_template.png',
4747
};
4848
break;
49+
case NotificationType.WithSound:
50+
headings = { en: 'Sound Notification' };
51+
contents = { en: 'This notification plays a custom sound' };
52+
extra.ios_sound = 'vine_boom.wav';
53+
extra.android_channel_id = 'b3b015d9-c050-4042-8548-dcc34aa44aa4';
54+
break;
4955
default:
5056
return false;
5157
}

0 commit comments

Comments
 (0)