Skip to content

Commit 0f3cd09

Browse files
authored
Fix for #119 (#221)
1 parent 73cea5f commit 0f3cd09

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

example/App.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ export const App = () => {
9494
});
9595
};
9696

97+
const sendLocalNotificationWithSound = () => {
98+
PushNotificationIOS.addNotificationRequest({
99+
id: 'notificationWithSound',
100+
title: 'Sample Title',
101+
subtitle: 'Sample Subtitle',
102+
body: 'Sample local notification with custom sound',
103+
sound: 'customSound.wav',
104+
badge: 1,
105+
});
106+
};
107+
97108
const scheduleLocalNotification = () => {
98109
PushNotificationIOS.scheduleLocalNotification({
99110
alertBody: 'Test Local Notification',
@@ -243,11 +254,14 @@ export const App = () => {
243254
return (
244255
<View style={styles.container}>
245256
<Button onPress={sendNotification} label="Send fake notification" />
246-
247257
<Button
248258
onPress={sendLocalNotification}
249259
label="Send fake local notification"
250260
/>
261+
<Button
262+
onPress={sendLocalNotificationWithSound}
263+
label="Send fake local notification with custom sound"
264+
/>
251265
<Button
252266
onPress={scheduleLocalNotification}
253267
label="Schedule fake local notification"

example/ios/example.xcodeproj/project.pbxproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
2DCD954D1E0B4F2C00145EB5 /* exampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* exampleTests.m */; };
1919
5432F7EB7F7F4537A837621A /* libPods-example-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D244570B607F65944D330F5 /* libPods-example-tvOS.a */; };
2020
7DA60D6A41F36271428AE19D /* libPods-example-tvOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 94208395677DFCD97160A544 /* libPods-example-tvOSTests.a */; };
21+
8A400557254A2B29000AA3A9 /* customSound.wav in Resources */ = {isa = PBXBuildFile; fileRef = 8A400556254A2B29000AA3A9 /* customSound.wav */; };
22+
8A400558254A2B29000AA3A9 /* customSound.wav in Resources */ = {isa = PBXBuildFile; fileRef = 8A400556254A2B29000AA3A9 /* customSound.wav */; };
2123
C5465B0C2DA5FC8811C8600F /* libPods-example-exampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AA19CB7647AA9CD05007354A /* libPods-example-exampleTests.a */; };
2224
E4D225D649DF4A69CD1D47AA /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6363838C2C9AC1ED8E8695DB /* libPods-example.a */; };
2325
/* End PBXBuildFile section */
@@ -60,6 +62,7 @@
6062
6F67B95AB047EFB4CDC1E4AC /* Pods-example-tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example-tvOS.release.xcconfig"; path = "Target Support Files/Pods-example-tvOS/Pods-example-tvOS.release.xcconfig"; sourceTree = "<group>"; };
6163
736DC2F0EF0CECD14EBBE3AF /* Pods-example-tvOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example-tvOSTests.debug.xcconfig"; path = "Target Support Files/Pods-example-tvOSTests/Pods-example-tvOSTests.debug.xcconfig"; sourceTree = "<group>"; };
6264
88185B6F69F96250716C8945 /* Pods-example-exampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example-exampleTests.debug.xcconfig"; path = "Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests.debug.xcconfig"; sourceTree = "<group>"; };
65+
8A400556254A2B29000AA3A9 /* customSound.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = customSound.wav; path = example/customSound.wav; sourceTree = "<group>"; };
6366
94208395677DFCD97160A544 /* libPods-example-tvOSTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example-tvOSTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
6467
9A1258F906FAEF290E80800D /* Pods-example-tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example-tvOS.debug.xcconfig"; path = "Target Support Files/Pods-example-tvOS/Pods-example-tvOS.debug.xcconfig"; sourceTree = "<group>"; };
6568
AA19CB7647AA9CD05007354A /* libPods-example-exampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example-exampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -125,6 +128,7 @@
125128
13B07FAE1A68108700A75B9A /* example */ = {
126129
isa = PBXGroup;
127130
children = (
131+
8A400556254A2B29000AA3A9 /* customSound.wav */,
128132
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
129133
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
130134
13B07FB01A68108700A75B9A /* AppDelegate.m */,
@@ -223,8 +227,8 @@
223227
isa = PBXNativeTarget;
224228
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "example" */;
225229
buildPhases = (
226-
D154B55232D78AA91BE854C3 /* [CP] Check Pods Manifest.lock */,
227230
FD10A7F022414F080027D42C /* Start Packager */,
231+
D154B55232D78AA91BE854C3 /* [CP] Check Pods Manifest.lock */,
228232
13B07F871A680F5B00A75B9A /* Sources */,
229233
13B07F8C1A680F5B00A75B9A /* Frameworks */,
230234
13B07F8E1A680F5B00A75B9A /* Resources */,
@@ -337,6 +341,7 @@
337341
isa = PBXResourcesBuildPhase;
338342
buildActionMask = 2147483647;
339343
files = (
344+
8A400557254A2B29000AA3A9 /* customSound.wav in Resources */,
340345
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
341346
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
342347
);
@@ -347,6 +352,7 @@
347352
buildActionMask = 2147483647;
348353
files = (
349354
2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */,
355+
8A400558254A2B29000AA3A9 /* customSound.wav in Resources */,
350356
);
351357
runOnlyForDeploymentPostprocessing = 0;
352358
};
531 KB
Binary file not shown.

index.d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ export type NotificationRequest = {
153153
badge?: number;
154154
/**
155155
* The sound to play when the notification is delivered.
156+
* The file should be added in the ios project from Xcode, on your target, so that it is bundled in the final app.
157+
* For more details see the example app.
156158
*/
157159
sound?: string;
158160
/**
@@ -209,6 +211,8 @@ export interface PresentLocalNotificationDetails {
209211
category?: string;
210212
/**
211213
* The sound played when the notification is fired (optional).
214+
* The file should be added in the ios project from Xcode, on your target, so that it is bundled in the final app
215+
* For more details see the example app.
212216
*/
213217
soundName?: string;
214218
/**
@@ -253,6 +257,8 @@ export interface ScheduleLocalNotificationDetails {
253257
fireDate: string;
254258
/**
255259
* The sound played when the notification is fired (optional).
260+
* The file should be added in the ios project from Xcode, on your target, so that it is bundled in the final app
261+
* For more details see the example app.
256262
*/
257263
soundName?: string;
258264
/**
@@ -316,7 +322,7 @@ export interface PushNotificationIOSStatic {
316322
* details is an object containing:
317323
* alertBody : The message displayed in the notification alert.
318324
* alertAction : The "action" displayed beneath an actionable notification. Defaults to "view";
319-
* soundName : The sound played when the notification is fired (optional).
325+
* soundName : The sound played when the notification is fired (optional). The file should be added in the ios project from Xcode, on your target, so that it is bundled in the final app. For more details see the example app.
320326
* category : The category of this notification, required for actionable notifications (optional).
321327
* userInfo : An optional object containing additional notification data.
322328
* applicationIconBadgeNumber (optional) : The number to display as the app's icon badge. The default value of this property is 0, which means that no badge is displayed.
@@ -330,7 +336,7 @@ export interface PushNotificationIOSStatic {
330336
* fireDate : The date and time when the system should deliver the notification.
331337
* alertBody : The message displayed in the notification alert.
332338
* alertAction : The "action" displayed beneath an actionable notification. Defaults to "view";
333-
* soundName : The sound played when the notification is fired (optional).
339+
* soundName : The sound played when the notification is fired (optional). The file should be added in the ios project from Xcode, on your target, so that it is bundled in the final app. For more details see the example app.
334340
* category : The category of this notification, required for actionable notifications (optional).
335341
* userInfo : An optional object containing additional notification data.
336342
* applicationIconBadgeNumber (optional) : The number to display as the app's icon badge. Setting the number to 0 removes the icon badge.

0 commit comments

Comments
 (0)