Reachability.swift: New version of Reachability (or iOS 12) causing issues with wi-fi connection status
What version of Reachability.Swift are you using? ReachabilitySwift (4.3.0) How is it installed? Manually, CocoaPods, Carthage? Cocoapods Does it occur on device or simulator? Which device? Device (iPhone 8 - users have reported it happening on others too)
What OS version are you running on? iOS 12.0.1
How often does it happen? Sporadically, but quite often when transitioning connections (i.e. from cellular only to cellular+wifi)
Are there steps you can take to reproduce it?
Transition from cellular only to cellular + wifi.
Issue: I set up Reachability in my app delegate, and it is global throughout the whole app. have some logic that checks whether or not we should do something based on whether the user is connected to wifi:
if reachabilityManager.connection == .wifi {
return true
}
if reachabilityManager.connection == .cellular {
// do something else
}
The connection does not indicate status == .wifi when connecting to a new wi-fi network. This is a new issue, so it may have been introduced after iOS 11.4.1 or upon the new version of reachability-swift. Please let me know how I might be able to contribute to help solve this issue asap.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 2
- Comments: 25 (2 by maintainers)
I have linked the CoreTelephony.framework but it still does not work
I use ReachabilitySwift version 4.3.0
My code is very simple. This is a if-else statement that is executed with a button event
if(reachability.connection == .none){ print(“Error”) }else{ print(“Connection OK”) }
Disconnected and connect my wifi or data connection in the mobile app and the library is not able to recognize that I have returned to have connection
Well for iOS12 Apple has added Capabilities requirement and needs to be configured in developer.apple.com and edit your AppId for WiFi access:
Also turn on Access Wifi Information in Capabilities for your application in XCode. Some guides to the said are represented picturesquely below:
Let me know if this helps.
Update - Tested with actual device (Ethernet and wifi) and everything works as expected. I suspect there was issues with simulator because I use VPN and Charles proxy (It installs SSL certificate in simulator and monitors all requests made) in my MacBook.
I am also facing the same issue in tvOS simulator.
What version of Reachability.Swift are you using? 4.3.1 How is it installed? Manually, CocoaPods, Carthage? Carthage Does it occur on device or simulator? Which device? Simulator, Apple TV simulator What OS version are you running on? tvOS 12.2 How often does it happen? Always Are there steps you can take to reproduce it? Please download and run https://github.com/abin0992/RechabilityBug
It detects when wifi connection is lost but doesn’t detect when internet is back. My implementation is https://github.com/abin0992/RechabilityBug/blob/master/Rechability Bug/ViewController.swift
I want to notify user when the internet connection is lost and reconnected. Is there something wrong with my implementation?
@mohsinka ,
I have updated all the configuration on Developer apple account and enabled capability on Xcode as well. But the problem is still same.
On the physical devices its working fine. Problem is persistence on the simulator only.
I’m using Alamofire to solve this problem
I’ve created a new class with this code:
import Foundation import Alamofire class NetworkState { class func isConnected() ->Bool { return NetworkReachabilityManager()!.isReachable } }
And its use is:
if NetworkState.isConnected() { print("Exists connection) }else{ print(“Not connection”) }
@corteggo Thank you, linking the CoreTelephony.framework fixed the problem.
Some more details - when I restart the app, the connection is properly set to “wi-fi.” The bug occurs when you launch the app, (instantiate reachability manager) and then later on the connection changes to a wi-fi connection. I can probably get around this by re-instantiating reachability every time I want to use it, but that’s not ideal.
I had the same issue with Xcode 10.3 and iOS 12.4 Simulator.
Came across this conversation, tried it on a physical device running iOS 12.4 and it’s working fine.
@andrewkouri linking CoreTelephony.framework to the project fixed the issue for me (only for real devices, not in the simulator unfortunately). Related to https://github.com/ashleymills/Reachability.swift/issues/307#issuecomment-425377792