flutter nearby connections
The flutter_nearby_connections plugin supports the discovery of services provided by nearby devices. Moreover, the flutter_nearby_connections plugin also supports communicating with those services through message-based data, streaming data, and resources (such as files). The framework uses infrastructure Wi-Fi networks, peer-to-peer Wi-Fi and Bluetooth Personal Area Networks (PAN) for the underlying transport over UDP. The project is based on
Nearby Connections API (Bluetooth & hotspot) Support Strategy: Strategy.P2P_CLUSTER, Strategy.P2P_STAR, Strategy.P2P_POINT_TO_POINT
Wi-Fi P2P (only wifi hotspot no internet) Support Strategy: Strategy.Wi_Fi_P2P
We use the NearbyConnections API, but Flutter methods are based on the concept of Multipeer Connectivity IOS.
Methods provided:
startAdvertisingPeer, startBrowsingForPeers, stopAdvertisingPeer
We separate the dependencies of the MCNearbyServiceAdvertiser, MCNearbyServiceBrowser and MCSession classes. All of the methods will be implemented in the NearbyService class.
<key>NSBonjourServices</key>
<array>
<string>_{YOUR_SERVICE_TYPE}._tcp</string>
</array>
<key>UIRequiresPersistentWiFi</key>
<true/>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>{YOUR_DESCRIPTION}</string>
in this case, YOUR_SERVICE_TYPE is 'mp-connection' (you can define it)
nearbyService.init(
serviceType: 'mp-connection',
strategy: Strategy.P2P_CLUSTER,