Accessing a Captive portal configured Wifi from within an iOS app

472 Views Asked by At

I am working on this app that has successfully implemented connecting to a Wifi network using NEHotspotConfigurationManager, using the code below.

- (void)joinWifiWithCredentials:(NSString * const)SSID passphrase:(NSString * const)passphrase completion:(void (^)(CMNNetworkWifiState, NSError * _Nullable))completion {
    NEHotspotConfiguration *configuration = [[NEHotspotConfiguration alloc] initWithSSID:SSID passphrase:passphrase isWEP:NO];
    configuration.joinOnce = NO;

    [[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError * _Nullable error) {
        [self onFinishedJoiningWifi:SSID error:error completion:completion];
    }];
}

This works great on a Wifi that requires an SSID/Passphrase pair to get access.

But it does not work on networks that sit behind a captive portal. I was pointed in the direction of [NEHotspotHelper registerWithOptions] to be able to connect to the captive portal but do not have the HotspotHelper entitlement.

I would like to find out if this is the only way to go about doing this.

Essentially, I want to be able from within the app to trigger the same behaviour as if I was trying to connect to the Wifi from within the iOS settings or Safari. When I tap on a button "Connect to Wifi", it would ideally try to connect and trigger the captive.apple.com portal page where I can proceed to login and connect to the Wifi before coming back to the app.

Could I please get some advice/pointers on how best to proceed?

Many thanks in anticipation for all your replies.

0

There are 0 best solutions below