Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Nearby Messages API là một API phát hành-đăng ký cho phép bạn truyền tải trọng nhị phân nhỏ giữa các thiết bị Android và iOS có kết nối Internet. Các thiết bị không nhất thiết phải kết nối với cùng một mạng, nhưng phải kết nối với Internet.
Tính năng Chia sẻ lân cận sử dụng Bluetooth năng lượng thấp để truyền mã ghép nối duy nhất tại một thời điểm giữa các thiết bị. Máy chủ hỗ trợ việc trao đổi thông báo giữa các thiết bị phát hiện cùng một mã ghép nối. Khi phát hiện mã ghép nối từ một thiết bị ở gần, thiết bị sẽ gửi mã ghép nối đó đến máy chủ Thông báo lân cận để xác thực và kiểm tra xem có thông báo nào cần gửi cho nhóm gói thuê bao hiện tại của ứng dụng hay không.
Ứng dụng Tin nhắn lân cận không xác thực và không yêu cầu Tài khoản Google.
Cơ chế chính xác để trao đổi dữ liệu có thể khác nhau giữa các bản phát hành. Trình tự sau đây cho thấy các sự kiện dẫn đến việc trao đổi thông báo:
Ứng dụng phát hành đưa ra yêu cầu liên kết tải trọng tệp nhị phân (thông báo) với mã ghép nối duy nhất theo thời gian (mã thông báo). Máy chủ sẽ liên kết tạm thời giữa tải trọng thông báo và mã thông báo.
Thiết bị phát hành sử dụng Bluetooth năng lượng thấp để các thiết bị ở gần có thể phát hiện mã thông báo. Thiết bị phát hành cũng sử dụng Bluetooth năng lượng thấp để quét tìm mã thông báo từ các thiết bị khác.
Ứng dụng đăng ký liên kết gói thuê bao của ứng dụng với một mã thông báo và sử dụng Bluetooth Năng lượng thấp để gửi mã thông báo của ứng dụng đến nhà xuất bản, đồng thời phát hiện mã thông báo của nhà xuất bản.
Khi một bên phát hiện mã thông báo của bên kia, bên đó sẽ báo cáo mã thông báo đó cho máy chủ.
Máy chủ hỗ trợ việc trao đổi thông báo giữa hai thiết bị khi cả hai đều được liên kết với một mã thông báo chung và các khoá API mà ứng dụng gọi sử dụng được liên kết với cùng một dự án trong Google Developers Console.
Khi sử dụng SDK Nearby của Dịch vụ Google Play, dữ liệu phân tích về mức sử dụng sẽ được thu thập để cải thiện trải nghiệm.
Chỉ số hiệu suất: Thời lượng của các lượt phát hành và đăng ký cũng như số lượng thông báo nhận được sẽ được thu thập khi sử dụng SDK Nearby.
Thông tin thiết bị: Kiểu thiết bị, quốc gia, phiên bản bản dựng và tên gói ứng dụng được thu thập và liên kết với các chỉ số hiệu suất để xác định các lát cắt theo khu vực và theo thiết bị.
Nearby Messages xuất bản: Dữ liệu được xuất bản thông qua Nearby Messages sẽ được Google lưu trữ cho đến khi thông báo không còn được xuất bản nữa. Dữ liệu này được chia sẻ với những người đăng ký ở gần thiết bị.
Người dùng cuối có thể cho phép hoặc từ chối việc thu thập này bằng cách chuyển đến phần Cài đặt > Google > Sử dụng và chẩn đoán.
[null,null,["Cập nhật lần gần đây nhất: 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."]]