[PR #2189] [CLOSED] [SG-823] Set push token on login #3415

Closed
opened 2025-11-26 23:32:25 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/2189
Author: @trmartin4
Created: 11/13/2022
Status: Closed

Base: masterHead: SG-816-add-push-token


📝 Commits (2)

  • 5b53c0c Added code to update PushToken that is used on login.
  • 3e9d378 Removed check for OS type before setting current push token on state.

📊 Changes

3 files changed (+6 additions, -6 deletions)

View changed files

📝 src/App/Services/PushNotificationListenerService.cs (+2 -4)
📝 src/Core/Models/Request/DeviceRequest.cs (+2 -1)
📝 src/Core/Services/AuthService.cs (+2 -1)

📄 Description

https://bitwarden.atlassian.net/browse/SG-823

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

One of the ways that a push token can be sent to the server (to subsequently be passed to the Azure Notification Hub) is on a login request. The server-side code will check for the Device information on the POST body and update the push token for the given user and device, if it exists.

This change is to populate the PushToken property on that object before it is sent on the request. Previously, all properties were set on the object except for the push token.

Code changes

DeviceRequest.cs: Added parameter to constructor for push token.
AuthService.cs: Looked up current push token from state service and passed that in to the object that is used to send the push token on the login request.
PushNotificationListenerService.cs:: Previously, SetCurrentPushTokenAsync() was only called if we were on an Android device, as it was only used for handling Android's re-generation of tokens (we compare Registered vs. Current tokens and update when they don't match). However, now we need a way to keep the current token in state even for iOS devices, as we'll be using it on login requests.

https://github.com/bitwarden/server/pull/2404 is also associated with this same problem.

Before you submit

  • Please check for formatting errors (dotnet format --verify-no-changes) (required)
  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/2189 **Author:** [@trmartin4](https://github.com/trmartin4) **Created:** 11/13/2022 **Status:** ❌ Closed **Base:** `master` ← **Head:** `SG-816-add-push-token` --- ### 📝 Commits (2) - [`5b53c0c`](https://github.com/bitwarden/android/commit/5b53c0c48f2d93c23a453d1fd96ed33b6699dda5) Added code to update PushToken that is used on login. - [`3e9d378`](https://github.com/bitwarden/android/commit/3e9d3787d8155f870039d5c46e47d0826c7c702e) Removed check for OS type before setting current push token on state. ### 📊 Changes **3 files changed** (+6 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/App/Services/PushNotificationListenerService.cs` (+2 -4) 📝 `src/Core/Models/Request/DeviceRequest.cs` (+2 -1) 📝 `src/Core/Services/AuthService.cs` (+2 -1) </details> ### 📄 Description https://bitwarden.atlassian.net/browse/SG-823 ## Type of change - [X] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective One of the ways that a push token can be sent to the server (to subsequently be passed to the Azure Notification Hub) is on a login request. The server-side code will check for the Device information on the `POST` body and update the push token for the given user and device, if it exists. This change is to populate the `PushToken` property on that object before it is sent on the request. Previously, all properties were set on the object except for the push token. ## Code changes **DeviceRequest.cs:** Added parameter to constructor for push token. **AuthService.cs:** Looked up current push token from state service and passed that in to the object that is used to send the push token on the login request. **PushNotificationListenerService.cs:**: Previously, `SetCurrentPushTokenAsync()` was only called if we were on an Android device, as it was only used for handling Android's re-generation of tokens (we compare Registered vs. Current tokens and update when they don't match). However, now we need a way to keep the current token in state even for iOS devices, as we'll be using it on login requests. https://github.com/bitwarden/server/pull/2404 is also associated with this same problem. ## Before you submit - Please check for formatting errors (`dotnet format --verify-no-changes`) (required) - Please add **unit tests** where it makes sense to do so (encouraged but not required) - If this change requires a **documentation update** - notify the documentation team - If this change has particular **deployment requirements** - notify the DevOps team --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:32:26 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#3415