Unverified Commit 5a678af5 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito Committed by GitHub

Merge pull request #1299 from RocketChat/fix/notification-not-showing-when-changing-users

[FIX] Notification not showing after logging out and log in with different user on the same server
parents ff46d5b3 e0d8f3a4
...@@ -177,6 +177,7 @@ class MainPresenter @Inject constructor( ...@@ -177,6 +177,7 @@ class MainPresenter @Inject constructor(
if (pushToken != null) { if (pushToken != null) {
try { try {
retryIO("unregisterPushToken") { client.unregisterPushToken(pushToken) } retryIO("unregisterPushToken") { client.unregisterPushToken(pushToken) }
view.invalidateToken(pushToken)
} catch (ex: Exception) { } catch (ex: Exception) {
Timber.d(ex, "Error unregistering push token") Timber.d(ex, "Error unregistering push token")
} }
......
...@@ -24,4 +24,5 @@ interface MainView : MessageView, VersionCheckView { ...@@ -24,4 +24,5 @@ interface MainView : MessageView, VersionCheckView {
fun setupNavHeader(viewModel: NavHeaderViewModel, accounts: List<Account>) fun setupNavHeader(viewModel: NavHeaderViewModel, accounts: List<Account>)
fun closeServerSelection() fun closeServerSelection()
fun invalidateToken(token: String)
} }
\ No newline at end of file
...@@ -134,6 +134,10 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -134,6 +134,10 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
.show() .show()
} }
override fun invalidateToken(token: String) {
InstanceID.getInstance(this).deleteToken(token, GoogleCloudMessaging.INSTANCE_ID_SCOPE)
}
private fun setupAccountsList(header: View, accounts: List<Account>) { private fun setupAccountsList(header: View, accounts: List<Account>) {
accounts_list.layoutManager = LinearLayoutManager(this) accounts_list.layoutManager = LinearLayoutManager(this)
accounts_list.adapter = AccountsAdapter(accounts, object : Selector { accounts_list.adapter = AccountsAdapter(accounts, object : Selector {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment