From 48b5545a33f73755d729550605830a7527b3af4a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 6 Aug 2016 01:43:48 -0400 Subject: [PATCH] unregister push on logout. iOS has no concept of unregistering for push. --- src/App/App.cs | 13 +++++++++++-- src/App/Services/PushNotificationListener.cs | 2 -- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/App/App.cs b/src/App/App.cs index 789113f9d..177e84813 100644 --- a/src/App/App.cs +++ b/src/App/App.cs @@ -14,6 +14,7 @@ using Plugin.Connectivity.Abstractions; using System.Net; using Acr.UserDialogs; using PushNotification.Plugin.Abstractions; +using XLabs.Ioc; namespace Bit.App { @@ -181,12 +182,20 @@ namespace Bit.App } } - private void Logout(string logoutMessage) + private async void Logout(string logoutMessage) { + var deviceApiRepository = Resolver.Resolve(); + var appIdService = Resolver.Resolve(); + + _pushNotification.Unregister(); + _settings.Remove(Constants.PushLastRegistrationDate); + await deviceApiRepository.PutClearTokenAsync(appIdService.AppId); + _authService.LogOut(); + _googleAnalyticsService.TrackAppEvent("LoggedOut"); _googleAnalyticsService.RefreshUserId(); - _pushNotification.Unregister(); + Current.MainPage = new HomePage(); if(!string.IsNullOrWhiteSpace(logoutMessage)) { diff --git a/src/App/Services/PushNotificationListener.cs b/src/App/Services/PushNotificationListener.cs index 2fb967ba8..f34910341 100644 --- a/src/App/Services/PushNotificationListener.cs +++ b/src/App/Services/PushNotificationListener.cs @@ -98,8 +98,6 @@ namespace Bit.App.Services public async void OnUnregistered(DeviceType deviceType) { Debug.WriteLine("Push Notification - Device Unnregistered"); - _settings.Remove(Constants.PushLastRegistrationDate); - await _deviceApiRepository.PutClearTokenAsync(_appIdService.AppId); } public void OnError(string message, DeviceType deviceType)