Skip to content

Commit d690152

Browse files
#13 No notification sound on ios
1 parent deced84 commit d690152

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ You can pass several options to this function, everything is optional:
6060
body: 'The body',
6161
ticker: 'The ticker',
6262
badge: 1,
63-
sound: null, // suppress sound on Android
63+
sound: null, // suppress the default sound
6464
at: new Date(new Date().getTime() + (10 * 1000)) // 10 seconds from now
6565
}]).then(
6666
function() {

local-notifications.android.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ LocalNotifications.schedule = function (arg) {
3131
options.icon = application.android.nativeApp.getApplicationInfo().icon;
3232
options.atTime = options.at ? options.at.getTime() : new Date().getTime();
3333

34-
// note that setting options.sound to explicitly to null will not add the default sound
35-
if (options.sound === undefined) {
34+
if (options.sound === undefined || options.sound === "default") {
3635
options.sound = android.media.RingtoneManager.getDefaultUri(android.media.RingtoneManager.TYPE_NOTIFICATION).toString();
3736
}
3837

39-
// TODO best move this to native lib so we can reuse it in the restorereceiver (dupl for now)
38+
// TODO best move this to native lib so we can reuse it in the restorereceiver (dupe for now)
4039
var builder = new android.support.v4.app.NotificationCompat.Builder(context)
4140
.setDefaults(0)
4241
.setContentTitle(options.title)

local-notifications.ios.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,13 @@ LocalNotifications._schedulePendingNotifications = function () {
107107
userInfoDict.setObjectForKey(options.body, "body");
108108
notification.userInfo = userInfoDict;
109109

110+
if (options.sound === undefined || options.sound === "default") {
111+
notification.soundName = UILocalNotificationDefaultSoundName;
112+
}
113+
110114
// TODO add these after v1
111115
// notification.repeatInterval = 1;
112-
// notification.soundName = null;
116+
// notification.soundName = custom..;
113117
// notification.resumeApplicationInBackground = true;
114118

115119
console.log("--- scheduling " + notification);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-local-notifications",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "The Local Notifications plugin allows your app to show notifications when the app is not running. Just like remote push notifications, but a few orders of magnitude easier to set up.",
55
"main" : "local-notifications.js",
66
"nativescript": {

0 commit comments

Comments
 (0)