Skip to content

[iOS] Fixed the ConnectivityChanged event is not triggered when toggling Wifi (turning it on or off) #29606

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KarthikRajaKalaimani
Copy link
Contributor

@KarthikRajaKalaimani KarthikRajaKalaimani commented May 21, 2025

Issue Details:

The Connectivity.ConnectivityChanged event is not triggered for iOS platform when toggling wifi (turning it on or off)

Root Cause:

When toggling Wifi (turning it on or off). The native iOS triggers OnChange() method, Inside this method, a delay of 100 milliseconds was used to allow the system time to update the network state before checking connectivity. The OnChange() method when compare the current NetworkAccess with the previous NetworkAccess value after the 100 milli seond delay the current NetworkAccess value is not updated and still it remains previous value. So, here the 100 milli seconds delay is not enough to settle the internal network state transition.

Description of Change:

To address this, the delay was increased from 100 milliseconds to 400 milliseconds. This adjustment was tested on the iOS simulator and provides sufficient time for the system's network state to fully stabilize. As a result, the NetworkAccess value is updated correctly, and the ConnectivityChanged event is triggered reliably.

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac

Reference:

N/A

Issues Fixed:

Fixes #28961

Screenshots

Before After
Screen.Recording.2025-05-21.at.4.06.01.PM.mov
Screen.Recording.2025-05-20.at.5.33.58.PM.mov

Fixed Connectivity.ConnectivityChanged not fired on iOS
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label May 21, 2025
Copy link
Contributor

Hey there @@KarthikRajaKalaimani! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label May 21, 2025
@KarthikRajaKalaimani KarthikRajaKalaimani marked this pull request as ready for review May 21, 2025 10:58
@Copilot Copilot AI review requested due to automatic review settings May 21, 2025 10:58
@KarthikRajaKalaimani KarthikRajaKalaimani requested a review from a team as a code owner May 21, 2025 10:58
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR increases the delay in the OnChange method from 100 to 400 milliseconds to allow iOS network state transitions to settle before the ConnectivityChanged event is fired.

  • Increase delay in OnChange to resolve unreliable event triggering on iOS
  • Tested on multiple platforms (iOS, Android, Windows, Mac)
Comments suppressed due to low confidence (1)

src/Essentials/src/Connectivity/Connectivity.ios.tvos.macos.reachability.cs:197

  • Consider correcting the spelling of 'artifical' to 'artificial' in the comment for clarity.
// Add in artifical delay so the connection status has time to change

@jsuarezruiz jsuarezruiz added the area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info label May 22, 2025
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connectivity.ConnectivityChanged not fired on iOS
2 participants