#ProvisionFile: Push.mobileprovision
#Entitlement: <key>com.apple.developer.networking.HotspotConfiguration</key><true/>
Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
NavControl.ShowPage(Page1)
ConnectWiFi("xxx", "22323223")
End Sub
Sub ConnectWiFi(SSID As String, Passphrase As String)
If App.OSVersion < 11 Then Return
Dim configuration As NativeObject
configuration = configuration.Initialize("NEHotspotConfiguration").RunMethod("alloc", Null).RunMethod("initWithSSID:passphrase:isWEP:", Array(SSID, Passphrase, False))
Dim no As NativeObject = Me
no.RunMethod("ApplyConfiguration:", Array(configuration))
End Sub
#if OBJC
@import NetworkExtension;
- (void)ApplyConfiguration:(NEHotspotConfiguration*) configuration {
[[NEHotspotConfigurationManager sharedManager]applyConfiguration:configuration completionHandler:^(NSError* error) {
if (error == nil) {
NSLog(@"Success");
}
else
NSLog(@"Error: %@", error);
}
];
}
#End If