简体   繁体   English

iOS 13:通过 NEHotspotConfiguration 连接的网络在几秒钟后断开连接

[英]iOS 13: Network connected via NEHotspotConfiguration disconnects after a few seconds

I use NEHotspotConfigurationManager in a native module developed for a react native app, to connect to a device that exposes an open wifi hotspot.我在为本机应用程序开发的本机模块中使用 NEHotspotConfigurationManager 来连接到暴露开放 wifi 热点的设备。 In older iOS versions (iOS 12 and lower) it worked fine, but in iOS 13 the device is being disconnected after a few seconds of being connected.在较旧的 iOS 版本(iOS 12 及更低版本)中,它运行良好,但在 iOS 13 中,设备在连接几秒钟后断开连接。

this is my native method, I use joinOnce as it makes sense according to the docs :这是我的本地方法,我使用joinOnce因为根据文档,它是有意义的:

NEHotspotConfiguration* configuration = [[NEHotspotConfiguration alloc] initWithSSID:ssid];
configuration.joinOnce = true;

[[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError * _Nullable error) {
  if (error != nil) {
    reject(ERR_HOTSPOT_CONFIGURATION, ERR_HOTSPOT_CONFIGURATION, error);
  } else {
    resolve(nil);
  }
}];

What is the proper way of keeping the connection up for longer periods of time?保持连接更长时间的正确方法是什么? Is this an intended/documented change in iOS 13?这是 iOS 13 中的预期/记录更改吗? Is it a bug?这是一个错误吗?

Also, in Android if the hotspot does not have internet connectivity the system automatically switches to mobile network.此外,在 Android 中,如果热点没有互联网连接,系统会自动切换到移动网络。 Is this some similar policy in iOS?这是 iOS 中的一些类似政策吗? The device I am connecting to does not provide internet access我连接的设备不提供互联网访问

This is a bug in newest iOS/iPadOS, similar to my report: iPadOS: Network connected via NEHotspotConfiguration disconnects after a while这是最新的 iOS/iPadOS 中的一个错误,类似于我的报告: iPadOS:通过 NEHotspotConfiguration 连接的网络在一段时间后断开

I have reported it to Apple, but it has not yet been solved, and likely will not be solved by iOS 13 release (September 19th).我已向Apple报告,但尚未解决,并且可能不会在iOS 13版本(9月19日)发布时解决。

Workaround is to use joinOnce = false , but in this case, a user may be prompted to switch to cellular if internet connection is not detected.解决方法是使用joinOnce = false ,但在这种情况下,如果未检测到互联网连接,可能会提示用户切换到蜂窝网络。 The user will not be switched automatically in the background, but switching to cellular is exposed as a preferred option.用户不会在后台自动切换,但切换到蜂窝网络是首选选项。

Thank you very much. 非常感谢你。 This has also fixed it for me. 这也为我解决了。 As part of my troubleshooting, I also had a problem attempting to retrieve the SSID of the NEHotspotConfiguration using CNCopySupportedInterfaces. 在我的疑难解答中,尝试使用CNCopySupportedInterfaces检索NEHotspotConfiguration的SSID时遇到了问题。 It was always returning nil. 它总是返回零。 The only way I solved this was to restart the IOS device. 我解决此问题的唯一方法是重新启动IOS设备。 Note:- I don't have enough points to comment... [I know this is not an answer to the question;-)] 注意:-我没有足够的意见要评论... [我知道这不是问题的答案;-)]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM