The Nearby Connections API allows your users to connect with each other even when no internet is available. The API uses Bluetooth and other technologies that allow for close range peer-to-peer communication, usually within 100 meters.
This opens up a lot of possibilities for what users can do or share. For example, users can collaborate within a large group or share videos, files, and text messages.
Of course, there are limitations on how large the group can be. Bluetooth can only maintain approximately 4 connections at once; WiFi caps at approximately 10 to 100 connections at once depending on whether wall-powered routers are available as bridges.
While the Nearby Messages API works across Android and iOS, the Nearby Connections API only works on Android devices. Two key advantages of the Nearby Connections API over Messages are:
- It allows unlimited amounts of data to be transferred over Bluetooth and peer-to-peer WiFi, whereas Messages is only for small packets (up to 4kb)
- It allows users to communicate with each other even without an internet connection, whereas Messages requires an internet connection
To allow your app to enable the Nearby Connections API for a user, you must first add the latest release of the following Gradle dependency in your app module.