Skip to content
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

feat(connectivity_plus): Return multiple active types on MacOS/iOS when available #3083

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@ public class PathMonitorConnectivityProvider: NSObject, ConnectivityProvider {

private func connectivityFrom(path: NWPath) -> [ConnectivityType] {
var types: [ConnectivityType] = []

// Check for connectivity and append to types array as necessary
if path.status == .satisfied {
if path.usesInterfaceType(.wifi) {
types.append(.wifi)
}
if path.usesInterfaceType(.cellular) {
types.append(.cellular)
}
if path.usesInterfaceType(.wiredEthernet) {
types.append(.wiredEthernet)
}
if path.usesInterfaceType(.other) {
types.append(.other)
}
}

return types.isEmpty ? [.none] : types

for interface in path.availableInterfaces {
switch interface.type {
case .wifi:
types.append(.wifi)
case .wiredEthernet:
types.append(.wiredEthernet)
case .cellular:
types.append(.cellular)
case .loopback:
types.append(.other)
case .other:
types.append(.other)
@unknown default:
types.append(.other)
}
}

return types.isEmpty ? [.none] : types
}

public var currentConnectivityTypes: [ConnectivityType] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C80D4294CF70F00263BE5 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,15 @@ class Connectivity {
/// case where [ConnectivityResult.none] is present.
///
/// This method applies [Stream.distinct] over the received events to ensure
/// only emiting when connectivity changes.
/// only emitting when connectivity changes.
Stream<List<ConnectivityResult>> get onConnectivityChanged {
return _platform.onConnectivityChanged.distinct((a, b) => a.equals(b));
}

/// Checks the connection status of the device.
///
/// Do not use the result of this function to decide whether you can reliably
/// make a network request, it only gives you the radio status. Instead, listen
/// for connectivity changes via [onConnectivityChanged] stream.
/// make a network request, as it only provides network interfaces status, but not an Internet availability.
///
/// The returned list is never empty. In case of no connectivity, the list contains
/// a single element of [ConnectivityResult.none]. Note also that this is the only
Expand Down
Loading