mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
show push prompt before push registration
This commit is contained in:
parent
193ef8c995
commit
3dff2cc6d0
1 changed files with 21 additions and 8 deletions
|
@ -155,20 +155,33 @@ namespace Bit.App.Pages
|
|||
if(_connectivity.IsConnected && Device.OS == TargetPlatform.iOS && !_favorites)
|
||||
{
|
||||
var pushPromptShow = _settings.GetValueOrDefault<bool>(Constants.PushInitialPromptShown);
|
||||
if(!pushPromptShow)
|
||||
Action registerAction = () =>
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.PushInitialPromptShown, true);
|
||||
_userDialogs.Alert("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!");
|
||||
}
|
||||
|
||||
// Check push registration once per day
|
||||
var lastPushRegistration = _settings.GetValueOrDefault<DateTime?>(Constants.PushLastRegistrationDate);
|
||||
if(!pushPromptShow || !lastPushRegistration.HasValue || (DateTime.UtcNow - lastPushRegistration) > TimeSpan.FromDays(1))
|
||||
{
|
||||
_pushNotification.Register();
|
||||
}
|
||||
};
|
||||
|
||||
if(!pushPromptShow)
|
||||
{
|
||||
_settings.AddOrUpdateValue(Constants.PushInitialPromptShown, true);
|
||||
_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.",
|
||||
Title = "Enable Automatic Syncing",
|
||||
OnOk = registerAction,
|
||||
OkText = "Ok, got it!"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check push registration once per day
|
||||
registerAction();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue