質問

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.

役に立ちましたか?

解決 2

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

It doesn't work from iOS 5.1.

他のヒント

This URL schema prefs:root=WIFI was deprecated from iOS 5.1 and onwards. Currently there is no official replacement. You will probably have to give the user some instructions in your UIAlert on WiFi and your app.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top