如何在IOS上打开应用程序的设置?

时间:2017-08-03 11:21:00

标签: xamarin xamarin.forms

我正在处理Xamarin表单,我想知道如何从应用程序中打开设置页面?

2 个答案:

答案 0 :(得分:2)

public interface ISystemSettings
{
    void OpenApplicationDetailsSettings();
}

的iOS

[assembly: Dependency(typeof(SystemSettings))]
public class SystemSettings : ISystemSettings
{
    public void OpenApplicationDetailsSettings()
    {
        var ApplicationUrl = new NSUrl(UIApplication.OpenSettingsUrlString);
        UIApplication.SharedApplication.OpenUrl(ApplicationUrl);
    }
}

的Android

[assembly: Dependency(typeof(SystemSettings))]
public class SystemSettings : ISystemSettings
{
    public void OpenApplicationDetailsSettings()
    {
        Forms.Context.StartActivity(new Intent(
            Android.Provider.Settings.ActionApplicationDetailsSettings,
            Android.Net.Uri.Parse("package:" + Android.App.Application.Context.PackageName)));
    }
}

答案 1 :(得分:1)

Xamarin.Essentials 包支持此功能:

Xamarin.Essentials.AppInfo.ShowSettingsUI

有关详细信息,请参阅 this Microsoft page