Commit e0d8f3a4 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Invalidate token when logging out just after unregistering the push token on server

parent ff46d5b3
...@@ -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