I want to use Google's Nearby Messages API to publish a simple message and I want to only use BLE for it so that no Nearby Permissions dialog is required. I am creating my MessagesClient with just the NearbyPermissions.BLE flag:
private MessagesClient messagesClient(Context context) {
return Nearby.getMessagesClient(context, messageOptions());
}
private MessagesOptions messageOptions() {
return new MessagesOptions.Builder()
.setPermissions(BLE)
.build();
}
public void publish(Context context) {
mMessagesClient = messagesClient(context);
mMessagesClient
.publish(mMessage) // publish without any PublishOptions
.addOnSuccessListener( // ... )
}
I am purposedly not setting any PublishOptions object because the documentation specifically states that the Strategy.BLE should only be used for subscriptions since it has an infinite TTL. However, messages are failing with the following error message:
2807: Missing microphone permission
I tried reverse-engineering the API a little bit and creating a custom Strategy object for BLE with a default TTL, but I instead get a 2806: FORBIDDEN error:
private PublishOptions publishOptions() {
return new PublishOptions.Builder()
.setStrategy(strategy())
.build();
}
private Strategy strategy() {
return new Strategy.Builder()
.zze(2)
.setTtlSeconds(TTL_SECONDS_DEFAULT)
.build();
}
Why is the API requiring a microphone permission even when I've explicitly requested only BLE permissions? (fine location permissions are granted, by the way).
From the Nearby Messages API Overview:
So the API you are using is expecting to speak and listen with audio for nearby identification/messaging.