iosxamarinnehotspothelper

When using NEHotspotConfiguration() to joing a network. Always recieve "unable to join"


I am implementing an APP through Xamarin that will force the iPhone to connect to a specific SSID.

Here is my code

var config = new NEHotspotConfiguration(SSID, Password, isWep: false)
config.JoinOnce = true;
var tcs = new TaskCompletionSource<NSError>();
NEHotspotConfigurationManager.SharedManager.ApplyConfiguration(config, err => tcs.SetResult(err));

There are two test result

Assume the target SSID I want to connect called "SSID-A"

  1. I delete the record of "SSID-A" in the iOS system page. Then deploy this APP to the phone. I give the correct SSID/Password into the code above. The system popup a message "Unable to join". Failed to connect to this SSID.

  2. I go to iOS system page. Manually connect to "SSID-A". Check the connection is done. Then I connect to mobile phone to other SSID. And go back to the APP. This time. It works.

Why there is a different at here?

What can I do to look more into this problem to solve this?

Thanks!


Solution

  • From applyConfiguration:completionHandler: of apple document, we could see the dicsussion that:

    This method attempts to join the network only if it's found nearby. Also, because of the noticeable delay that the Hotspot 2.0 discovery mechanism may incur, the method doesn't attempt to join Hotspot 2.0 networks.

    Therefore, Join once seems can not mark sure it works.We could have a try with remove this line, or set false as follows:

    config.joinOnce = false;
    

    In addition, it seems a bug in iOS 13 from Apple. You could have a look at this discussion.