Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reachability returns incorrect reachability status #375

Open
HarshitDaftary opened this issue Jan 20, 2021 · 9 comments
Open

Reachability returns incorrect reachability status #375

HarshitDaftary opened this issue Jan 20, 2021 · 9 comments

Comments

@HarshitDaftary
Copy link

HarshitDaftary commented Jan 20, 2021

Xcode : 12.1
iOS : 14.1
Reachability : 5.1.0

I implemented below code in my viewcontrollers.

In view did load

do {
            try self.reachability = Reachability()
        } catch {
            
        }

in another method

 if self.reachability.allowsCellularConnection {
                print("internet is available")

            } else {
                print("Internet not available")
            }

This code works properly on first view controller. For second view controller, self.reachability.allowsCellularConnection always returns true.

@kostiag
Copy link

kostiag commented Feb 10, 2021

Are you doing it on the simulator? Seems to be an issue in the simulator, but works correctly on the actual device.

@HarshitDaftary
Copy link
Author

Yes I tried in simulator. Ok I will try on device and update you if I face the same issue.

@JamesL007
Copy link

Do you still have the same issue on the simulator? How did you solve it to be able to test on the Simulator? Thanks

@kostiag
Copy link

kostiag commented Aug 24, 2022 via email

@JamesL007
Copy link

JamesL007 commented Aug 24, 2022

@kostiag Thanks for the quick reply. I don't believe we can either in simulator as it uses the mac's connection. But I wanted to make sure. I could do a quick workaround (in simulator mode) by making a request to let's say "www.google.com" or "www.apple.com"...it doesn't matter and see if I get a 200 code back? This will tell me if I'm on connected or not (only on Simulator) since the reachability doesn't seem to be working properly in simulator.

@kostiag
Copy link

kostiag commented Aug 24, 2022 via email

@JamesL007
Copy link

@kostiag When I turn on/off wifi on my machine while running from the simulator. Currently, the Reachability framework detects the connection change but returns the wrong status...makes testing on the simulator difficult...especially if you don't have a device handy to run your tests. On a device, the same code works as expected and well. It's only on the simulator the status is a big wonky

@JamesL007
Copy link

@kostiag I'll give my idea a try and see if it's solves my issue. Thanks for the inputs. :)

@GergoBurai
Copy link

+1, wrong status is returned on change, when testing on simulator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants