joinOnce在NEHotspotConfiguration中做了什么?

时间:2018-04-30 20:20:52

标签: ios iphone networking

我正在尝试使用以下代码在iOS中进行自动连接

if([Utils isEmpty:password]){
  configuration = [[NEHotspotConfiguration alloc] initWithSSID: wifiSSID];
}else{
  configuration = [[NEHotspotConfiguration alloc] initWithSSID: wifiSSID passphrase: password isWEP: NO];
}
configuration.joinOnce = YES;

/* Alert the OS that the user wants to connect to the WiFi */
[[NEHotspotConfigurationManager sharedManager] applyConfiguration: configuration completionHandler: ^ (NSError * _Nullable error) {
  if (nil == error) {
    DLog (@ "Is Connected!!");
    [WiFiManager sendCallback:CONNECTED callback:callback];
  } else {
    DLog (@ "Error is:%@", error);
    [WiFiManager sendCallback:UNKNOWN callback:callback];
}}];

这里我有joinOnce = YES。 当它设置为NO时,它实际上做了什么。 我发现在YES和NO之间没有任何真正的区别。

任何人都请解释。

1 个答案:

答案 0 :(得分:1)

joinOnce设置为true时,这意味着到该热点的连接将被断开,并且一旦设备进入睡眠状态或您的应用程序处于后台运行,该配置将被忘记。一段时间。