Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
891 views
in Technique[技术] by (71.8m points)

networking - iOS 13.2 message: nehelper sent invalid result code [1] for Wi-Fi information request

My app uses locationservices for tracking and geofencing in the background.

Now with iOS 13.2 I see every second the following message in the console:

Anchorwatch nehelper sent invalid result code [1] for Wi-Fi information request

My app does nothing with the WiFi system and when I disable WiFi on the device the message disappears.

While there seem to be no adverse effects by the message I learned the hard way that ignoring message might be a bad idea.

Can anyone hint me to why this message is coming and what I can do to supress it ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've managed to make it on iOS 13.3. Here goes how I make it. (EDIT Aug/2020: I've tested this on iOS 13.6 and worked same)

The official documentation of CNCopyCurrentNetworkInfo says that the function is providing real SSID/BSSID of current connection if the app

  • has an "Access WiFi Information Entitlement" (see here) and
  • is one of 1) Core Location , 2) using NEHotspotConfiguration to connect current Wi-Fi Network, and 3) VPN app.

I've already configured "Access WiFi Information Entitlement", therefore only meet the first requirement. It does work on iOS 13.1 but doesn't work on iOS 13.3. To meet the latter requirement, I decided to include the Core Location in my APP. I've checked the code in here but I gotta to add some constants below on my app's Info.plist to avoid error.

    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Application requires user’s location for better user experience.</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Application requires user’s location for better user experience.</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Application requires user’s location for better user experience.</string>

I also needed to call

manager.requestWhenInUseAuthorization()

before

manager.requestAlwaysAuthorization()

to popup the dialog when user launch the app for the first time.

User needed to allow the permission at the first launch. If it is allowed as "Always", the app can use CNCopyCurrentNetworkInfo without error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...