Search code examples
iosobjective-cuialertviewreachability

Reachability Go To "Wi-Fi Settings" button not working


So i have Reachability implemented because my app uses web services, my app successfully detects if i have a internet connection or not and warns the user about it... the warning message contains 2 buttons, OK or GO TO WIFI SETTINGS

If i press OK, it dismisses the warning and nothing happens, as expected... but if i click to go wifi settings it also dismisses the warning and thats it.

Below you can see my 2 methods..

- (BOOL)checkForWIFIConnection {
    Reachability* wifiReach = [Reachability reachabilityForLocalWiFi];
    NetworkStatus netStatus = [wifiReach currentReachabilityStatus];
    if (netStatus!=ReachableViaWiFi)
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Sem conexão à internet!", @"AlertView")
                                                            message:NSLocalizedString(@"Não está conectado à internet. Tente novamente após se connectar.", @"AlertView")
                                                           delegate:self
                                                  cancelButtonTitle:NSLocalizedString(@"Cancelar", @"AlertView")
                                                  otherButtonTitles:NSLocalizedString(@"Definições WiFi", @"AlertView"), nil];
        [alertView show];
        return NO;
    }
    else {
        return YES;
    }
}

I guess there is something wrong with the code below...

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1)
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
    }
}

Any help? Thanks.


Solution

  • ....."prefs:root=WIFI"..
    

    It doesn't work from iOS 5.1.