Since DotNetBrowser 1.8.4 you can handle situation when a web page wants to display desktop notifications. You decide whether the web page is allowed to display notifications or not. By default, desktop notifications are suppressed.


Configuring notification handler

class TestNotificationHandler : INotificationHandler
{
    private Action<NotificationEventArgs> action;

    public TestNotificationHandler(Action<NotificationEventArgs> action)
    {
        this.action = action;
    }

    public void OnShowNotification(NotificationEventArgs args)
    {
        this.action(args);
    }
};
browser.Context.NotificationService.NotificationHandler = 
    new NyNotificationHandler((NotificationEventArgs e) =>
    {

       var notification = e.Notification;
        //...

    });


The Notification object contains URL, title, message and notification type.

Call Notification.Close() to inform DotNetBrowser that the notification has been closed.

The JavaScript code Notification.close() can also be used to close the notification.


Configuring permission request handler

class MyPermissionHandler : IPermissionHandler
{
    private Func<PermissionRequest, PermissionStatus> func;

    public MyPermissionHandler(Func<PermissionRequest, PermissionStatus> func)
    {
        this.func = func;
    }

    public PermissionStatus OnRequestPermission(PermissionRequest request)
    {
        return func(request);
    }
};


browser.PermissionHandler = new MyPermissionHandler((PermissionRequest request) =>
{
    return PermissionStatus.GRANTED;
});