简体   繁体   中英

Open wifi settings on IOS Device from within my application , with my application remaining in foreground

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.

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];

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM