Skip to content

Commit

Permalink
doEventActionSideEffects: Stop playing in-app "notification" sound.
Browse files Browse the repository at this point in the history
On iOS, for zulip#4897, we instead want to use the native
notification-sound functionality. So, do that, by adding a line to
AppDelegate.m.

We should still carve out an exception: we won't need to notify the
user if the relevant item (a new or updated message) is already on
the user's screen. Doing so could be annoying; for example, you
don't need to be notified about every single message in an active PM
conversation. That's issue zulip#3114, and it'll take some work. But this
change improves the behavior on iOS and it matches the existing
behavior on Android.

On Android, this JS function call has apparently been duplicating
the notification sound that gets played at a lower level, so it's
fine for Android to remove this.

Fixes: zulip#4897
  • Loading branch information
chrisbobbe committed Sep 10, 2021
1 parent 4209981 commit b3d8092
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ios/ZulipMobile/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ -(void)userNotificationCenter:(UNUserNotificationCenter *)center
// Update the badge count. Do not play sound or show an alert. For
// these options see
// https://developer.apple.com/documentation/usernotifications/unnotificationpresentationoptions?language=objc
completionHandler(UNNotificationPresentationOptionBadge);
completionHandler(
UNNotificationPresentationOptionBadge
| UNNotificationPresentationOptionSound
);
}

@end
2 changes: 0 additions & 2 deletions src/events/doEventActionSideEffects.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { EventAction } from '../actionTypes';
import { EVENT_NEW_MESSAGE, EVENT_TYPING_START } from '../actionConstants';
import { isHomeNarrow, isMessageInNarrow } from '../utils/narrow';
import { getActiveAccount, getChatScreenParams } from '../selectors';
import { playMessageSound } from '../utils/sound';
import { NULL_ARRAY } from '../nullObjects';
import { ensureTypingStatusExpiryLoop } from '../typing/typingActions';
import { getOwnUserId } from '../users/userSelectors';
Expand Down Expand Up @@ -38,7 +37,6 @@ const messageEvent = (state: GlobalState, message: Message): void => {
&& isMessageInNarrow(message, flags, narrow, getOwnUserId(state));
const isSenderSelf = getOwnUserId(state) === message.sender_id;
if (!isUserInSameNarrow && !isSenderSelf) {
playMessageSound();
// Vibration.vibrate();
}
};
Expand Down

0 comments on commit b3d8092

Please sign in to comment.