public IActionResult Notify(string message, string client) { if (client == null) { return(BadRequest("No Client Name parsed.")); } PushSubscription subscription = PersistentStorage.GetSubscription(client); if (subscription == null) { return(BadRequest("Client was not found")); } var subject = configuration["VAPID:subject"]; var publicKey = configuration["VAPID:publicKey"]; var privateKey = configuration["VAPID:privateKey"]; var vapidDetails = new VapidDetails(subject, publicKey, privateKey); var webPushClient = new WebPushClient(); try { webPushClient.SendNotification(subscription, message, vapidDetails); } catch (Exception exception) { } return(View(PersistentStorage.GetClientNames())); }
public IActionResult Index(string client, string endpoint, string p256dh, string auth) { if (client == null) { return(BadRequest("No Client Name parsed.")); } if (PersistentStorage.GetClientNames().Contains(client)) { return(BadRequest("Client Name already used.")); } var subscription = new PushSubscription(endpoint, p256dh, auth); PersistentStorage.SaveSubscription(client, subscription); return(View("Notify", PersistentStorage.GetClientNames())); }
public IActionResult Notify() { return(View(PersistentStorage.GetClientNames())); }