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

779 views Asked by At

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!

2

There are 2 answers

0
Junior Jiang On BEST ANSWER

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.

0
Leon On

In case it helps someone one day I had an issue suddenly start where my device was unable to join a network which has previously been working fine.

To test an error condition I tried connecting to a secure network without adding the passphase to the NEHotspotConfiguration. This attempt to join failed but then subsequently after putting the passphase back in the device wouldn't even display the join request dialog and would just fail with an 'Unable to join' error.

I eventually tried another test phone and this worked just fine so it seemed to be an issue on the device itself. I tried resetting my device's network settings but this made no difference.

The fix was to go into the device's wifi setting, join the network manually, return to my app, attempt to join, disconnect from the network in the device settings, and then forget the network. After that it worked fine on every subsequent attempt.