Skip to content

Commit 2a86727

Browse files
rajveermalviyagnprice
authored andcommitted
notif: Don't rely on requestCode for distinct PendingIntent
The intent data URL for notification embed the conversation information, stream-id and topic name for topic conversation, and recipient-ids for dm conversations. So a distinct `requestCode` isn't necessary anymore, set it to zero (matching zulip-mobile).
1 parent 3973460 commit 2a86727

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

lib/notifications/display.dart

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,9 @@ class NotificationDisplayManager {
189189
},
190190

191191
contentIntent: PendingIntent(
192-
// TODO make intent URLs distinct, instead of requestCode
193-
// (This way is a legacy of flutter_local_notifications.)
194-
// The Intent objects we make for different conversations look the same.
195-
// They differ in their extras, but that doesn't count:
196-
// https://developer.android.com/reference/android/app/PendingIntent
197-
//
198-
// This leaves only PendingIntent.requestCode to distinguish one
199-
// PendingIntent from another; the plugin sets that to the notification ID.
200-
// We need a distinct PendingIntent for each conversation, so that the
201-
// notifications can lead to the right conversations when opened.
202-
// So, use a hash of the conversation key.
203-
requestCode: notificationIdAsHashOf(conversationKey),
192+
// The intent data URL is distinct for each conversation, so this value
193+
// doesn't matter.
194+
requestCode: 0,
204195

205196
// TODO is setting PendingIntentFlag.updateCurrent OK?
206197
// (That's a legacy of `flutter_local_notifications`.)

test/notifications/display_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void main() {
281281
..inboxStyle.isNull()
282282
..autoCancel.equals(true)
283283
..contentIntent.which((it) => it.isNotNull()
284-
..requestCode.equals(expectedId)
284+
..requestCode.equals(0)
285285
..flags.equals(expectedIntentFlags)
286286
..intent.which((it) => it
287287
..action.equals(IntentAction.view)

0 commit comments

Comments
 (0)