diff --git a/example/App.js b/example/App.js
index 67675556d..eed403533 100644
--- a/example/App.js
+++ b/example/App.js
@@ -49,6 +49,13 @@ export default class App extends Component {
}}>
Local Notification (now)
+ {
+ this.notif.localNotif('sample.mp3');
+ }}>
+ Local Notification with sound (now)
+
{
@@ -56,6 +63,13 @@ export default class App extends Component {
}}>
Schedule Notification in 30s
+ {
+ this.notif.scheduleNotif('sample.mp3');
+ }}>
+ Schedule Notification with sound in 30s
+
{
diff --git a/example/NotifService.js b/example/NotifService.js
index 3ffdb9b66..58b43467e 100644
--- a/example/NotifService.js
+++ b/example/NotifService.js
@@ -9,7 +9,7 @@ export default class NotifService {
NotificationHandler.attachNotification(onNotification);
}
- localNotif() {
+ localNotif(soundName) {
this.lastId++;
PushNotification.localNotification({
/* Android Only Properties */
@@ -35,14 +35,14 @@ export default class NotifService {
/* iOS and Android properties */
title: 'Local Notification', // (optional)
message: 'My Notification Message', // (required)
- playSound: false, // (optional) default: true
- soundName: 'default', // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
+ playSound: !!soundName, // (optional) default: true
+ soundName: soundName ? soundName : 'default', // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
number: 10, // (optional) Valid 32 bit integer specified as string. default: none (Cannot be zero)
actions: '["Yes", "No"]', // (Android only) See the doc for notification actions to know more
});
}
- scheduleNotif() {
+ scheduleNotif(soundName) {
this.lastId++;
PushNotification.localNotificationSchedule({
date: new Date(Date.now() + 30 * 1000), // in 30 secs
@@ -70,8 +70,8 @@ export default class NotifService {
/* iOS and Android properties */
title: 'Scheduled Notification', // (optional)
message: 'My Notification Message', // (required)
- playSound: true, // (optional) default: true
- soundName: 'default', // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
+ playSound: !!soundName, // (optional) default: true
+ soundName: soundName ? soundName : 'default', // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
});
}
diff --git a/example/android/app/src/main/res/raw/sample.mp3 b/example/android/app/src/main/res/raw/sample.mp3
new file mode 100644
index 000000000..4569ff11f
Binary files /dev/null and b/example/android/app/src/main/res/raw/sample.mp3 differ
diff --git a/example/ios/example.xcodeproj/project.pbxproj b/example/ios/example.xcodeproj/project.pbxproj
index 3fd964f4b..268d7cc50 100644
--- a/example/ios/example.xcodeproj/project.pbxproj
+++ b/example/ios/example.xcodeproj/project.pbxproj
@@ -20,6 +20,7 @@
4303B027D05E61B36AF2D9DA /* libPods-example-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D89C42625470FE853701396C /* libPods-example-tvOS.a */; };
4BF20923B09DA7D7C7D74054 /* libPods-example-exampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F3EFF15EA907A6500887787 /* libPods-example-exampleTests.a */; };
66172E2B135131DB9C88C137 /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 67C595176EF92CCFA00C1943 /* libPods-example.a */; };
+ AECB905824658DC600ED1B83 /* sample.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = AECB905724658DC600ED1B83 /* sample.mp3 */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -62,6 +63,7 @@
67C595176EF92CCFA00C1943 /* libPods-example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
68FB3463CAEF28E88730ADEE /* Pods-example-tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example-tvOSTests.release.xcconfig"; path = "Target Support Files/Pods-example-tvOSTests/Pods-example-tvOSTests.release.xcconfig"; sourceTree = ""; };
ACCB69D76B81B3D29BE3BB2B /* libPods-example-tvOSTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example-tvOSTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ AECB905724658DC600ED1B83 /* sample.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = sample.mp3; sourceTree = ""; };
AED90B1C243E6D21006F11F7 /* example.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = example.entitlements; path = example/example.entitlements; sourceTree = ""; };
B43E6CF3919EF7ACAF9CC8B7 /* 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 = ""; };
C528DBA88EA5CBFA010ECC73 /* Pods-example-exampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example-exampleTests.release.xcconfig"; path = "Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests.release.xcconfig"; sourceTree = ""; };
@@ -126,6 +128,7 @@
13B07FAE1A68108700A75B9A /* example */ = {
isa = PBXGroup;
children = (
+ AECB905724658DC600ED1B83 /* sample.mp3 */,
AED90B1C243E6D21006F11F7 /* example.entitlements */,
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
@@ -341,6 +344,7 @@
files = (
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
+ AECB905824658DC600ED1B83 /* sample.mp3 in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/example/ios/sample.mp3 b/example/ios/sample.mp3
new file mode 100644
index 000000000..4569ff11f
Binary files /dev/null and b/example/ios/sample.mp3 differ