I have an app, developed in Xamarin Forms, which connects programmatically to a WIFI (with no internet access) exposed by an IoT device. This is the code I use to connect to the wifi network:
NEHotspotConfiguration configuration = new NEHotspotConfiguration("ssid");
Device.BeginInvokeOnMainThread(() =>
{
NEHotspotConfigurationManager.SharedManager.ApplyConfiguration(configuration, (NSError error) =>
{
if (error != null)
{
if (error.LocalizedDescription == "already associated.")
{
// connected!
CommunicateConnected();
}
else
{
// not connected
CommunicateNotConnected();
}
}
else
{
// connected!
CommunicateNotConnected();
}
});
});
Once the connection is successfully established the app performs some HTTP calls to the IP of the IoT device.
Sometimes it happens that the HTTP calls go over the cellular data connection instead of WIFI connection (because the joined network has no internet connection?) and they fail. (Simply, I see that the 4G icon is still visible instead of the one representing the WIFI connection).
The switch between mobile connection and WIFI connection, in these cases, happens after some minutes. Is there a way to force the HTTP calls to go over the just joined network?
-
—
Mfranc
-
—
meaton
Add a CommentHI, I have the problem that my IOT device don't work with iOS, in Android the connection works without problem but in iOS the same code you posted don't work.
I think it depends on some property missing in my Entitlements file.. Could be possible? Can you share your Entitlements?
Thanks
There is a sample project here that shows the usage of the
NEHotspotConfigurationAPI along with it's entitlements.