Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

[Bug] Connectivity.ConnectionProfiles contains "Wifi" even if disconnected / turned off on iOS #1613

Closed
AndreasReitberger opened this issue Jan 2, 2021 · 16 comments · May be fixed by aleks-ivanov/maui#6
Labels
bug Something isn't working
Milestone

Comments

@AndreasReitberger
Copy link

Description

I'm using bool WifiOn = Connectivity.ConnectionProfiles.Contains(ConnectionProfile.WiFi); in the ConnectivityChanged event to detect if my mobile device is connected to the wifi or not.
However the bool WifiOn is true on my device, even if the Wifi is snoozed or completely turned off in the settings.
If I turn on the flight mode, it works and the wifi connection is detected as off.

I'm also setting the bool WifiOn = Connectivity.ConnectionProfiles.Contains(ConnectionProfile.WiFi); on startup of the app. But even with the wifi turned off this returns true at the app's startup.

Steps to Reproduce

  1. Install Xamarin.Forms 5.0.0.1829-pre6 & Xamarin.Essentials v1.6.0
  2. Check bool WifiOn = Connectivity.ConnectionProfiles.Contains(ConnectionProfile.WiFi); on a real device

Expected Behavior

The Wifi profile should not be included in the ConnectionProfiles if turned off or snoozed.

Actual Behavior

The Wifi profile is included in the ConnectionProfiles even if the wifi is turned off or snoozed.

Basic Information

  • Version with issue: Xamarin.Essentials v1.6.0 / Xamarin.Forms 5.0.0.1829-pre6
  • IDE: Visual Studio 19 Community
  • Platform Target Frameworks:
    • iOS: 14.2
  • Affected Devices: Only tested on Iphone 11
@AndreasReitberger AndreasReitberger added the bug Something isn't working label Jan 2, 2021
@demoh2019
Copy link

There is a solution?

@ghost
Copy link

ghost commented Jan 15, 2021

Hi,

I have had the same issue with current stable Xamarin Forms 5.0.0.1874.

Will be glad to here from you.

Kind regards

Thies

@jamesmontemagno
Copy link
Collaborator

What does NetworkAccess return?

@jamesmontemagno
Copy link
Collaborator

From what I can see NetworkReachability flags are returning IsWWAN. Will need to look deeper into it.

@ghost
Copy link

ghost commented Jan 15, 2021

What does NetworkAccess return?

NetworkAccess returns NetworkAccess.Internet

@ghost
Copy link

ghost commented Jan 15, 2021

Now I tried to go back to XF 4.8.0.1821 and had the same issue.

@ghost
Copy link

ghost commented Jan 15, 2021

From what I can see NetworkReachability flags are returning IsWWAN. Will need to look deeper into it.

And thanks for looking deeper into it... :-)

@ghost
Copy link

ghost commented Jan 15, 2021

btw: I tested your "old" https://github.com/jamesmontemagno/ConnectivityPlugin and that is working as expected...

@jamesmontemagno
Copy link
Collaborator

Interesting... I will look at the difference in code between the Connectivity Plugin and this one. Xamarin.Essentials and Xamarin.Forms are completely separate packages and are independent so that is why you see the same thing.

@jamesmontemagno
Copy link
Collaborator

@gemelo-hh were you using 3.2.0 of the plugin or the 4.0 beta stuff?

@jamesmontemagno
Copy link
Collaborator

I figured it out ;)

@ghost
Copy link

ghost commented Jan 15, 2021

@gemelo-hh were you using 3.2.0 of the plugin or the 4.0 beta stuff?

I'm using 3.2.0...

@mattleibow
Copy link
Contributor

mattleibow commented Jan 18, 2021

@jamesmontemagno I can't seem to repro this on my iPhone X with iOS 14.3...

On startup and in the event it has the correct values when wifi is off and off in the settings.

EDIT might be because I have no sim and thus no cellular connection to break it.

mattleibow added a commit that referenced this issue Jan 18, 2021
mattleibow added a commit that referenced this issue Jan 19, 2021
@mattleibow mattleibow added this to the 1.6.1 milestone Jan 19, 2021
@janvdp
Copy link

janvdp commented Jan 21, 2021

fwiw just tested the preview2 build and wifi test seems to be working now. Thanks for the fix!

@mattleibow
Copy link
Contributor

Thanks for the feedback!

@jamesmontemagno
Copy link
Collaborator

I did the same thing @mattleibow as my test phone has no sim and you have to have a sim to see the problem lol

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants