• Open App-Settings in Xamarin Forms

    Sometimes it’s necessary for the user to grant some access rights, e.g. for camera or photo library. Typically the user is asked on first access, but if he denies he will not be prompted anymore. So you should forward the user to the settings page instead of just saying “Hey, go to your settings page and do the changes”.

    For iOS it’s quite easy to do in Xamarin Forms ( Device.OpenUri(new Uri(“app-settings:”));), but there is no such command for Android so you have to use Dependency Service.

    On StackOverflow, EvZ has posted the code how to do this. So here are the files you have to create in your Xamarin Forms app, including all the usings etc.

    .net standard application

    In your .net standard application, add a new interface called “IAppSettingsHelper.cs” with this content (modify Namespace according to your settings):

    Android App

    Create a new class “AppSettingsInterface.cs” in your Android App. Modify “package_name” according to your package, e.g. “com.example.myapp”.

    iOS App

    Finally also create a new class “AppSettingsInterface.cs” in your iOS App. Note that it’s not needed to add your application id here as iOS will automatically open the correct settings.

    From Xamarin Forms, you could now open app settings on Android or iOS just with this command:

     

     

     

     

     

     

Leave a comment

If you want to share your opinion, leave a comment.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">