diff --git a/src/Android/Services/DeviceInfoService.cs b/src/Android/Services/DeviceInfoService.cs index 2b30f0ca4..1f12f0040 100644 --- a/src/Android/Services/DeviceInfoService.cs +++ b/src/Android/Services/DeviceInfoService.cs @@ -8,6 +8,7 @@ namespace Bit.Android.Services { public class DeviceInfoService : IDeviceInfoService { + public string Type => Xamarin.Forms.Device.Android; public string Model => Build.Model; public int Version => (int)Build.VERSION.SdkInt; public float Scale diff --git a/src/App/Abstractions/Services/IDeviceInfoService.cs b/src/App/Abstractions/Services/IDeviceInfoService.cs index 6b55bdda0..56276013b 100644 --- a/src/App/Abstractions/Services/IDeviceInfoService.cs +++ b/src/App/Abstractions/Services/IDeviceInfoService.cs @@ -2,6 +2,7 @@ { public interface IDeviceInfoService { + string Type { get; } string Model { get; } int Version { get; } float Scale { get; } diff --git a/src/App/Utilities/Helpers.cs b/src/App/Utilities/Helpers.cs index a99b415f7..39007f876 100644 --- a/src/App/Utilities/Helpers.cs +++ b/src/App/Utilities/Helpers.cs @@ -23,9 +23,14 @@ namespace Bit.App.Utilities } public static T OnPlatform(T iOS = default(T), T Android = default(T), - T WinPhone = default(T), T Windows = default(T)) + T WinPhone = default(T), T Windows = default(T), string platform = null) { - switch(Device.RuntimePlatform) + if(platform == null) + { + platform = Device.RuntimePlatform; + } + + switch(platform) { case Device.iOS: return iOS; diff --git a/src/App/Utilities/TokenHttpRequestMessage.cs b/src/App/Utilities/TokenHttpRequestMessage.cs index e76e7741a..c8e6812a2 100644 --- a/src/App/Utilities/TokenHttpRequestMessage.cs +++ b/src/App/Utilities/TokenHttpRequestMessage.cs @@ -14,6 +14,7 @@ namespace Bit.App { var tokenService = Resolver.Resolve(); var appIdService = Resolver.Resolve(); + var deviceInfoService = Resolver.Resolve(); if(!string.IsNullOrWhiteSpace(tokenService.Token)) { @@ -25,7 +26,7 @@ namespace Bit.App } Headers.Add("Device-Type", ((int)Helpers.OnPlatform(iOS: DeviceType.iOS, - Android: DeviceType.Android, Windows: DeviceType.UWP)).ToString()); + Android: DeviceType.Android, Windows: DeviceType.UWP, platform: deviceInfoService.Type)).ToString()); } public TokenHttpRequestMessage(object requestObject) diff --git a/src/UWP/Services/DeviceInfoService.cs b/src/UWP/Services/DeviceInfoService.cs index fa8f79b92..8a7f34918 100644 --- a/src/UWP/Services/DeviceInfoService.cs +++ b/src/UWP/Services/DeviceInfoService.cs @@ -13,6 +13,7 @@ namespace Bit.UWP.Services { private const string SmartCardEmulatorType = "Windows.Devices.SmartCards.SmartCardEmulator"; + public string Type => Xamarin.Forms.Device.UWP; public string Model => SystemInformation.DeviceModel; public int Version => SystemInformation.OperatingSystemVersion.Build; public float Scale => (float)DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; diff --git a/src/iOS.Core/Services/DeviceInfoService.cs b/src/iOS.Core/Services/DeviceInfoService.cs index 7015cce58..41daf9f78 100644 --- a/src/iOS.Core/Services/DeviceInfoService.cs +++ b/src/iOS.Core/Services/DeviceInfoService.cs @@ -7,14 +7,14 @@ namespace Bit.iOS.Core.Services { public class DeviceInfoService : IDeviceInfoService { + public string Type => Xamarin.Forms.Device.iOS; public string Model => UIDevice.CurrentDevice.Model; public int Version { get { - int version; var versionParts = UIDevice.CurrentDevice.SystemVersion.Split('.'); - if(versionParts.Length > 0 && int.TryParse(versionParts[0], out version)) + if(versionParts.Length > 0 && int.TryParse(versionParts[0], out int version)) { return version; }