0

I want to open wifi settings from inside my application,that is I don't want the settings page to put my application in background. I found a similar question : Opening the Settings app from another app

And tried this: for opening the wifi Settings page directly from my app:

NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"];
if ([[UIApplication sharedApplication] canOpenURL:url]) 
{
   [[UIApplication sharedApplication] openURL:url];
}

But even this code puts my app in background,hence the user needs to navigate back to the app. Kindly suggest if there is any possible option so that the app does not enter background.

Community
  • 1
  • 1

2 Answers2

0

Not possible. Also don't use prefs:root=WIFI as it is not documented and may stop working.

You are only allowed to open your own app's settings like this (iOS8 and above):

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
atulkhatri
  • 10,896
  • 3
  • 53
  • 89
  • Thanks for the answer,but I am looking to keep my app in foreground and select a wifi network from within the app.Any help would be appreciated. – DeveloperIOS Apr 22 '16 at 11:34
0

To open settings of our own application in iOS 8 and later, use following code.

- (void) openSettings
{
    if(&UIApplicationOpenSettingsURLString != nil)
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
    else
        NSLog(@"UIApplicationOpenSettingsURLString is not available in current iOS version");
}

Use this method on your button click event.

Anuj J
  • 186
  • 1
  • 11
  • hey thanks, I have already tried this suggestion,but didn't work for me, the app still goes in background while opening the settings. – DeveloperIOS Apr 25 '16 at 06:59