Пример #1
0
        public async Task <ActionResult <PushSubscription> > Subscribe([FromBody] PushSubscriptionViewModel model)
        {
            var subscription = new PushSubscription
            {
                UserId         = Guid.NewGuid().ToString(), // You'd use your existing user id here
                Endpoint       = model.Subscription.Endpoint,
                ExpirationTime = model.Subscription.ExpirationTime,
                Auth           = model.Subscription.Keys.Auth,
                P256Dh         = model.Subscription.Keys.P256Dh
            };

            return(await _pushService.Subscribe(subscription));
        }
Пример #2
0
        public async Task <ActionResult <PushSubscription> > Unsubscribe([FromBody] PushSubscriptionViewModel model)
        {
            var subscription = new PushSubscription
            {
                Endpoint       = model.Subscription.Endpoint,
                ExpirationTime = model.Subscription.ExpirationTime,
                Auth           = model.Subscription.Keys.Auth,
                P256Dh         = model.Subscription.Keys.P256Dh
            };

            await _pushService.Unsubscribe(subscription);

            return(subscription);
        }