Notification setListener() deprecated

Answered

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)
.setListener(NotificationListener.URL_OPENING_LISTENER)
.setTitle("Plugin notifications")
.notify(JetbrainsUtils.getCurrProject());
1 comment
Comment actions Permalink

  /** @deprecated please use {@link #addAction(AnAction)} instead */
  @Deprecated
  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);

0

Please sign in to leave a comment.