2019-05-18 02:00:56 +02:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2017-10-21 04:37:01 +02:00
|
|
|
|
using ElectronNET.API;
|
|
|
|
|
|
using ElectronNET.API.Entities;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ElectronNET.WebApp.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class NotificationsController : Controller
|
|
|
|
|
|
{
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
|
{
|
2017-10-23 21:24:05 +02:00
|
|
|
|
if(HybridSupport.IsElectronActive)
|
|
|
|
|
|
{
|
|
|
|
|
|
Electron.IpcMain.On("basic-noti", (args) => {
|
2017-10-21 04:37:01 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
var options = new NotificationOptions("Basic Notification", "Short message part")
|
|
|
|
|
|
{
|
|
|
|
|
|
OnClick = async () => await Electron.Dialog.ShowMessageBoxAsync("Notification clicked")
|
|
|
|
|
|
};
|
2017-10-21 04:37:01 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
Electron.Notification.Show(options);
|
2017-10-21 04:37:01 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
});
|
2017-10-21 04:37:01 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
Electron.IpcMain.On("advanced-noti", (args) => {
|
2017-10-21 04:37:01 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
var options = new NotificationOptions("Notification with image", "Short message plus a custom image")
|
|
|
|
|
|
{
|
|
|
|
|
|
OnClick = async () => await Electron.Dialog.ShowMessageBoxAsync("Notification clicked"),
|
|
|
|
|
|
Icon = "/assets/img/programming.png"
|
|
|
|
|
|
};
|
2017-10-21 04:37:01 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
Electron.Notification.Show(options);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2017-10-21 04:37:01 +02:00
|
|
|
|
|
|
|
|
|
|
return View();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|