AboutSupportDeveloper GuideVersion 42.138.100.107

Class NotificationManagerInstanceExperimental

NotificationManagers allow all HTML5 notifications created in the application to be intercepted and dispatched.

Please note, currently Notifications will only be intercepted if the following conditions are met:

  • The source WebContents has the notification webAPI permission.
  • The source WebContents is not a service worker.

Service worker and push notifications are currently not supported.

See also - Notification API (MDN)

This API is subject to change in future releases.

Methods

  • Experimental

    Destroys the current NotificationManagerInstance.

    Returns Promise<void>

    await notificationManager.destroy();
    
  • Experimental

    Dispatches a Notification lifecycle event ('close' | 'click' | 'show').

    Parameters

    • event: NotificationEvent

      Identifies the type of event to emit, and which notificationId to emit it for.

    Returns Promise<void>

    notificationManager.setNotificationHandler((notification) => {
    await mockNotificationUi.showNotification(notification);
    await notificationManager.dispatchNotificationEvent({
    notificationId: notification.notificationId,
    type: 'show
    })
    })

    See Also - Notification Click Event (MDN)

    See Also - Notification Close Event (MDN)

    See Also - Notification Show Event (MDN)

  • Experimental

    Sets the current handler for notifications. The provided function will be invoked whenever a WebContents successfully raises a notification.

    Note, only one handler can be used at a time, calling setNotificationHandler will replace any existing registered handler.

    Parameters

    • handler: NotificationHandler

      The notification handler callback which will be invoked whenever a notification is created.

    Returns Promise<void>

    const notificationManager = await fin.NotificationManager.init();
    const handler = (notification) => {
    console.log("Received the following notification", info);
    }
    await notificationManager.setNotificationHandler(handler);