This repository has been archived by the owner on May 1, 2024. It is now read-only.
OnSleep / OnResumed called by System Dialogs on iOS [Bug] #13077
Labels
s/needs-info ❓
A question has been asked that requires an answer before work can continue on this issue.
s/unverified
New report that has yet to be verified
t/bug 🐛
Description
When certain iOS system dialogs appear the
OnSleep
method in theApp
is called. Events I have noticed include:This is making it difficult to implement a reliable background service using Xamarin Forms events whilst the app is running in the foreground.
This is the same issue as #8413 which had no reproduction so I have provided one here, although as I mention the scope of this issue is wider than just permission requests. If your app is redirected to a microsoft login for example, the
OnSleep
method will be called.I came across this issue when handling the sleep / wake events for the SignalR service in my companys app. The app will connect to our SignalR client when it loads. I decided to disconnect it when the
OnSleep
method is called because the app is now "offline", I noticed that when logging for the first time the SignalR service was being disconnected leading me to this issue. I would not consider the app to get asleep at this time, the user is currently going through login!Steps to Reproduce
OnSleep
/OnResume
methods inApp.xaml.cs
Expected Behavior
OnSleep
is not called because the app is in the foregroundActual Behavior
OnSleep
is called, andOnResume
is called when the system dialog has completed.Basic Information
Environment
Reproduction Link
I have created a reproduction repo that requests photos permission. You will need to delete the app and reinstall to get the permission dialog to show, this was easier than putting something in like Microsoft MSAL which will trigger this issue every-time.
OnSleepRepro.zip
Workaround
The workaround is ignoring the xamarin forms events and implementing your own service that is aware of the native events.
The text was updated successfully, but these errors were encountered: