1

Error Domain=NEHotspotConfigurationErrorDomain Code=8 "internal error." UserInfo={NSLocalizedDescription=internal error.}

Here is my code:

NEHotspotConfigurationManager wifiManager = new NEHotspotConfigurationManager(); var wifiConfig = new NEHotspotConfiguration(ssid, password, false) { JoinOnce = true };

        wifiManager.RemoveConfiguration(ssid);
        wifiManager.ApplyConfigurationAsync(wifiConfig);
        wifiManager.ApplyConfiguration(wifiConfig, (error) =>
        {
            if (error != null)
            {
                Console.WriteLine(error.GetType());
                Console.WriteLine($"Error while connecting to WiFi network {ssid}: {error}");
            }
        });
        return true;
Kefi
  • 67
  • 2
  • 7
  • Hi , you should detail show what you have done in project, and to explain what function you want to achieve. By the way , from shared error log, here is a similar discussion for reference.https://stackoverflow.com/questions/47060649/nehotspotconfigurationerrordomain-code-8-internal-error – Junior Jiang Jul 12 '19 at 03:14
  • i want to connect to wifi using ssid and password in xamarin ios so i get this error. – Kefi Jul 12 '19 at 05:24
  • Okey, the first step is to set the “Enable Hotspot Configuration” entitlement in your Entitlements.plist file. Do you configure this ? – Junior Jiang Jul 12 '19 at 05:54
  • I share an answer .If be helpful , thanks for marking in advance. – Junior Jiang Jul 12 '19 at 06:29
  • Both the configuration is on but error is same :Foundation.NSErrorException: Error Domain=NEHotspotConfigurationErrorDomain Code=8 "internal error." UserInfo={NSLocalizedDescription=internal error.} – Kefi Jul 12 '19 at 06:51
  • Is the SSID within the scope of the device search? – Junior Jiang Jul 12 '19 at 06:57
  • Means hotspot is on with these ssid? – Kefi Jul 12 '19 at 07:03
  • Yeah , you should use physical device to connect the wifi, and be sure the wifi can be searched .Not using emulator to do this. – Junior Jiang Jul 12 '19 at 07:06
  • yeah, wifi is in within range and i am doing with real device. – Kefi Jul 12 '19 at 07:08
  • I have tried many codes but the error is same in all codes "Internal error code 8" and type of error is "Foundation.NSError". – Kefi Jul 12 '19 at 07:09
  • If In ios 12, also need to set this .https://i.stack.imgur.com/JESFO.png And AppID also need to add this . – Junior Jiang Jul 12 '19 at 07:20
  • Access wifi information setting is also enabled. – Kefi Jul 12 '19 at 07:47
  • Rebooting your device to have a try. Here is a previous in ios 11 occurs dicussion about this.https://stackoverflow.com/questions/47060649/nehotspotconfigurationerrordomain-code-8-internal-error?rq=1 This probelm is strange in IOS and seems like not easy to find the final reason. – Junior Jiang Jul 12 '19 at 07:54
  • Reboot device is not worked for me. – Kefi Jul 12 '19 at 08:00
  • Okey, Maybe this related to some configure of wifi . – Junior Jiang Jul 16 '19 at 08:01

1 Answers1

1

This is new with iOS11+ and enables your app to join a network using a known SSID. You can find the documentation over at Apple. To use it, you won’t have to request access to the super-secret hotspot APIs but there’s still a little configuration required.

The first step is to set the “Enable Hotspot Configuration” entitlement in your Entitlements.plist file:

enter image description here

This entitlement must also be configured in the developer portal when creating an app ID for your application:

enter image description here

With these settings in place you can start connecting to a network. The code is not complicated and requires the creation of an NEHotspotConfiguration object which specifies how the network will be used. Among the configurable parameters is for example a boolean that tells iOS if you are trying to access the network just temporarily or for longer. You should read the documentation to find out what settings work best for your case. Here’s a code example:

var config = new NEHotspotConfiguration(ssid, password, isWep: false);
config.JoinOnce = false;
var tcs = new TaskCompletionSource<NSError>();
NEHotspotConfigurationManager.SharedManager.ApplyConfiguration(config, err => tcs.SetResult(err));
var error = await tcs.Task;
if (error != null)
{
    var alert = new UIAlertController
    {
        Title = "Error",
        Message = error.Description
    };
    alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
    PresentViewController(alert, true, null);
    return;
}

Note:If in IOS 12, you also need to set this in Entitlement :

enter image description here

and AppID:

enter image description here

Junior Jiang
  • 12,430
  • 1
  • 10
  • 30