Add network connectivity ios android#2
Open
J4t-P wants to merge 5 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plugin detects the connection type and verifies whether the device actually has internet access in real time.
Why this plugin?
The built-in Capacitor Network plugin only tells you if the device is connected to a network interface. But being connected to WiFi doesn't mean you have internet — think captive portals, dead hotspots, or firewalled networks. This plugin distinguishes between those cases.
How it works
The plugin returns an InternetStatus object with four fields:
iOS
Uses NWPathMonitor to detect network changes, then validates actual internet access by firing concurrent HTTP HEAD requests to 4 well-known servers (Google, Apple, Cloudflare, Microsoft). If any responds successfully, internetReachable is true. This catches captive portals and dead WiFi networks that NWPathMonitor alone would report as "connected".
Android
Uses ConnectivityManager with NetworkCallback to monitor network changes. Internet reachability is determined via NET_CAPABILITY_VALIDATED, which is Android's built-in mechanism for verifying actual internet access at the OS level.
Web
Falls back to navigator.onLine with online/offline event listeners.
Compatibility
Capacitor >= 7.0.0
iOS 14+
Android API 23+ (minSdk), targeting API 35