From 3dff2cc6d0d2c0c362429af58bc00e1889554515 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 25 Jul 2016 23:34:19 -0400 Subject: [PATCH] show push prompt before push registration --- src/App/Pages/Vault/VaultListSitesPage.cs | 29 ++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/App/Pages/Vault/VaultListSitesPage.cs b/src/App/Pages/Vault/VaultListSitesPage.cs index 5241b2a97..3da7869dc 100644 --- a/src/App/Pages/Vault/VaultListSitesPage.cs +++ b/src/App/Pages/Vault/VaultListSitesPage.cs @@ -155,20 +155,33 @@ namespace Bit.App.Pages if(_connectivity.IsConnected && Device.OS == TargetPlatform.iOS && !_favorites) { var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown); + Action registerAction = () => + { + var lastPushRegistration = _settings.GetValueOrDefault(Constants.PushLastRegistrationDate); + if(!pushPromptShow || !lastPushRegistration.HasValue || (DateTime.UtcNow - lastPushRegistration) > TimeSpan.FromDays(1)) + { + _pushNotification.Register(); + } + }; + if(!pushPromptShow) { _settings.AddOrUpdateValue(Constants.PushInitialPromptShown, true); - _userDialogs.Alert("bitwarden keeps your vault automatically synced by using push notifications." + _userDialogs.Alert(new AlertConfig + { + Message = "bitwarden keeps your vault automatically synced by using push notifications." + " For the best possible experience, please select \"Ok\" on the following prompt when asked to enable push notifications.", - "Enable Automatic Syncing", "Ok, got it!"); + Title = "Enable Automatic Syncing", + OnOk = registerAction, + OkText = "Ok, got it!" + }); + } + else + { + // Check push registration once per day + registerAction(); } - // Check push registration once per day - var lastPushRegistration = _settings.GetValueOrDefault(Constants.PushLastRegistrationDate); - if(!pushPromptShow || !lastPushRegistration.HasValue || (DateTime.UtcNow - lastPushRegistration) > TimeSpan.FromDays(1)) - { - _pushNotification.Register(); - } } }