diff --git a/Core/Resgrid.Model/PushUri.cs b/Core/Resgrid.Model/PushUri.cs index d0a709cf..6414e2d2 100644 --- a/Core/Resgrid.Model/PushUri.cs +++ b/Core/Resgrid.Model/PushUri.cs @@ -12,8 +12,6 @@ namespace Resgrid.Model [Table("PushUris")] public class PushUri : IEntity { - private string _pushLocation; - [Key] [Required] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] @@ -36,20 +34,8 @@ public class PushUri : IEntity public string DeviceId { get; set; } [Required] - public string PushLocation - { - get { return _pushLocation; } - set - { - if (_pushLocation != value) - { - _pushLocation = value; - - //if (((Platforms)PlatformType) == Platforms.Windows8 || ((Platforms)PlatformType) == Platforms.WindowsPhone7 || ((Platforms)PlatformType) == Platforms.WindowsPhone8 || ((Platforms)PlatformType) == Platforms.UnitWin) - // ChannelUri = new Uri(_pushLocation, UriKind.Absolute); - } - } - } + [ProtoMember(9)] + public string PushLocation { get; set; } [ProtoMember(5)] public int? UnitId { get; set; } diff --git a/Core/Resgrid.Services/PushService.cs b/Core/Resgrid.Services/PushService.cs index 244b84b9..18107d0b 100644 --- a/Core/Resgrid.Services/PushService.cs +++ b/Core/Resgrid.Services/PushService.cs @@ -35,7 +35,7 @@ public PushService(IPushLogsService pushLogsService, INotificationProvider notif public async Task Register(PushUri pushUri) { - if (pushUri == null || String.IsNullOrWhiteSpace(pushUri.DeviceId)) + if (pushUri == null || String.IsNullOrWhiteSpace(pushUri.DeviceId) || string.IsNullOrWhiteSpace(pushUri.PushLocation)) return false; var code = pushUri.PushLocation; diff --git a/Web/Resgrid.Web.Services/Controllers/v4/DevicesController.cs b/Web/Resgrid.Web.Services/Controllers/v4/DevicesController.cs index 554603f1..25edcd8d 100644 --- a/Web/Resgrid.Web.Services/Controllers/v4/DevicesController.cs +++ b/Web/Resgrid.Web.Services/Controllers/v4/DevicesController.cs @@ -154,8 +154,13 @@ public async Task> RegisterDevice([FromBody push.UserId = UserId; push.PlatformType = registrationInput.Platform; - var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false); - push.PushLocation = department.Code; + if (!string.IsNullOrWhiteSpace(registrationInput.Prefix)) + push.PushLocation = registrationInput.Prefix; + else + { + var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false); + push.PushLocation = department.Code; + } push.DeviceId = registrationInput.Token; push.Uuid = registrationInput.DeviceUuid;