From 40a3541e8ef05d90f938acc12060144f32678bd7 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 13 Jul 2019 20:25:31 -0400 Subject: [PATCH] handle sleep event on ios manually --- src/App/App.xaml.cs | 18 +++++++++++++++--- src/iOS/AppDelegate.cs | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index 0404f19b8..35ea34849 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -126,6 +126,13 @@ namespace Bit.App ResumedAsync(); } } + else if(message.Command == "slept") + { + if(Device.RuntimePlatform == Device.iOS) + { + await SleptAsync(); + } + } else if(message.Command == "migrated") { await Task.Delay(1000); @@ -182,10 +189,9 @@ namespace Bit.App if(Device.RuntimePlatform == Device.Android) { await _storageService.SaveAsync(Constants.LastActiveKey, DateTime.UtcNow); + SetTabsPageFromAutofill(); + await SleptAsync(); } - SetTabsPageFromAutofill(); - await HandleLockingAsync(); - _messagingService.Send("stopEventTimer"); } protected override void OnResume() @@ -197,6 +203,12 @@ namespace Bit.App } } + private async Task SleptAsync() + { + await HandleLockingAsync(); + _messagingService.Send("stopEventTimer"); + } + private async void ResumedAsync() { _messagingService.Send("cancelLockTimer"); diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index fc08d9de6..d6689cb87 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -194,6 +194,7 @@ namespace Bit.iOS UIApplication.SharedApplication.KeyWindow.EndEditing(true); UIApplication.SharedApplication.SetStatusBarHidden(true, false); _storageService.SaveAsync(Constants.LastActiveKey, DateTime.UtcNow); + _messagingService.Send("slept"); base.DidEnterBackground(uiApplication); }