-
Notifications
You must be signed in to change notification settings - Fork 304
DeleteDevice improvements
#5978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
SDK Size Comparison 📏
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
...t/src/test/java/io/getstream/chat/android/client/notifications/PushTokenUpdateHandlerTest.kt
Show resolved
Hide resolved
…roid/client/notifications/PushTokenUpdateHandlerTest.kt Co-authored-by: Copilot <[email protected]>
|


🎯 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.