square / react-native-square-reader-sdk

React Native Plugin for Square Reader SDK
Apache License 2.0
117 stars 36 forks source link

Blank "Square reader" screen after enabling bluetooth #197

Closed mormrod closed 1 year ago

mormrod commented 2 years ago

Describe the issue

Both on my device and emulator running Android 12 I am getting the following screens.

(see screenshots)

To Reproduce

As you can see, when attempting to connect to the reader, I get asked the permission options (I have already granted the Bluetooth one when the app opens)

I enable each one, and on clicking on Enable Bluetooth I get the blank "Square reader" screen.

No reader ever appears to connect to, and there are no other options other than to close that screen and return to my RN app.

Expected behavior

I have had this repo running successfully on RN 0.62 for some time, so I know the app code is correct (and it matches your docs), but I needed to update to RN 0.69, and this is the last component that does not work.

On this screen I used to see information on how to connect the reader, and it would then connect to it when following the instructions, but now I only get a blank screen.

Environment (please complete the following information):

Screenshots

Screenshot_20220927_221253 Screenshot_20220927_221334 Screenshot_20220927_221353

Additional context

mormrod commented 2 years ago

@CharmisG Is there any update on this? This is undermining our ability to release the Android app which processes millions of Dollars in revenue. Does this need escalating to our Square account manager?

mormrod commented 2 years ago

@CharmisG Any update?

Has anyone else replicated this behavior on the latest version on an Android 12 device?

fka3 commented 2 years ago

That this is about Bluetooth permissions and Android 12 is telling; Google changed how those work as of that Android release. It's supposed to work for Reader SDK 1.7.1, but that's new. If you can play with the target SDK level, at API 30 or less the old permission rules should apply, which might avoid this issue.

mormrod commented 2 years ago

@fka3 I've tried building the quickstart app with targetSdkVersion set at 30 and result is the same. The screenshots are taken from the latest download of the quickstart app on an Android 12 device. Can you get it to run on an Android 12 device successfully?

fka3 commented 2 years ago

Well, dang it, it did when I cut that branch, but no, didn't just now. [Unprintable words here.]

Ok, back to API31 for me. You might check; there are two Bluetooth permissions that matter, but "dangerous" (per Google, because they imply location data) and needing user confirmation. If you can grant--- and I don't know enough React to know if this is possible---both BLUETOOTH_CONNECT and BLUETOOTH_SCAN outside of Reader SDK, that should at least avoid the issue.

But I'll try to figure out what went wrong (and how it worked for me at first!)

fka3 commented 2 years ago

No, actually, it does work for me; we just had the code with permissions set back to API 30's permissions.

Two questions:

  1. When you say you "tried building the quickstart app with targetSdkVersion set at 30," what did you edit? If you only changed the target SDK, it probably should have failed to compile because of the new permission names... but you should have to edit both AndroidManifest to remove the new permissions, and also build.gradle to set the target SDK; did you adjust both?
  2. Although I definitely suggest that we should explore with quickstart, the real target is your react app; is it possible to pull the final AndroidManifest from that? (Failing that, could you send me the .apk and I can pull it?). What I want to check is the targetSDK of the manifest and the permissions requested by it; they should be consistent. Either the targetSDK should be 30-or-less and the strings BLUETOOTH_CONNECT and BLUETOOTH_SCAN should not appear, or the target SDK should be 31-or-more and both should be requested.

Having realized that my test app was inconsistent, I'm now seeing working behavior targeting and running on 31/Android 12. I can do the test of targeting 30 while running on 31, if that's your target SDK?

hukid commented 2 years ago

@fka3 @mormrod is this problem resolved? Should we close this issue now?

fka3 commented 1 year ago

I'd've liked the customer/developer to confirm, but yes, from what I observed, things work properly and the ticket can be closed. If @mormrod disagrees, we can reconsider.