Пример #1
0
        public ActionResult GetRegistrationStatus()
        {
            PushRegistrationRequest request = ApiRequestBase.ParseRequest <PushRegistrationRequest>(this);

            if (!request.Validate(out Project p, out ApiResponseBase error))
            {
                return(Json(error));
            }

            User user = session.GetUser();

            string[] keys       = user.GetPushNotificationSubscriptions(request.projectName, request.folderId);
            bool     subscribed = keys.Contains(request.subscriptionKey);

            return(Json(new GetRegistrationStatusResponse(subscribed)));
        }
Пример #2
0
        public ActionResult UnregisterForPush()
        {
            PushRegistrationRequest request = ApiRequestBase.ParseRequest <PushRegistrationRequest>(this);

            if (!request.Validate(out Project p, out ApiResponseBase error))
            {
                return(Json(error));
            }

            User user = session.GetUser();

            user.SetPushNotificationSubscription(request.projectName, request.folderId, request.subscriptionKey, false);
            Settings.data.Save();

            return(Json(new ApiResponseBase(true)));
        }