From 2adefecc92274541afa151196d27d9f1a5c8600d Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Wed, 20 Sep 2023 14:18:08 +0200 Subject: [PATCH] fix(android): Fix multiple notification issues - Fix updating the notification causing another vibration - Fix the "mark as read" intent being stuck --- .../kotlin/org/moxxy/moxxy_native/notifications/Helpers.kt | 4 ---- .../notifications/NotificationsImplementation.kt | 7 ++++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/android/src/main/kotlin/org/moxxy/moxxy_native/notifications/Helpers.kt b/android/src/main/kotlin/org/moxxy/moxxy_native/notifications/Helpers.kt index 0ab1016..06f6db8 100644 --- a/android/src/main/kotlin/org/moxxy/moxxy_native/notifications/Helpers.kt +++ b/android/src/main/kotlin/org/moxxy/moxxy_native/notifications/Helpers.kt @@ -1,8 +1,6 @@ package org.moxxy.moxxy_native.notifications import android.content.Intent -import android.util.Log -import org.moxxy.moxxy_native.TAG /* * Extract all user-added extra key-value pairs from @intent. @@ -10,9 +8,7 @@ import org.moxxy.moxxy_native.TAG fun extractPayloadMapFromIntent(intent: Intent): Map { val extras = mutableMapOf() intent.extras?.keySet()!!.forEach { - Log.d(TAG, "Checking $it -> ${intent.extras!!.get(it)}") if (it.startsWith("payload_")) { - Log.d(TAG, "Adding $it") extras[it.substring(8)] = intent.extras!!.getString(it) } } diff --git a/android/src/main/kotlin/org/moxxy/moxxy_native/notifications/NotificationsImplementation.kt b/android/src/main/kotlin/org/moxxy/moxxy_native/notifications/NotificationsImplementation.kt index 21f8274..6fb6d58 100644 --- a/android/src/main/kotlin/org/moxxy/moxxy_native/notifications/NotificationsImplementation.kt +++ b/android/src/main/kotlin/org/moxxy/moxxy_native/notifications/NotificationsImplementation.kt @@ -94,7 +94,7 @@ class NotificationsImplementation(private val context: Context) : MoxxyNotificat context.applicationContext, 0, replyIntent, - PendingIntent.FLAG_MUTABLE, + PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT, ) val replyAction = NotificationCompat.Action.Builder( R.drawable.reply, @@ -113,13 +113,14 @@ class NotificationsImplementation(private val context: Context) : MoxxyNotificat notification.extra?.forEach { putExtra("payload_${it.key}", it.value) + Log.d(TAG, "Adding payload_${it.key} -> ${it.value}") } } val markAsReadPendingIntent = PendingIntent.getBroadcast( context.applicationContext, 0, markAsReadIntent, - PendingIntent.FLAG_IMMUTABLE, + PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT, ) val markAsReadAction = NotificationCompat.Action.Builder( R.drawable.mark_as_read, @@ -250,7 +251,7 @@ class NotificationsImplementation(private val context: Context) : MoxxyNotificat setCategory(Notification.CATEGORY_MESSAGE) // Prevent no notification when we replied before - setOnlyAlertOnce(false) + setOnlyAlertOnce(true) // Automatically dismiss the notification on tap setAutoCancel(true)