diff --git a/examples/build.md b/examples/build.md index 3b2ae96d..a12d9f32 100644 --- a/examples/build.md +++ b/examples/build.md @@ -275,6 +275,13 @@ Create `src/theme.ts` with `AppColors`, `AppSpacing`, and `AppTheme` objects. Ex ### iOS - Standard React Native setup with push notification entitlement +### Custom Notification Sound + +Copy `vine_boom.wav` from [sdk-shared/assets](https://github.com/OneSignal/sdk-shared/tree/main/assets) and place in: + +- **Android**: `android/app/src/main/res/raw/vine_boom.wav` +- **iOS**: `ios/demo/vine_boom.wav` (add to Xcode project as a bundle resource) + --- ## Key Files Structure diff --git a/examples/demo/android/app/src/main/res/raw/vine_boom.wav b/examples/demo/android/app/src/main/res/raw/vine_boom.wav new file mode 100644 index 00000000..626bd5cc Binary files /dev/null and b/examples/demo/android/app/src/main/res/raw/vine_boom.wav differ diff --git a/examples/demo/assets/vine_boom.wav b/examples/demo/assets/vine_boom.wav new file mode 100644 index 00000000..626bd5cc Binary files /dev/null and b/examples/demo/assets/vine_boom.wav differ diff --git a/examples/demo/bun.lock b/examples/demo/bun.lock index 17cce7dd..6ee1b97d 100644 --- a/examples/demo/bun.lock +++ b/examples/demo/bun.lock @@ -1368,7 +1368,7 @@ "react-native": ["react-native@0.84.0", "", { "dependencies": { "@jest/create-cache-key-function": "^29.7.0", "@react-native/assets-registry": "0.84.0", "@react-native/codegen": "0.84.0", "@react-native/community-cli-plugin": "0.84.0", "@react-native/gradle-plugin": "0.84.0", "@react-native/js-polyfills": "0.84.0", "@react-native/normalize-colors": "0.84.0", "@react-native/virtualized-lists": "0.84.0", "abort-controller": "^3.0.0", "anser": "^1.4.9", "ansi-regex": "^5.0.0", "babel-jest": "^29.7.0", "babel-plugin-syntax-hermes-parser": "0.32.0", "base64-js": "^1.5.1", "commander": "^12.0.0", "flow-enums-runtime": "^0.0.6", "hermes-compiler": "250829098.0.7", "invariant": "^2.2.4", "jest-environment-node": "^29.7.0", "memoize-one": "^5.0.0", "metro-runtime": "^0.83.3", "metro-source-map": "^0.83.3", "nullthrows": "^1.1.1", "pretty-format": "^29.7.0", "promise": "^8.3.0", "react-devtools-core": "^6.1.5", "react-refresh": "^0.14.0", "regenerator-runtime": "^0.13.2", "scheduler": "0.27.0", "semver": "^7.1.3", "stacktrace-parser": "^0.1.10", "tinyglobby": "^0.2.15", "whatwg-fetch": "^3.0.0", "ws": "^7.5.10", "yargs": "^17.6.2" }, "peerDependencies": { "@types/react": "^19.1.1", "react": "^19.2.3" }, "optionalPeers": ["@types/react"], "bin": { "react-native": "cli.js" } }, "sha512-CcBfucLDHz8MAjQx9kFXasYtpcn8zP1YapUgGtAy0psRZTLShwF9yeh5+ErSgEK2gXV1CCSz7hqCZqx1eMyBLA=="], - "react-native-onesignal": ["react-native-onesignal@../../react-native-onesignal.tgz", { "dependencies": { "invariant": "^2.2.4" }, "peerDependencies": { "react-native": ">=0.76.0" } }, "sha512-CfyXgxsDx0Nw1GYBDDwR8LDgZ0nWbyBlZIOiDpCeJydR1nThwWuKH0F1FRbbpI+MisZuCPqHLZ1IBnZf8qfrCA=="], + "react-native-onesignal": ["react-native-onesignal@../../react-native-onesignal.tgz", { "dependencies": { "invariant": "^2.2.4" }, "peerDependencies": { "react-native": ">=0.76.0" } }, "sha512-8CwYcZoQCXlHQ2eH2sHv11cM5otYoU2HMnKn+2YDB2vAX0zv4CjG+QftYz1UTI3yfDD6Onf6EktXW6dErMPmAg=="], "react-native-safe-area-context": ["react-native-safe-area-context@5.6.2", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-4XGqMNj5qjUTYywJqpdWZ9IG8jgkS3h06sfVjfw5yZQZfWnRFXczi0GnYyFyCc2EBps/qFmoCH8fez//WumdVg=="], diff --git a/examples/demo/ios/Podfile.lock b/examples/demo/ios/Podfile.lock index 715de224..b56cf522 100644 --- a/examples/demo/ios/Podfile.lock +++ b/examples/demo/ios/Podfile.lock @@ -1446,7 +1446,7 @@ PODS: - React-RCTFBReactNativeSpec - ReactCommon/turbomodule/core - ReactNativeDependencies - - react-native-onesignal (5.3.6): + - react-native-onesignal (5.4.0): - hermes-engine - OneSignalXCFramework (= 5.5.0) - RCTRequired @@ -2349,7 +2349,7 @@ SPEC CHECKSUMS: React-logger: 9e51e01455f15cb3ef87a09a1ec773cdb22d56c1 React-Mapbuffer: 92b99e450e8ff598b27d6e4db3a75e04fd45e9a9 React-microtasksnativemodule: 2fe0f2bd2840dedbd66c0ac249c64f977f39cc18 - react-native-onesignal: eb0b07478feb04abfc7a2504d34fec0df6317140 + react-native-onesignal: 95e69fd48dbdd28700ee6ebe6a5548c107127bf3 react-native-safe-area-context: 37e680fc4cace3c0030ee46e8987d24f5d3bdab2 React-NativeModulesApple: 44a9474594566cd03659f92e38f42599c6b9dee4 React-networking: db73d91466cb134fcbdaaa579fb2de14e2c2ea01 diff --git a/examples/demo/ios/demo.xcodeproj/project.pbxproj b/examples/demo/ios/demo.xcodeproj/project.pbxproj index 2edc4ce3..cd493ce5 100644 --- a/examples/demo/ios/demo.xcodeproj/project.pbxproj +++ b/examples/demo/ios/demo.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ A10000000000000000000007 /* libPods-OneSignalWidgetExtension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A20000000000000000000010 /* libPods-OneSignalWidgetExtension.a */; }; A10000000000000000000008 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A20000000000000000000009 /* WidgetKit.framework */; }; A10000000000000000000009 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2000000000000000000000A /* SwiftUI.framework */; }; + B10000000000000000000001 /* vine_boom.wav in Resources */ = {isa = PBXBuildFile; fileRef = B20000000000000000000001 /* vine_boom.wav */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -82,6 +83,7 @@ A2000000000000000000000F /* libPods-OneSignalNotificationServiceExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OneSignalNotificationServiceExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A20000000000000000000010 /* libPods-OneSignalWidgetExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OneSignalWidgetExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A20000000000000000000011 /* demo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = demo.entitlements; path = demo/demo.entitlements; sourceTree = ""; }; + B20000000000000000000001 /* vine_boom.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = vine_boom.wav; path = demo/vine_boom.wav; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -124,6 +126,7 @@ 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */, A20000000000000000000011 /* demo.entitlements */, + B20000000000000000000001 /* vine_boom.wav */, ); name = demo; sourceTree = ""; @@ -317,6 +320,7 @@ 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 5F8F7D5C84F8947D278D5B06 /* PrivacyInfo.xcprivacy in Resources */, + B10000000000000000000001 /* vine_boom.wav in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/examples/demo/ios/demo/vine_boom.wav b/examples/demo/ios/demo/vine_boom.wav new file mode 100644 index 00000000..626bd5cc Binary files /dev/null and b/examples/demo/ios/demo/vine_boom.wav differ diff --git a/examples/demo/src/components/sections/SendPushSection.tsx b/examples/demo/src/components/sections/SendPushSection.tsx index 4fb12916..309c0501 100644 --- a/examples/demo/src/components/sections/SendPushSection.tsx +++ b/examples/demo/src/components/sections/SendPushSection.tsx @@ -31,6 +31,11 @@ export default function SendPushSection({ onPress={() => onSendNotification(NotificationType.WithImage)} testID="send_image_push_button" /> + onSendNotification(NotificationType.WithSound)} + testID="send_sound_push_button" + /> setCustomVisible(true)} diff --git a/examples/demo/src/models/NotificationType.ts b/examples/demo/src/models/NotificationType.ts index c30d1207..a4dee118 100644 --- a/examples/demo/src/models/NotificationType.ts +++ b/examples/demo/src/models/NotificationType.ts @@ -1,5 +1,6 @@ export enum NotificationType { Simple = 'Simple', WithImage = 'With Image', + WithSound = 'With Sound', Custom = 'Custom', } diff --git a/examples/demo/src/services/OneSignalApiService.ts b/examples/demo/src/services/OneSignalApiService.ts index 74d00cf3..be5a57a3 100644 --- a/examples/demo/src/services/OneSignalApiService.ts +++ b/examples/demo/src/services/OneSignalApiService.ts @@ -46,6 +46,12 @@ class OneSignalApiService { 'https://media.onesignal.com/automated_push_templates/ratings_template.png', }; break; + case NotificationType.WithSound: + headings = { en: 'Sound Notification' }; + contents = { en: 'This notification plays a custom sound' }; + extra.ios_sound = 'vine_boom.wav'; + extra.android_channel_id = 'b3b015d9-c050-4042-8548-dcc34aa44aa4'; + break; default: return false; } diff --git a/examples/setup.sh b/examples/setup.sh index f3ee093f..33157c0c 100755 --- a/examples/setup.sh +++ b/examples/setup.sh @@ -1,10 +1,12 @@ +set -euo pipefail + ORIGINAL_DIR=$(pwd) # Build root package cd ../../ bun run build -rm -f react-native-onesignal.tgz +rm -f react-native-onesignal*.tgz bun pm pack mv react-native-onesignal-*.tgz react-native-onesignal.tgz