public async Task <IActionResult> Create(UwpWebPushViewModel value) { await PushNotificationsWeb.SendAsync(new PushNotificationsWeb.Subscription() { Endpoint = value.EndpointUrl }, payload : "Hello"); return(RedirectToAction(nameof(Index))); }
private static async Task SendWebNotificationAsync(AdaptiveBlock block, string blockJson, Device device) { var transformResult = (await new AdaptiveBlockToWebNotificationTransformer().TransformAsync(block)); if (transformResult.Result == null) { throw new Exception(string.Join("\n", transformResult.Errors)); } else { await PushNotificationsWeb.SendAsync(device.Identifier, JsonConvert.SerializeObject(transformResult.Result)); } }
public async Task <IActionResult> Send(WebPushViewModel value) { try { if (string.IsNullOrWhiteSpace(value.SubscriptionJson)) { throw new ArgumentException("SubscriptionJson must be provided"); } await PushNotificationsWeb.SendAsync(value.SubscriptionJson, payload : value.Message, value.PublicServerKey, value.PrivateServerKey); base.ViewData["Response"] = "Successfully sent!"; } catch (Exception ex) { base.ViewData["Response"] = ex.ToString(); } return(View("Index", value)); }