chrome extension notification onclick event action based on type of notification

Akhil JP

I have two different functions that creates a chrome.notification and I would like the onclick actions to be separate as well. When I browse through the chrome extension API, there isn't a mention of how to handle this situation.

Here is the code I have in my background.js

chrome.notifications.onClicked.addListener(function(event){
  chrome.tabs.create({url: 'details.html?id=' + event});
});
Iván Nokonoko

Assign a different id to each notification and check that id in the listener function:

chrome.notifications.onClicked.addListener(function(notifId){
    if (notifId == "notification_1") {
        //handle notification 1 being clicked
    }
    if (notifId == "notification_2") {
        //handle notification 2 being clicked
    }
    //etc.
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to insert notification action buttons in chrome extension?

From Dev

Chrome extension - Notification

From Dev

chrome extension disable notification sound on click of close notification button

From Dev

Close/clear a chrome extension notification while notification panel is open

From Dev

Chrome extension notification shows only once

From Dev

How to set a closing time for notification extension chrome

From Dev

Chrome Extension Notification Buttons not showing on MacOs/OSX

From Dev

IOS notification content extension: add buttons in storyboard and handle the click action

From Dev

Chrome extension browser action event not firing

From Dev

Chrome extension: Creating a new tab after clicking on the notification

From Dev

Chrome extension - Notification.requestPermission() does not ask for permission

From Dev

Chrome extension - Notification.requestPermission() does not ask for permission

From Dev

Is there any way to insert action buttons in notification in Google Chrome

From Dev

Can I include more than 2 action buttons in chrome notification?

From Dev

iOS Share Extension notification

From Dev

Clearing notification onclick/toggle()

From Dev

onClick Notification to fragment Android

From Dev

Action buttons are not shown in notification

From Dev

Execute an action on notification click

From Dev

Change default action for a Notification

From Dev

Add Action To Firebase Notification

From Dev

Add action to background of a Notification

From Dev

Notification and Action center is gone

From Dev

Notification without "Open" action

From Dev

Not able to load data URL for GCM push notification for chrome in 'notificationclick' event

From Dev

Not able to load data URL for GCM push notification for chrome in 'notificationclick' event

From Dev

Launch Notification type extension in Sony Smartwatch2

From Dev

Small Thumbnail in Collapsed Notification with Notification Content Extension

From Dev

Is the notification of completion of a background job based on some callback event-handling?

Related Related

  1. 1

    How to insert notification action buttons in chrome extension?

  2. 2

    Chrome extension - Notification

  3. 3

    chrome extension disable notification sound on click of close notification button

  4. 4

    Close/clear a chrome extension notification while notification panel is open

  5. 5

    Chrome extension notification shows only once

  6. 6

    How to set a closing time for notification extension chrome

  7. 7

    Chrome Extension Notification Buttons not showing on MacOs/OSX

  8. 8

    IOS notification content extension: add buttons in storyboard and handle the click action

  9. 9

    Chrome extension browser action event not firing

  10. 10

    Chrome extension: Creating a new tab after clicking on the notification

  11. 11

    Chrome extension - Notification.requestPermission() does not ask for permission

  12. 12

    Chrome extension - Notification.requestPermission() does not ask for permission

  13. 13

    Is there any way to insert action buttons in notification in Google Chrome

  14. 14

    Can I include more than 2 action buttons in chrome notification?

  15. 15

    iOS Share Extension notification

  16. 16

    Clearing notification onclick/toggle()

  17. 17

    onClick Notification to fragment Android

  18. 18

    Action buttons are not shown in notification

  19. 19

    Execute an action on notification click

  20. 20

    Change default action for a Notification

  21. 21

    Add Action To Firebase Notification

  22. 22

    Add action to background of a Notification

  23. 23

    Notification and Action center is gone

  24. 24

    Notification without "Open" action

  25. 25

    Not able to load data URL for GCM push notification for chrome in 'notificationclick' event

  26. 26

    Not able to load data URL for GCM push notification for chrome in 'notificationclick' event

  27. 27

    Launch Notification type extension in Sony Smartwatch2

  28. 28

    Small Thumbnail in Collapsed Notification with Notification Content Extension

  29. 29

    Is the notification of completion of a background job based on some callback event-handling?

HotTag

Archive