From c34376820aab1e2bf8d630ab508babcb08f11d51 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 21 Dec 2017 22:27:25 -0500 Subject: [PATCH] register android push on my vault page too --- .../AndroidPushNotificationService.cs | 4 ++ src/App/Pages/Vault/VaultListGroupingsPage.cs | 56 +++++++++++-------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/Android/Services/AndroidPushNotificationService.cs b/src/Android/Services/AndroidPushNotificationService.cs index c4981c1cc..b6c286cb8 100644 --- a/src/Android/Services/AndroidPushNotificationService.cs +++ b/src/Android/Services/AndroidPushNotificationService.cs @@ -28,6 +28,10 @@ namespace Bit.Android.Services { _pushNotificationListener.OnRegistered(registeredToken, Device.Android); } + else + { + _settings.AddOrUpdateValue(Constants.PushLastRegistrationDate, DateTime.UtcNow); + } } public void Unregister() diff --git a/src/App/Pages/Vault/VaultListGroupingsPage.cs b/src/App/Pages/Vault/VaultListGroupingsPage.cs index 8f068bca4..0caf3707e 100644 --- a/src/App/Pages/Vault/VaultListGroupingsPage.cs +++ b/src/App/Pages/Vault/VaultListGroupingsPage.cs @@ -136,34 +136,44 @@ namespace Bit.App.Pages _filterResultsCancellationTokenSource = FetchAndLoadVault(); - if(_connectivity.IsConnected && Device.RuntimePlatform == Device.iOS) + // Push registration + if(_connectivity.IsConnected) { - var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false); - Action registerAction = () => - { - var lastPushRegistration = - _settings.GetValueOrDefault(Constants.PushLastRegistrationDate, DateTime.MinValue); - if(!pushPromptShow || DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1)) - { - _pushNotification.Register(); - } - }; + var lastPushRegistration = _settings.GetValueOrDefault(Constants.PushLastRegistrationDate, + DateTime.MinValue); - if(!pushPromptShow) + if(Device.RuntimePlatform == Device.iOS) { - _settings.AddOrUpdateValue(Constants.PushInitialPromptShown, true); - _userDialogs.Alert(new AlertConfig + var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false); + Action registerAction = () => { - Message = AppResources.PushNotificationAlert, - Title = AppResources.EnableAutomaticSyncing, - OnAction = registerAction, - OkText = AppResources.OkGotIt - }); + if(!pushPromptShow || DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1)) + { + _pushNotification.Register(); + } + }; + + if(!pushPromptShow) + { + _settings.AddOrUpdateValue(Constants.PushInitialPromptShown, true); + _userDialogs.Alert(new AlertConfig + { + Message = AppResources.PushNotificationAlert, + Title = AppResources.EnableAutomaticSyncing, + OnAction = registerAction, + OkText = AppResources.OkGotIt + }); + } + else + { + // Check push registration once per day + registerAction(); + } } - else + else if(Device.RuntimePlatform == Device.Android && + DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1)) { - // Check push registration once per day - registerAction(); + _pushNotification.Register(); } } } @@ -230,7 +240,7 @@ namespace Bit.App.Pages if(collections.Any()) { - folderGroupings.Add(new GroupingOrCipher(new Grouping(AppResources.FolderNone, + folderGroupings.Add(new GroupingOrCipher(new Grouping(AppResources.FolderNone, noFolderCipherGroupings.Count))); }