From 5b53c0c48f2d93c23a453d1fd96ed33b6699dda5 Mon Sep 17 00:00:00 2001 From: Todd Martin Date: Sun, 13 Nov 2022 10:05:50 -0500 Subject: [PATCH 1/2] Added code to update PushToken that is used on login. (cherry picked from commit 264b6791372b6a5d6c8c4f9e3c7e393b3ec4392b) --- src/Core/Models/Request/DeviceRequest.cs | 3 ++- src/Core/Services/AuthService.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Core/Models/Request/DeviceRequest.cs b/src/Core/Models/Request/DeviceRequest.cs index a4cd687bba1..a2c1646e23b 100644 --- a/src/Core/Models/Request/DeviceRequest.cs +++ b/src/Core/Models/Request/DeviceRequest.cs @@ -5,10 +5,11 @@ namespace Bit.Core.Models.Request { public class DeviceRequest { - public DeviceRequest(string appId, IPlatformUtilsService platformUtilsService) + public DeviceRequest(string appId, string pushToken, IPlatformUtilsService platformUtilsService) { Type = platformUtilsService.GetDevice(); Name = platformUtilsService.GetDeviceString(); + PushToken = pushToken; Identifier = appId; } diff --git a/src/Core/Services/AuthService.cs b/src/Core/Services/AuthService.cs index db09798dbe3..ea47f777b89 100644 --- a/src/Core/Services/AuthService.cs +++ b/src/Core/Services/AuthService.cs @@ -300,7 +300,8 @@ private async Task LogInHelperAsync(string email, string hashedPassw { var storedTwoFactorToken = await _tokenService.GetTwoFactorTokenAsync(email); var appId = await _appIdService.GetAppIdAsync(); - var deviceRequest = new DeviceRequest(appId, _platformUtilsService); + var pushToken = await _stateService.GetPushCurrentTokenAsync(); + var deviceRequest = new DeviceRequest(appId, pushToken, _platformUtilsService); string[] emailPassword; string[] codeCodeVerifier; From 3e9d3787d8155f870039d5c46e47d0826c7c702e Mon Sep 17 00:00:00 2001 From: Todd Martin Date: Sun, 13 Nov 2022 10:42:18 -0500 Subject: [PATCH 2/2] Removed check for OS type before setting current push token on state. --- src/App/Services/PushNotificationListenerService.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/App/Services/PushNotificationListenerService.cs b/src/App/Services/PushNotificationListenerService.cs index 80adee2e132..8ce3367532d 100644 --- a/src/App/Services/PushNotificationListenerService.cs +++ b/src/App/Services/PushNotificationListenerService.cs @@ -187,10 +187,8 @@ await _apiService.Value.PutDeviceTokenAsync(appId, Debug.WriteLine($"{TAG} Registered device with server."); await _stateService.Value.SetPushLastRegistrationDateAsync(DateTime.UtcNow); - if (deviceType == Device.Android) - { - await _stateService.Value.SetPushCurrentTokenAsync(token); - } + + await _stateService.Value.SetPushCurrentTokenAsync(token); } #if DEBUG catch (ApiException apiEx)