Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

NetworkReachability is obsolete on iOS 17.4+ and macOS 14.4+ (CA1422 warnings). Apple recommends NWPathMonitor from the Network framework as replacement.

Changes

  • Migrated from SystemConfiguration to Network framework

    • Replaced NetworkReachability with NWPathMonitor (available since iOS 12)
    • Removed System.Net and SystemConfiguration dependencies
    • Added shared NWPathMonitor instance with thread-safe initialization
  • Simplified Reachability implementation

    • RemoteHostStatus() and InternetConnectionStatus() now query NWPathMonitor.CurrentPath.Status
    • GetActiveConnectionType() uses NWPath.UsesInterfaceType() to detect Cellular/WiFi/Wired
    • Removed obsolete NetworkReachabilityFlags-based logic
  • Updated ReachabilityListener

    • Uses NWPathMonitor.SnapshotHandler for change notifications
    • Maintains 100ms delay constant for status stabilization
    • Preserves CTCellularData integration on iOS

Net -38 lines. No public API changes.

// Before: obsolete API
using (var reachability = new NetworkReachability(HostName))
{
    var reachable = reachability.TryGetFlags(out var flags);
    // ... complex flag checking logic
}

// After: modern API
var path = SharedMonitor.CurrentPath;
if (path.Status == NWPathStatus.Satisfied && path.UsesInterfaceType(NWInterfaceType.Cellular))
    return NetworkStatus.ReachableViaCarrierDataNetwork;
Original prompt

This section details on the original issue you should resolve

<issue_title>NetworkReachability is obsolete on iOS/maccatalyst 17.4+</issue_title>
<issue_description>### Description

Looking at the warnings from the code the NetworkReachability class is obsolete on newer versions of iOS/maccatalyst.

Image

Steps to Reproduce

Check https://github.com/dotnet/maui/blob/main/src/Essentials/src/Connectivity/Connectivity.ios.tvos.macos.reachability.cs and look at the warnings it produces

Link to public reproduction project repository

No response

Version with bug

10.0.0-rc.2

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

iOS/maccatalyst 17.4+

Did you find any workaround?

Warning suggests to use NSUrlSession or NWConnection APIs instead of NetworkReachability

Relevant log output

```</issue_description>

<agent_instructions>Make sure to not introduce any changes to public APIs</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@jfversluis</author><body>
Related: https://github.com/dotnet/maui/issues/2574</body></comment_new>
</comments>

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 3, 2025 11:16
Co-authored-by: jfversluis <939291+jfversluis@users.noreply.github.com>
Co-authored-by: jfversluis <939291+jfversluis@users.noreply.github.com>
Copilot AI changed the title [WIP] NetworkReachability is obsolete on iOS/maccatalyst 17.4+ Replace deprecated NetworkReachability with NWPathMonitor on iOS/macOS Nov 3, 2025
Copilot AI requested a review from jfversluis November 3, 2025 11:20
Copilot finished work on behalf of jfversluis November 3, 2025 11:20
@jfversluis
Copy link
Member

/azp run MAUI-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jfversluis
Copy link
Member

NWPathMonitor is supported from iOS 12 and up so just replacing it should not mess with our bottom support platform

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

Successfully merging this pull request may close these issues.

NetworkReachability is obsolete on iOS/maccatalyst 17.4+ Use NWPathMonitor on iOS for Essentials Connectivity

2 participants