Private Sub ConnectToWifi (SSID As String, Password As String)
Me.As(NativeObject).RunMethod("connectToWifi:::", Array(SSID, Password, False))
Wait For Connection_State (MaybeSuccess As Boolean)
Log("Connection_State: " & MaybeSuccess)
If MaybeSuccess = False Then
Log(LastException)
Else
'Maybe there is a connection now. Make a network call to test it.
End If
End Sub
#if OBJC
#import <NetworkExtension/NetworkExtension.h>
- (void)connectToWifi: (NSString*)ssid :(NSString*)password :(BOOL)joinOnce {
NEHotspotConfiguration *config =
[[NEHotspotConfiguration alloc] initWithSSID:ssid
passphrase:password
isWEP:NO];
config.joinOnce = joinOnce;
[[NEHotspotConfigurationManager sharedManager]
applyConfiguration:config
completionHandler:^(NSError * _Nullable error) {
if (error)
[B4I shared].lastError = error;
[self.bi raiseUIEvent:nil event:@"connection_state:" params:@[@(error == nil)]];
}];
}
#End If