Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Nearby Messages API berpotensi menghabiskan baterai karena cara
menggunakan Bluetooth dan resource perangkat lainnya untuk mendeteksi dan berkomunikasi dengan
perangkat di sekitar. Untuk memastikan bahwa pengguna dapat mengontrol pengalaman, dialog keikutsertaan
akan ditampilkan saat pengguna pertama kali mengakses Nearby Messages API.
Pengguna harus memberikan izin agar Nearby dapat menggunakan resource
perangkat yang diperlukan.
Khusus BLE
Anda dapat menghindari dialog keikutsertaan jika aplikasi Anda telah diberi
izin ACCESS_FINE_LOCATION dan hanya menggunakan BLE selama publikasi dan
langganan.
[null,null,["Terakhir diperbarui pada 2025-08-29 UTC."],[[["\u003cp\u003eThe Nearby Messages API requires user consent to utilize device resources due to potential battery consumption from Bluetooth and other resource usage.\u003c/p\u003e\n"],["\u003cp\u003eAn opt-in dialog is presented upon first API access, requiring explicit user permission.\u003c/p\u003e\n"],["\u003cp\u003eThe opt-in dialog can be bypassed if the app only uses Bluetooth Low Energy (BLE), has been granted ACCESS_FINE_LOCATION permission, and is configured with the NearbyPermissions.BLE option.\u003c/p\u003e\n"]]],[],null,["# Handling User Consent\n\nThe Nearby Messages API has the potential to be battery-intensive due to the way\nit uses Bluetooth and other device resources to detect and communicate with\nnearby devices. To ensure that users are in control of the experience, an opt-in\ndialog is presented the first time the user accesses the Nearby Messages API.\nThe user must provide consent for Nearby to utilize the required device\nresources.\n| **Note:** The opt in dialog won't be shown if you only use BLE, and your app has ACCESS_FINE_LOCATION permissions. See [BLE Only](#ble_only) for an example.\n\nBLE Only\n--------\n\nYou can avoid the opt in dialog if your app has been granted the\nACCESS_FINE_LOCATION permission and only uses BLE during publishes and\nsubscribes. \n\n if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)\n == PackageManager.PERMISSION_GRANTED) {\n mMessagesClient = Nearby.getMessagesClient(this, new MessagesOptions.Builder()\n .setPermissions(NearbyPermissions.BLE)\n .build());\n }"]]