feat: implement iOS connectivity detection#12
Open
polw1 wants to merge 2 commits into
Open
Conversation
Add an iOS platform implementation behind the connectivity plugin. The Swift bridge runs an NWPathMonitor and resolves connected/metered/ constrained/connectionType from the cached NWPath, exposing it to Rust through run_mobile_plugin. The Rust side gains an IosConnectivity handle wrapper and a generic Connectivity<R> managed state.
velocitysystems
suggested changes
Jun 2, 2026
Contributor
velocitysystems
left a comment
There was a problem hiding this comment.
Thanks @polw1. Please see comments below. Also, the Swift files use 2-space indentation; the Silvermine Swift standard is 3 spaces indentation.
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.
Adds iOS support for
connection_status()using Apple’sNWPathMonitor.Closes #9.
This wires a native iOS implementation into the existing plugin API while keeping the same
ConnectionStatusresponse shape used by the cross-platform surface.The iOS implementation is provided by
ios/Sources/ConnectivityPlugin.swiftand is backed by a long-livedNWPathMonitor. The monitor starts during plugin initialization, caches the latest observedNWPath, andconnection_status()maps that cached state to:connectedmeteredconstrainedconnectionTypeThis avoids treating
NWPathMonitoras a synchronous one-shot status getter and better matches Apple’s callback-driven API model.On the Rust side,
Connectivityis now platform-specific:PluginHandle-backed native implementationBecause these types are materially different, the plugin state, extension trait return types, and initialization path branch under
#[cfg(target_os = "ios")]and#[cfg(not(target_os = "ios"))].I kept this split explicit in
lib.rsto land the minimal iOS integration cleanly without introducing a broader abstraction layer in the same PR. A follow-up refactor can reduce the conditional boilerplate if needed.Tested with:
npm run standards