Open WiFi System Settings or Settings from App

I'm using Xamarin.Forms, however because the Android call to opening the WiFi settings page is platform dependent, I assume iOS is as well - if even possible due to the limited control that Apple provides us :)

In Android i'm usin this..

  Xamarin.Forms.Forms.Context.StartActivity(new Android.Content.Intent(Android.Provider.Settings.ActionWifiSettings));

How would I (if possible) open the WiFi settings page in iOS?

Thanks in advance!

Posts

  • adamkempadamkemp USInsider, Developer Group Leader mod

    I don't think that exists on iOS.

  • RobotAppDevRobotAppDev CAMember ✭✭

    Thank you

  • EZRobotEZRobot CAMember ✭✭

    Here is how you open the iOS settings..

      MonoTouch.UIKit.UIApplication.SharedApplication.OpenUrl(new MonoTouch.Foundation.NSUrl(MonoTouch.UIKit.UIApplication.OpenSettingsUrlString));
    
  • rmaciasrmacias USBeta, University ✭✭✭✭✭

    ^ Also note that only works on iOS 8 and above.

  • JohnMonteschioJohnMonteschio USUniversity ✭✭

    This:

    MonoTouch.UIKit.UIApplication.SharedApplication.OpenUrl(new MonoTouch.Foundation.NSUrl(MonoTouch.UIKit.UIApplication.OpenSettingsUrlString));

    Opens up my App's personal "Settings" in iOS, not the general Wifi System Settings (which is what the original email asked about). Any idea how to open the Wifi settings instead?

  • adamkempadamkemp USInsider, Developer Group Leader mod

    Unfortunately there isn't an API for that.

  • JKLTechnologiesJKLTechnologies USMember

    @RobotAppDev , The following code is working in iPhone.

    var url = new NSUrl("prefs:root=Settings");
    UIApplication.SharedApplication.OpenUrl(url);

    Hope, this will help for you.

  • sturentzlersturentzler USMember

    Agree with @JKLTechnologies, to make it more refined and open the WiFi settings for @RobotAppDev, not just the base settings, then in JKLTechnologies answer, modify the variable to:

    Change: var url = new NSUrl("prefs:root=Settings");
    To: var url = new NSUrl("prefs:root=WIFI");

    or from a Form, use:
    Device.OpenUri(new Uri(string.Format("prefs:root=WIFI")));

    more here, including link to full prefs things that can be done:
    http://forums.xamarin.com/discussion/comment/218386#Comment_218386

  • @sturentzler how to navigate to the settings page in C# Xmarin Forms PCL !! (especially for Andoid)

  • @AbdelazizNjah.2501

    I'm working with a PCL project. The following worked on the iOS side:

    Get to my own app's setting screen:
    Device.OpenUri(new Uri(string.Format("app-settings:")));

    General Settings:
    Change: var url = new NSUrl("prefs:root=Settings");

    Where you trying to head too?

    Android. Haven't gotten around to testing on that side. If it helps, to figure out the OpenUri correctly, I had built an XCode project and debugged "where is the string for opening an app's setting on iOS". There are many examples of that on the web.

    Guessing the same investigation can be done on the Android side. Build a project and see (if possible) what string passed would work. Haven't explored this yet on Android.

  • KlausKeithKlausKeith DKMember

    seems that only "app-settings:" is working on ios 10+

  • ChristophKahlChristophKahl DEMember ✭✭

    @KlausKeith said:
    seems that only "app-settings:" is working on ios 10+

    Do you think it should look like this:

    UIApplication.SharedApplication.OpenUrl(new NSUrl("app-settings:WIFI"));
    
  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    As of iOS 10, Apple no longer allows access to "prefs:" URLs.

  • DooksDooks ZAMember ✭✭✭
    edited February 2017

    iOS 10 Works:

    var WiFiURL = new NSUrl("prefs:root=WIFI");
    if(UIApplication.SharedApplication.CanOpenUrl(WiFiURL))
    {   //Pre iOS 10
        UIApplication.SharedApplication.OpenUrl(WiFiURL);
    }
    else
    {   //iOS 10
        UIApplication.SharedApplication.OpenUrl(new NSUrl("App-Prefs:root=WIFI"));
    }
    
Sign In or Register to comment.