Repository navigation
DeleteDevice improvements - #5978
Merged
VelikovPetar merged 7 commits intoOct 24, 2025
Merged
Conversation
Contributor
SDK Size Comparison 📏
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the DeleteDevice operation by decoupling device deletion from persistence flushing, removing automatic deletion on unrecoverable errors, and simplifying the push token update handler to rely on user device state instead of SharedPreferences.
Key changes:
- Added a
deleteDeviceparameter to thedisconnect()method to explicitly control device deletion behavior, defaulting toflushPersistencefor backwards compatibility - Removed automatic
deleteDeviceinvocation when WebSocket encounters anUnrecoverableError, aligning with iOS SDK behavior - Refactored
PushTokenUpdateHandlerto useUser.devicesinstead of SharedPreferences and removed debouncing logic
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| PushTokenUpdateHandler.kt | Simplified to track device state in-memory and check registration against user devices |
| PushTokenUpdateHandlerTest.kt | Added comprehensive unit tests for add/delete device operations |
| ChatNotifications.kt | Updated to pass user context and removed persistence-based device cleanup |
| ChatClient.kt | Added deleteDevice parameter to disconnect method and explicit deletion on user switch |
| stream-chat-android-client.api | Updated public API surface with new disconnect overload |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…roid/client/notifications/PushTokenUpdateHandlerTest.kt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
aleksandar-apostolov
approved these changes
Oct 24, 2025
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


🎯 Goal
This PR includes several changes related to the
DeleteDeviceoperation:deleteDeviceinvocation from theflushPersistenceflag. It introduces a newdeleteDevice: Booleanflag on thedisconnect()method to control whether thedeleteDevicecall will be performed in the disconnect operation. For backwards compatibility, this flags defaults to theflushPersistencevalue.deleteDevicewhen the web socket terminates with anUnrecoverableError. This aligns it to the iOS SDK, and prevents unwanted invocations todeleteDevice. Now, the only place wheredeleteDeviceis called, is as part ofdisconnectorswitchUser.PushTokenUpdateHandler: It no longer relies onSharedPreferencestorage, but rather on the currentUser.devices. It no longer has debouncing logic too, because the only place from where it can be invoked isdisconnect/switchUser.🛠 Implementation details
deleteDeviceto thedisconnectmethod in addition toflushPersistencecontrolling the automatic invocation of thedeleteDeviceendpointdeleteDevicewhen the web socket terminates with anUnrecoverableErrorPushTokenUpdateHandler: It no longer relies onSharedPreferencestorage, but rather on the currentUser.devices🎨 UI Changes
NA
🧪 Testing
Test different scenarios related to registering/unregistering push devices, for example: Login with one user, receive push notifications. Then logout, login with different user and ensure that notifications are still received for the correct user. Play around with the
disconnect-deleteDeviceflag and ensure the SDK properly handles the push processes.