From 06df5982d6f19dfaee730fbd56e0d27c5341ac37 Mon Sep 17 00:00:00 2001 From: MinhDV Date: Thu, 5 Oct 2023 15:48:26 +0700 Subject: [PATCH] fix: remove pusher when logout --- lib/pages/settings_dashboard/settings/settings.dart | 7 ++++++- lib/utils/background_push.dart | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/pages/settings_dashboard/settings/settings.dart b/lib/pages/settings_dashboard/settings/settings.dart index 17ae8a0342..05759b6ba6 100644 --- a/lib/pages/settings_dashboard/settings/settings.dart +++ b/lib/pages/settings_dashboard/settings/settings.dart @@ -79,7 +79,12 @@ class SettingsController extends State with ConnectPageMixin { final matrix = Matrix.of(context); await showFutureLoadingDialog( context: context, - future: () => matrix.client.logout(), + future: () async { + if (matrix.backgroundPush != null) { + await matrix.backgroundPush!.removeCurrentPusher(); + } + return matrix.client.logout(); + }, ); } diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index 1ab50d99ba..508009fad5 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -570,4 +570,11 @@ class BackgroundPush { apnChannel.invokeMethod('clearAll'); } } + + Future removeCurrentPusher() async { + if (_pushToken == null) return; + await setupPusher( + oldTokens: {_pushToken}, + ); + } }