mirror of
https://github.com/bitwarden/mobile
synced 2025-12-15 15:53:44 +00:00
register android push on my vault page too
This commit is contained in:
@@ -28,6 +28,10 @@ namespace Bit.Android.Services
|
|||||||
{
|
{
|
||||||
_pushNotificationListener.OnRegistered(registeredToken, Device.Android);
|
_pushNotificationListener.OnRegistered(registeredToken, Device.Android);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_settings.AddOrUpdateValue(Constants.PushLastRegistrationDate, DateTime.UtcNow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unregister()
|
public void Unregister()
|
||||||
|
|||||||
@@ -136,13 +136,17 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
_filterResultsCancellationTokenSource = FetchAndLoadVault();
|
_filterResultsCancellationTokenSource = FetchAndLoadVault();
|
||||||
|
|
||||||
if(_connectivity.IsConnected && Device.RuntimePlatform == Device.iOS)
|
// Push registration
|
||||||
|
if(_connectivity.IsConnected)
|
||||||
|
{
|
||||||
|
var lastPushRegistration = _settings.GetValueOrDefault(Constants.PushLastRegistrationDate,
|
||||||
|
DateTime.MinValue);
|
||||||
|
|
||||||
|
if(Device.RuntimePlatform == Device.iOS)
|
||||||
{
|
{
|
||||||
var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false);
|
var pushPromptShow = _settings.GetValueOrDefault(Constants.PushInitialPromptShown, false);
|
||||||
Action registerAction = () =>
|
Action registerAction = () =>
|
||||||
{
|
{
|
||||||
var lastPushRegistration =
|
|
||||||
_settings.GetValueOrDefault(Constants.PushLastRegistrationDate, DateTime.MinValue);
|
|
||||||
if(!pushPromptShow || DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1))
|
if(!pushPromptShow || DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1))
|
||||||
{
|
{
|
||||||
_pushNotification.Register();
|
_pushNotification.Register();
|
||||||
@@ -166,6 +170,12 @@ namespace Bit.App.Pages
|
|||||||
registerAction();
|
registerAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(Device.RuntimePlatform == Device.Android &&
|
||||||
|
DateTime.UtcNow - lastPushRegistration > TimeSpan.FromDays(1))
|
||||||
|
{
|
||||||
|
_pushNotification.Register();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisappearing()
|
protected override void OnDisappearing()
|
||||||
|
|||||||
Reference in New Issue
Block a user