问题
We are currently utilizing a React Native wrapper over Google Nearby Messages (repo code here). On Android everything was working until about a week ago when suddenly everytime anything is published it returns a 2806 Forbidden error with almost no context. Everything is working on the iOS side. We have been trying to solve this here: https://github.com/mrousavy/react-native-google-nearby-messages/issues/25 but we are turning to stackoverflow as we are hoping somebody has seen this and solved it on Android.
Here is the Kotlin code for publishing:
@ReactMethod
fun publish(message: String, promise: Promise) {
if (_messagesClient != null) {
if (_publishedMessage != null) {
promise.reject(Exception("There is an active published message! Call unpublish first!"))
} else {
_publishedMessage = Message(message.toByteArray())
_messagesClient!!.publish(_publishedMessage!!, _publishOptions!!).addOnCompleteListener { task ->
Log.d(name, "GNM_BLE: Published! Successful: ${task.isSuccessful}")
if (task.isSuccessful) {
promise.resolve(null)
} else {
_publishedMessage = null
val e = task.exception
if (e != null) promise.reject(mapApiException(e))
else promise.reject(Exception("The task was not successful, but no Exception was thrown."))
}
}
}
} else {
promise.reject(Exception("The Messages Client was null. Did the GoogleNearbyMessagesModule native constructor fail to execute?"))
}
}
Here are the variables inspected when adding a breakpoint to the Log line:
We have tried switching API keys already and all that.
来源:https://stackoverflow.com/questions/64431212/google-nearby-messages-publish-returns-2806-forbidden-android-react-native