Notification setListener() deprecated


I checked my plugin against the latest stable IDE API build (2022.1) using the pluginVerifier and found that my plugin is using a deprecated API for notifications. I use the setListener() method of the Notification class to add a notification listener (NotificationListener.URL_OPENING_LISTENER) to my notification instance, so that links in the notification content can be clicked and open the URL in the browser. This appears to have been deprecated in the latest stable IDE API build. I can't seem to find any logical replacement for this functionality though in the Notification class, nor does it appear to be documented anywhere. Does anyone know what API method replaces the now deprecated setListener() method on the Notification class to allow for setting a listener on a Notification instance? In my case I'm trying to allow clickable links in the notification content. See a code sample below of how to do this pre-deprecation...

NotificationGroupManager.getInstance().getNotificationGroup("Simple Notification")
.createNotification(content, NotificationType.ERROR)
.setTitle("Plugin notifications")

  /** @deprecated please use {@link #addAction(AnAction)} instead */
  public @NotNull Notification setListener(@NotNull NotificationListener listener) {


Such action can be created via com.intellij.notification.NotificationAction#createSimple(java.lang.String, java.lang.Runnable), in Runnable invoke     BrowserUtil.browse(url);


@Yann Cebron. That's partly true. The problem is what addAction(someText) will add extra text at the new line, the text is going to be highlighted as well. So for now I also didn't manage to find any alternatives to Url_Open_Listener. We are using the notification text with hyperlinks inside like "... For more information click here or contact us for etc". So basically we have existing functionality being deprecated, but no alternatives instead. We would be very glad if you can provide detailed example of how to achieve that.


There is no direct replacement that will give the same visual result. Over time, all existing code should be migrated to use replacement API as this is the official UI style now.


Please sign in to leave a comment.