In 4.1, the following code Reachability().connection
would provide .wifi
or .cellular
.
Since 4.2, Reachability().connection
returns .none
right after the initialization.
After a while, if subscribing to the notifications, the value returns to the real reachability state.
Is this the designed behavior or is this a regression ?
Regards
@Drusy That looks like a regression. Thanks for reporting, I'll take a look
Cheers
Ash
In the sample iOS app in the repo, I tried printing connection
immediately after calling startNotifier()
- and it's showing the correct value (on device and simulator). Can you give me any more details?
try reachability?.startNotifier()
print(reachability!.connection)
// WiFi
@ashleymills my sample is as simple as this
let reachability = Reachability()
print(reachability!.connection)
// No Connection
I am not calling startNotifier()
because in that case I do not need the notifications. I may misuse your API, but the behavior is definitely changing between 4.1 and 4.2
OK, I see the problem. I'll push a fix later today.
@ashleymills I'm still experiencing this issue with version 4.2.1 when building my project with Xcode 10 final release and iOS 12 SDK.
The scenario is the following one:
I was also observing the following message in console output: "[NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}"
In order to fix the issue, I had to manually add CoreTelephony as a required dependency. Everything works as expected now, both on iOS 12 and older versions when building the app with the final version of Xcode 10 and using Swift 4.2. The message still appears on iOS simulator (and does not work, obviously) but it does not on a real device.
I'd suggest you either to update README.md file to add this information or update podspec file to add CoreTelephony as a subspec/dependency.
Most helpful comment
OK, I see the problem. I'll push a fix later today.