Esempio n. 1
0
        public void checkHomeStatus(Home home)
        {
            var predictedDoorLockPercentage = predictDoorLockPercentage(home);

            if (predictedDoorLockPercentage - (home.DLMs.Count(dlm => dlm.IsLocked) / home.DLMs.Count) > 0.25)
            {
                _apns.SendPushNotifications(home.Users.Where(user => user.DeviceToken != null && user.DeviceToken.Length == 64).Select(user => user.DeviceToken), JObject.Parse("{'aps':{'alert':{'title': 'Home Alert','body': 'Home is in an unsafe state. Would you like to lock your doors?'},'badge':1,'sound':'default','category': 'ML_CATEGORY'}}"));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> SendPushForHome()
        {
            var currentUser = await _userManager.GetUserAsync(HttpContext.User);

            if (currentUser.HomeId == null)
            {
                return(BadRequest());
            }

            var home = await _repository.GetHomeById(currentUser.HomeId);

            _apns.SendPushNotifications(home.Users.Where(user => user.DeviceToken != null && user.DeviceToken.Length == 64).Select(user => user.DeviceToken), JObject.Parse("{'aps':{'alert':{'title': 'Home Alert','body': 'Home is in an unsafe state. Would you like to lock your doors?'},'badge':1,'sound':'default','category': 'ML_CATEGORY'}}"));

            return(Ok(home.Users.Where(user => user.DeviceToken != null && user.DeviceToken.Length == 64).Select(user => user.DeviceToken)));
        }