Platform behavior
Why the platforms do not interoperate
An Android device and an iPhone that run your app never discover each other. The plugin gives you one API over two unrelated native transports. It does not give you one network across both.
| Android | iOS | |
|---|---|---|
| Transport | Nearby Connections | Multipeer Connectivity |
| Delivered by | Google Play services | The operating system |
| Wire format | Google's, closed | Apple's, closed |
Neither vendor publishes a specification that the other could implement, and the same ServiceId
on both sides does not help. If your users are on both platforms and must reach each other, do not
adopt this plugin.
Android requires Google Play services
Nearby Connections is part of Google Play services, not of the Android platform. A device without Google Play services cannot advertise or discover. Such devices include AOSP builds and some rugged industrial handhelds.
On such a device, CheckAvailabilityAsync reports NearbyAvailability.PlayServicesUnavailable and
the start methods throw NearbyException. The plugin has no fallback transport. Check availability
before you show the feature:
if (await nearby.CheckAvailabilityAsync(ct) is NearbyAvailability.PlayServicesUnavailable)
{
// This device cannot do nearby connectivity at all. Hide the feature.
}
Connections do not survive backgrounding
iOS. Multipeer Connectivity has no background mode, and iOS suspends an app within seconds
after it moves to the background. The plugin stops the session on DidEnterBackground, the same
way that StopAllAsync does, but with a different reason:
- The
Closedtask of every open connection completes withNearbyEndReason.AppSuspended. - Every device leaves
Devices, andDeviceChangedreports each one asRemoved. - Advertising and discovery stop, and
LastStop.ReasonisSuspended.
The plugin restarts nothing when the app returns to the foreground. Your app decides whether to restart.
Android. The connection ends when the process ends, and Doze separately suspends networking. A connection survives the background only with a foreground service. The plugin leaves that work to your app. See Keep a connection open in the background. The plugin also does not stop advertising or discovery when the app moves to the background. If your app continues in the background, make sure that the user knows. Google's Nearby guidelines require this.
There is no auto-reconnect. Neither platform has a reconnect API. To recover, advertise again and connect again.
App versions during a rollout
Devices with different versions of your app can connect. The plugin sends a small control frame
with the offer window and the presence. A device that cannot read that frame ignores it and does
not deliver it to your app. It then uses the default OfferWindow and receives no Info. Discovery, connections,
and payloads still work. On iOS, a frame that the device cannot read during the authentication
code exchange fails that connection attempt.
Which radio carries the data
Neither platform lets you choose the radio. On Android, Nearby Connections selects from Bluetooth
Classic, BLE, and Wi-Fi, based on NearbyOptions.Android.Topology. On iOS, Multipeer Connectivity
uses Wi-Fi only and always behaves as a mesh. For that reason, the plugin reports
NearbyAvailability.BluetoothDisabled and WifiDisabled on Android only.
Next
- Security for what an encrypted link does and does not prove.
- Set up Android and iOS for the manifest and
Info.plistentries that each platform needs.