Skip to content

Commit

Permalink
fix: remove pusher when logout
Browse files Browse the repository at this point in the history
  • Loading branch information
drminh2807 authored and hoangdat committed Oct 6, 2023
1 parent 01d5be1 commit 06df598
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pages/settings_dashboard/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ class SettingsController extends State<Settings> 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();
},
);
}

Expand Down
7 changes: 7 additions & 0 deletions lib/utils/background_push.dart
Original file line number Diff line number Diff line change
Expand Up @@ -570,4 +570,11 @@ class BackgroundPush {
apnChannel.invokeMethod('clearAll');
}
}

Future<void> removeCurrentPusher() async {
if (_pushToken == null) return;
await setupPusher(
oldTokens: {_pushToken},
);
}
}

0 comments on commit 06df598

Please sign in to comment.