Skip to content

feat(network): expose connection condition flags#2555

Open
birkskyum wants to merge 2 commits into
ionic-team:mainfrom
birkskyum:network-connection-conditions
Open

feat(network): expose connection condition flags#2555
birkskyum wants to merge 2 commits into
ionic-team:mainfrom
birkskyum:network-connection-conditions

Conversation

@birkskyum

Copy link
Copy Markdown

Description

Adds optional constrained and expensive fields to Network.getStatus() and networkStatusChange.

This keeps connectionType unchanged and exposes connection condition signals separately:

  • iOS uses NWPath.isConstrained and NWPath.isExpensive
  • Android uses metered network capabilities, Data Saver restrictions, and Android 15 bandwidth-constrained capabilities
  • Web uses navigator.connection.saveData for constrained

Offline status reports both fields as false.

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

Some apps need to adjust network behavior based on more than connection type. For example, a connection can still be Wi-Fi or cellular while also being metered, expensive, or under a platform data-saving mode.

This adds platform-backed condition flags without changing the existing connectionType API.

Tests or Reproductions

Tested with:

  • CAP_PLUGIN_PUBLISH=true CAPACITOR_VERSION=8.4.1 npm run verify
  • npm run lint
  • xcodebuild test -scheme CapacitorNetwork -destination 'platform=iOS Simulator,name=iPhone 17,OS=26.5'
  • xcodebuild build -scheme CapacitorNetwork -destination 'id=00008150-001155E01191401C'

Also verified the iOS target builds for a physical iPhone 17 Pro on iOS 26.5.1.

Screenshots / Media

N/A

Platforms Affected

  • Android
  • iOS
  • Web

Notes / Comments

No related issue that I could find.

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.

1 participant