//Registro en el servidor de notificaciones push public async Task <bool> RegisterPush(UserDto user) { var tries = 5; var result = false; for (int regTry = 0; regTry < tries && !result; regTry++) { var token = deviceService.GetToken(); //var token = Guid.NewGuid().ToString(); if (!string.IsNullOrEmpty(token)) { var data = new PushRegistrationDto() { DeviceId = CrossDeviceInfo.Current.Id, DeviceToken = token, DeviceType = deviceService.GetDeviceType(), Tags = GetTags(), Username = user.Username, Password = user.Password, }; result = await appService.RegisterPush(data); } await Task.Delay(2000); } return(result); }
public bool RegisterPush(PushRegistrationDto push) { var result = false; if (IsValidPush(push) && ValidateLoginUser(push)) { var pushDB = regPushRepository.GetByDeviceId(push.DeviceId); if (pushDB == null) { var newPush = entityMapper.Map <PushRegistrationDto, PushRegistration>(push); newPush.Id = Guid.NewGuid(); newPush.User = userRepository.GetUser(push.Username); newPush.CreationDate = DateTime.Now; newPush.UpdateDate = DateTime.Now; newPush.Tags = string.Join('|', push.Tags.ToArray()); result = regPushRepository.AddPushReg(newPush); } else { pushDB.User = userRepository.GetUser(push.Username); pushDB.UpdateDate = DateTime.Now; pushDB.Token = push.DeviceToken; pushDB.Tags = string.Join('|', push.Tags.ToArray()); result = regPushRepository.Update(pushDB); } } return(result); }
private bool IsValidPush(PushRegistrationDto push) { return(push != null && !string.IsNullOrEmpty(push.DeviceToken) && !string.IsNullOrEmpty(push.DeviceId)); }
public async Task <bool> RegisterPush(PushRegistrationDto data) { var result = await restClientService.PostAsync <PushRegistrationDto, bool>("api/User/RegisterPush", data); return(result.Entity); }
public IActionResult RegisterPush([FromBody] PushRegistrationDto push) { bool result = appServices.RegisterPush(push); return(Ok(result)); }