Skip to content

Install Connectivity

To use this package, add the following to your pubspec.yaml file. Note that this package only works together with carp_mobile_sensing.

dependencies:
flutter:
sdk: flutter
carp_mobile_sensing: ^latest
carp_connectivity_package: ^latest
...

As explained in the Android Wi-Fi scanning overview, access to wifi information requires location access and wifi access permissions. As explained in the dchs_flutter_beacon plugin, access to iBeacons requires location access and Bluetooth access permissions. In summary, you should add the following to your app’s AndroidManifest.xml file located in android/app/src/main:

<!-- Required for accessing location information -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Optional: background scanning -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<!-- Required for accessing network information -->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!-- Required for BLE scanning on Android 12+ (API 31+) -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<!-- Recommended when checking Bluetooth state or prompting the user to enable Bluetooth -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

Access to network information on iOS is highly restricted. From iOS >= 13 there is no longer direct access to wifi information. See the network_info_plus description and the iOS description.

To enable bluetooth tracking, add these permissions in the Info.plist file located in ios/Runner:

<!-- Bluetooth Privacy -->
<!-- for iOS 13 + -->
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Reason why app needs bluetooth</string>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
<string>bluetooth-peripheral</string>
<string>external-accessory</string>
<string>fetch</string>
</array>

To collect iBeacon measurements, please follow the setup described in the dchs_flutter_beacon plugin. Especially, for iOS you need permissions to access location information in the Info.plist file:

<!-- When in use -->
<key>NSLocationWhenInUseUsageDescription</key>
<string>Reason why app needs location</string>
<!-- Always -->
<!-- for iOS 11 + -->
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Reason why app needs location</string>
<!-- for iOS 9/10 -->
<key>NSLocationAlwaysUsageDescription</key>
<string>Reason why app needs location</string>