mrousavy / react-native-google-nearby-messages

📲 Communicate with nearby devices using Bluetooth, BLE, WiFi and near-ultrasonic audio. Broadcast and receive small payloads (like strings) using the easy-to-use React Native API!
https://mrousavy.github.io
MIT License
214 stars 33 forks source link

[BUG] IllegalArgumentException on Android [ConnectionResult=APP_NOT_OPTED_IN] #117

Open jaysquared opened 1 year ago

jaysquared commented 1 year ago

IllegalArgumentException on Android [ConnectionResult=APP_NOT_OPTED_IN]

I have read the Troubleshooting page: Yes

Describe the bug When calling connect, I get this Exception in the Logs and the Nearby API is not working:

GMS core API Availability. ConnectionResult=2802, tag=null
 java.lang.IllegalArgumentException
at com.google.android.gms.common.GoogleApiAvailability.zae(com.google.android.gms:play-services-base@@18.0.1:2)
at com.google.android.gms.common.GoogleApiAvailability.zah(com.google.android.gms:play-services-base@@18.0.1:6)
at com.google.android.gms.common.api.internal.GoogleApiManager.zaG(com.google.android.gms:play-services-base@@18.0.1:1)
at com.google.android.gms.common.api.internal.zabq.zar(com.google.android.gms:play-services-base@@18.0.1:21)
at com.google.android.gms.common.api.internal.zabq.onConnectionFailed(com.google.android.gms:play-services-base@@18.0.1:1)
at com.google.android.gms.common.internal.zai.onConnectionFailed(com.google.android.gms:play-services-base@@18.0.1:1)
at com.google.android.gms.common.internal.zzf.zzb(com.google.android.gms:play-services-basement@@18.1.0:2)
at com.google.android.gms.common.internal.zza.zza(com.google.android.gms:play-services-basement@@18.1.0:3)
at com.google.android.gms.common.internal.zzc.zze(com.google.android.gms:play-services-basement@@18.1.0:3)
at com.google.android.gms.common.internal.zzb.handleMessage(com.google.android.gms:play-services-basement@@18.1.0:31)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.os.HandlerThread.run(HandlerThread.java:67)

According to NearbyMessagesStatusCodes the error code 2802 refers to

public static final int APP_NOT_OPTED_IN
Status code indicating that the User has not granted the calling application permission to use Nearby.Messages.
Resolution: The application can use the returned PendingIntent to request user consent.
Constant Value: 2802

Environment

Additional context I changed the kotlin version in build.gradle to "1.6.0" as the app wouldn't build otherwise. I tried all kinds of combinations of permissions in AndroidManifest and requesting these with react-native-permissions:

"react": "18.1.0",
"react-native": "0.70.6",
"react-native-google-nearby-messages": "1.0.22"

I hope you have an idea to solve this issue. It's working fine on iOS. Thanks!

NiccoloCase commented 1 year ago

I can't get this library to work either.