plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Request]: Return if the connection uses a VPN instead of returning VPN as a result

Open js2702 opened this issue 1 year ago • 1 comments

Plugin

connectivity_plus

Use case

When using the plugin to detect if the user is on mobile data, vs non metered networks currently there is no way to tell if a user is connected when using a VPN. Because only VPN is returned we can't know if it's actually connected to the internet, or if it's a metered connection.

Proposal

I would propose a breaking change. Instead of returning an enum, return an object similar to this:

class ConnectivityResult {
  final ConnectivityType type;     // An enum with the current enum values except vpn
  final bool vpnConnection;
}

This allows actually checking the connectivity type when using a VPN. Currently there is no way to do that, at least on Android. On iOS since the VPN information is not exposed the flag could be false.

js2702 avatar Jan 25 '23 17:01 js2702

@js2702 Hey! Looking at the order of conditions within Connectivity.java#L26, it seems like if the device is on WiFi, it will return immediately, without any information about the VPN.

Does this behavior help?

I understand taking a dependency on this implicit contract is not a good idea, but just thought I'll check.

vishnukvmd avatar Apr 10 '23 06:04 vishnukvmd