question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"mobile_app_notification_cleared" not fired when notification clicked

See original GitHub issue

Home Assistant Android version: beta-2300-f33743dc-full

Android version: 12

Phone model: Samsung Galaxy S10+

Home Assistant version: 2022.5.4

Last working Home Assistant release (if known):

Description of problem: When a notification is manually cleared, the mobile_app_notification_cleared trigger fires. When a notification is clicked, the corresponding clickAction is executed (or HomeAssistant is started if no action is set) and the notification is closed. However, the notification is then only closed, but the trigger “mobile_app_notification_cleared” is not triggered. Therefore, the “wait_for_trigger” event is also not triggered in a script, which can lead to problems/overlaps with a trigger with a timeout.

Traceback (if applicable, to get the logs you may refer to: https://companion.home-assistant.io/docs/troubleshooting/faqs/#android-crash-logs):


Screenshot of problem:

Additional information:

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
tefrackycommented, May 18, 2022

I currently do not have the time to test it by myself, but I think it should work to call the delete Intent

val deleteIntent = Intent(context, NotificationDeleteReceiver::class.java).apply {
    putExtra(NotificationDeleteReceiver.EXTRA_DATA, HashMap(data))
    putExtra(NotificationDeleteReceiver.EXTRA_NOTIFICATION_GROUP, group)
    putExtra(NotificationDeleteReceiver.EXTRA_NOTIFICATION_GROUP_ID, groupId)
}

in createOpenUriPendingIntent.

0reactions
Minckacommented, Dec 4, 2022

Another solution would be to handle the clickAction itself as an event with a custom identifier.

I found this idea of sending the intent to a Service (ok, it was loooong time ago): https://stackoverflow.com/questions/25830673/android-dont-open-app-after-performing-notification-on-click-action

If it’s something that could still be done to prevent the app to open but capture the intent, the event identifier in the clickAction could be sent through the service, or at least something related to the current notification.

In this is something possible, I would avoid using sending a fake “Notification Cleared” event through the service. In my opinion, clicking the notification is not clearing/dismissing it. There is an intent to interact with the notification. That’s why I’m not sure that fire “Notification Cleared” would be the best idea to capture this user intent.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android notification doesn't disappear after clicking the ...
Bit to be bitwise-ored into the flags field that should be set if the notification should be canceled when it is clicked by...
Read more >
"Notification" Event Not Firing When Closed Through App ...
So a run down of the problem in short: a. User opens application, push is registered. b. 'Notification' events now get triggered as...
Read more >
Notifications Not Shown - Mobile Push
When an app is in a Force Stopped / Force Killed state most events including FCM messages for push notifications will not be...
Read more >
What are Push Notifications? A Complete Guide [Up-to-date]
Similar to desktop push notifications, mobile app push notifications are also triggered by an existing/downloaded application on your device.
Read more >
Troubleshoot Slack notifications
From the Slack desktop app, open the affected workspace. Press Shift Esc . Clear the Slack app cache. Tap You at the bottom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found