在C#中使用Webpush发送通知后没有响应

时间:2017-04-20 11:03:40

标签: c# web push-notification asp.net-web-api2 web-push

我正在使用Webpush库向web应用程序发送webpush通知,我已经开发了用于发送推送通知的API,在命令API中有一个名为 SendNotification 的库中的方法,没有响应即将到来。[ [1]:https://i.stack.imgur.com/fuwpP.png][1]

public HttpResponseMessage sendNotification(Notification notify)
    {
        try
        {
            var subscription = new PushSubscription(notify.endPoint, notify.p256dh, notify.auth);
            if (subscription != null)
            {
                client.SendNotification(subscription, "clarifide notification received");
                return Request.CreateResponse(HttpStatusCode.OK, notify);
            }
            else
            {
                return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Internal Server Error");
            }
        }
        catch (WebPushException e)
        {

            return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message);
        }
    }

0 个答案:

没有答案