Essentials: [Bug] ShowSettingsUI returns before settings UI is opened

Created on 15 May 2020  路  3Comments  路  Source: xamarin/Essentials

ShowSettingsUI is a synchronous method that opens the device's settings UI. A common use case for opening the app's settings is to ask the user to enable some permissions for the app.

However, ShowSettingsUI instantly returns while the device settings open at a later time, making it impossible to do (pseudo) code like:

if (PromptToOpenSettings() == "YES")
{
ShowSettingsUI();
AskForPermissions(); <--- this will execute before the settings UI is shown
}

Could AskForPermissions either wait until the settings dialog has been opened, or add an async variant? I don't know what good the current one will do as you can't react to any settings changes.

Thanks.

bug not-on-roadmap

All 3 comments

I was able to work around this by adding a service that listens to all resume and pause events (also from native Android side as it works differently than Application's life cycle events on iOS), and another service that has an asynchronous method that calls PromptToOpenSettings, while waiting for the next resume event from the main activity. It actually works flawlessly so if someone else is in a pinch go for it, but it's a ton of unnecessary code so I'd still appreciate native support for it.

Thanks!

Yeah, that seems like better route of doing it. I mean we just send the event, it isn't meant to wait until it returns. This is implemented as designed today as each platform doesn't offer a way of waiting for it to come back to your app.

Yeah, that seems like better route of doing it. I mean we just send the event, it isn't meant to wait until it returns. This is implemented as designed today as each platform doesn't offer a way of waiting for it to come back to your app.

Alright! Makes sense if not all platforms support waiting for it. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tsjdev-apps picture tsjdev-apps  路  4Comments

Agredo picture Agredo  路  3Comments

TedMobile picture TedMobile  路  3Comments

Howell1618 picture Howell1618  路  4Comments

charlespetzold picture charlespetzold  路  4Comments