> [!WARNING]
> **Warning:** Nearby Messages is deprecated and will stop working as of December 2023. Please migrate to [Nearby Connections](https://developers.google.com/nearby/connections/overview.md.txt) for further support.

The Nearby Messages API is a publish-subscribe API that lets you pass small
binary payloads between internet-connected Android and iOS devices. The devices
don't have to be on the same network, but they do have to be connected to the
Internet.

Nearby uses Bluetooth Low Energy to communicate a unique-in-time pairing code
between devices. The server facilitates message exchange between devices that
detect the same pairing code. When a device detects a pairing code from a nearby
device, it sends the pairing code to the Nearby Messages server for validation,
and to check whether there are any messages to deliver for the application's
current set of subscriptions.

Nearby Messages is unauthenticated and does not require a Google Account.

The exact mechanism for data exchange may vary from release to release. The
following sequence shows the events leading to message exchange:

1. A publishing app makes a request to associate a binary payload (the message)
   with a unique-in-time pairing code (token). The server makes a temporary
   association between the message payload and the token.

2. The publishing device uses Bluetooth Low Energy to make the token detectable
   by nearby devices. The publishing device also uses Bluetooth Low Energy to scan
   for tokens from other devices.

3. A subscribing app associates its subscription with a token and uses Bluetooth
   Low Energy to send its token to the publisher, and to detect the publisher's
   token.

4. When either side detects the other's token, it reports it to the server.

5. The server facilitates message exchange between two devices when both are
   associated with a common token, and the API keys used by the calling apps are
   associated with the same project in the [Google Developers Console](https://console.developers.google.com/).

When using the Google Play services Nearby SDK, usage analytics are collected to
improve the experience.

- **Performance metrics:** The duration of publishes and subscriptions and the number of messages received is collected when using the Nearby SDK.
- **Device information:** Device model, country, build version and the application package name are collected and associated with the performance metrics to identify regional and device-specific slices.
- **Nearby Messages publishes:** Data published through Nearby Messages is stored by Google until the message is no longer published. This data is shared with subscribers who are near the device.

End users can allow or deny this collection by navigating to Settings \> Google \>
Usage \& diagnostics.