unregister push on logout. iOS has no concept of unregistering for push.

This commit is contained in:
Kyle Spearrin 2016-08-06 01:43:48 -04:00
parent b1da05474a
commit 48b5545a33
2 changed files with 11 additions and 4 deletions

View file

@ -14,6 +14,7 @@ using Plugin.Connectivity.Abstractions;
using System.Net; using System.Net;
using Acr.UserDialogs; using Acr.UserDialogs;
using PushNotification.Plugin.Abstractions; using PushNotification.Plugin.Abstractions;
using XLabs.Ioc;
namespace Bit.App 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<IDeviceApiRepository>();
var appIdService = Resolver.Resolve<IAppIdService>();
_pushNotification.Unregister();
_settings.Remove(Constants.PushLastRegistrationDate);
await deviceApiRepository.PutClearTokenAsync(appIdService.AppId);
_authService.LogOut(); _authService.LogOut();
_googleAnalyticsService.TrackAppEvent("LoggedOut"); _googleAnalyticsService.TrackAppEvent("LoggedOut");
_googleAnalyticsService.RefreshUserId(); _googleAnalyticsService.RefreshUserId();
_pushNotification.Unregister();
Current.MainPage = new HomePage(); Current.MainPage = new HomePage();
if(!string.IsNullOrWhiteSpace(logoutMessage)) if(!string.IsNullOrWhiteSpace(logoutMessage))
{ {

View file

@ -98,8 +98,6 @@ namespace Bit.App.Services
public async void OnUnregistered(DeviceType deviceType) public async void OnUnregistered(DeviceType deviceType)
{ {
Debug.WriteLine("Push Notification - Device Unnregistered"); Debug.WriteLine("Push Notification - Device Unnregistered");
_settings.Remove(Constants.PushLastRegistrationDate);
await _deviceApiRepository.PutClearTokenAsync(_appIdService.AppId);
} }
public void OnError(string message, DeviceType deviceType) public void OnError(string message, DeviceType deviceType)