better action resolution

This commit is contained in:
Egor 2026-02-23 09:59:12 -08:00
parent 79cf5bddd6
commit c25fb8dfb0
2 changed files with 9 additions and 7 deletions

View file

@ -1 +1 @@
0.2.0 0.2.1

View file

@ -40,17 +40,19 @@ class NotificationActionReceiver : BroadcastReceiver() {
Log.d(TAG, "Notification action triggered: $actionLabel ($actionID) for channel $channelID") Log.d(TAG, "Notification action triggered: $actionLabel ($actionID) for channel $channelID")
if (notificationTag.isNotEmpty() && notificationId != -1) {
(context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager)
.cancel(notificationTag, notificationId)
}
val pendingResult = goAsync()
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
try { try {
executeAction(context, actionEndpoint, actionMethod, data) executeAction(context, actionEndpoint, actionMethod, data)
if (notificationTag.isNotEmpty() && notificationId != -1) {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.cancel(notificationTag, notificationId)
Log.d(TAG, "Dismissed notification with tag: $notificationTag")
}
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "Failed to execute notification action: ${e.message}", e) Log.e(TAG, "Failed to execute notification action: ${e.message}", e)
} finally {
pendingResult.finish()
} }
} }
} }