Dołącz do
naszej listy adresowej, aby być na bieżąco z ogłoszeniami i ogłoszeniami dotyczącymi funkcji W pobliżu.
Przegląd
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Interfejs Nearby Messages API to interfejs typu publikowanie-subskrypcja, który umożliwia przesyłanie małych binarnych danych między urządzeniami z Androidem i iOS połączonymi z internetem. Urządzenia nie muszą być w tej samej sieci, ale muszą być połączone z internetem.
Udostępnianie w pobliżu używa Bluetootha Low Energy do przesyłania unikalnego kodu parowania między urządzeniami. Serwer ułatwia wymianę wiadomości między urządzeniami, które wykrywają ten sam kod parowania. Gdy urządzenie wykryje kod parowania z położonego w pobliżu urządzenia, wysyła go do serwera Nearby Messages w celu weryfikacji i sprawdzenia, czy są jakieś wiadomości do dostarczenia w przypadku bieżącego zestawu subskrypcji aplikacji.
Wiadomości w pobliżu nie wymagają uwierzytelniania ani konta Google.
Dokładny mechanizm wymiany danych może się różnić w zależności od wersji. Poniższa sekwencja przedstawia zdarzenia prowadzące do wymiany wiadomości:
Aplikacja do publikowania wysyła żądanie, aby powiązać binarne dane (wiadomość) z unikatowym kodem parowania (tokenem). Serwer tworzy tymczasowe powiązanie między ładunkiem wiadomości a tokenem.
Urządzenie publikujące używa Bluetooth Low Energy, aby umożliwić wykrycie tokena przez urządzenia w pobliżu. Urządzenie publikujące korzysta też z Bluetooth Low Energy, aby skanować tokeny z innych urządzeń.
Aplikacja subskrybowana łączy subskrypcję z tokenem i korzysta z Bluetooth Low Energy, aby wysłać token do wydawcy i wykryć token wydawcy.
Gdy jedna ze stron wykryje token drugiej strony, przekazuje tę informację na serwer.
Serwer ułatwia wymianę wiadomości między 2 urządzeniami, gdy oba są powiązane z tym samym tokenem, a klucze interfejsu API używane przez aplikacje wywołujące są powiązane z tym samym projektem w Konsoli programistów Google.
Gdy używasz pakietu SDK Usługi Google Play w pobliżu, gromadzone są statystyki dotyczące korzystania z tej usługi, aby zapewnić lepsze wrażenia.
- Dane o skuteczności: podczas korzystania z pakietu SDK Nearby są zbierane dane o czasie trwania publikacji i subskrypcji oraz o liczbie otrzymanych wiadomości.
- Informacje o urządzeniu: model urządzenia, kraj, wersja kompilacji i nazwa pakietu aplikacji są zbierane i kojarzone z danymi o wydajności, aby umożliwić identyfikację przekrojów regionalnych i urządzeniowych.
- Wymiana wiadomości z urządzeniami w pobliżu publikuje: dane opublikowane za pomocą funkcji Wymiana wiadomości z urządzeniami w pobliżu są przechowywane przez Google do momentu, gdy wiadomość przestanie być publikowana. Te dane są udostępniane subskrybentom, którzy znajdują się w pobliżu urządzenia.
Użytkownicy mogą zezwolić na gromadzenie danych lub zablokować to gromadzenie, wybierając kolejno Ustawienia > Google > Użytkowanie i diagnostyka.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-08-29 UTC.
[null,null,["Ostatnia aktualizacja: 2025-08-29 UTC."],[[["\u003cp\u003eNearby Messages, a publish-subscribe API, enables the exchange of small data payloads between nearby Android and iOS devices over the internet using Bluetooth Low Energy.\u003c/p\u003e\n"],["\u003cp\u003eThis API, set to be deprecated in December 2023, is unauthenticated, doesn't require a Google account, and leverages a unique pairing code system for device discovery and message delivery.\u003c/p\u003e\n"],["\u003cp\u003eGoogle collects performance metrics, device information, and published message data to improve the service; however, users can control this data collection through their device settings.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers are encouraged to migrate to Nearby Connections for continued support and functionality.\u003c/p\u003e\n"]]],[],null,["# Overview\n\n| **Warning:** Nearby Messages is deprecated and will stop working as of December 2023. Please migrate to [Nearby Connections](//developers.google.com/nearby/connections/overview) for further support.\n\nThe Nearby Messages API is a publish-subscribe API that lets you pass small\nbinary payloads between internet-connected Android and iOS devices. The devices\ndon't have to be on the same network, but they do have to be connected to the\nInternet.\n\nNearby uses Bluetooth Low Energy to communicate a unique-in-time pairing code\nbetween devices. The server facilitates message exchange between devices that\ndetect the same pairing code. When a device detects a pairing code from a nearby\ndevice, it sends the pairing code to the Nearby Messages server for validation,\nand to check whether there are any messages to deliver for the application's\ncurrent set of subscriptions.\n\nNearby Messages is unauthenticated and does not require a Google Account.\n\nThe exact mechanism for data exchange may vary from release to release. The\nfollowing sequence shows the events leading to message exchange:\n\n1. A publishing app makes a request to associate a binary payload (the message)\n with a unique-in-time pairing code (token). The server makes a temporary\n association between the message payload and the token.\n\n2. The publishing device uses Bluetooth Low Energy to make the token detectable\n by nearby devices. The publishing device also uses Bluetooth Low Energy to scan\n for tokens from other devices.\n\n3. A subscribing app associates its subscription with a token and uses Bluetooth\n Low Energy to send its token to the publisher, and to detect the publisher's\n token.\n\n4. When either side detects the other's token, it reports it to the server.\n\n5. The server facilitates message exchange between two devices when both are\n associated with a common token, and the API keys used by the calling apps are\n associated with the same project in the [Google Developers Console](https://console.developers.google.com/).\n\nWhen using the Google Play services Nearby SDK, usage analytics are collected to\nimprove the experience.\n\n- **Performance metrics:** The duration of publishes and subscriptions and the number of messages received is collected when using the Nearby SDK.\n- **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.\n- **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.\n\nEnd users can allow or deny this collection by navigating to Settings \\\u003e Google \\\u003e\nUsage \\& diagnostics."]]