#jack-android-terminal-discovery

1 messages · Page 1 of 1 (latest)

jagged hawkBOT
vital cypress
#

hello

eternal isle
#

hey there

#

Which reader are you using?

vital cypress
#
public class ReaderDiscoveryActivity extends AppCompatActivity implements DiscoveryListener {

    Cancelable discoverCancelable = null;

    // Action for a "Discover Readers" button
    @SuppressLint("MissingPermission")
    public void discoverReadersAction() {
        DiscoveryConfiguration config = new DiscoveryConfiguration.BluetoothDiscoveryConfiguration(0, false);


        discoverCancelable = Terminal.getInstance().discoverReaders(config, this, new Callback() {
            @Override
            public void onSuccess() {
                Log.d("CordovaStripePlugin", "discoverReaders succeeded");
            }

            @Override
            public void onFailure(@NonNull TerminalException e) {
                e.printStackTrace();
            }
        });
    }

    // DiscoveryListener
    @Override
    public void onUpdateDiscoveredReaders(@NonNull List<Reader> list) {

    }
}
#

m2

#

i havent gotten to connecting to it yet

#

but im simply trying to execute the code above

#

unfortunately

eternal isle
#

Are you seeing the onSuccess log?

vital cypress
#

the function never calls the onUpdateDiscovered readders or the onsuccess

#

nope

eternal isle
#

What about the error case then?

vital cypress
#

it says that the bluetooth permissions must be requested before discovering

#

but when the app launches it already asked the user and they said allow

eternal isle
#

Does your app properly declare all permissions required?

vital cypress
#

it should

eternal isle
vital cypress
#

if (
ContextCompat.checkSelfPermission(
this.cordova.getActivity(),
android.Manifest.permission.ACCESS_FINE_LOCATION
) !=
PackageManager.PERMISSION_GRANTED
) {
String[] permissions = {
android.Manifest.permission.ACCESS_FINE_LOCATION,
};
// REQUEST_CODE_LOCATION should be defined on your app level
ActivityCompat.requestPermissions(
this.cordova.getActivity(),
permissions,
REQUEST_CODE_LOCATION
);
}

eternal isle
#

Oh this is via Cordova?

#

I'm not sure whether the SDKs work via Cordova or not

#

But aside from the above snippet you'd also need the manifest entries and onRequestPermissionsResult

vital cypress
#

yes i have that method

eternal isle
#

But you're saying to reach neither the success nor error paths?

vital cypress
#

ok hold on

#

the function is called

#

this is the error i am getting

#

on app launch i do this

#

this then works assuming the user clicks allow

eternal isle
#

Ok, then everything works?

vital cypress
#

no

#

thats the problem

eternal isle
#

This seems to revolve around permissions propagation then

#

Are you using the Android SDK natively, or is Cordova some kind of intermediary here?

#

The only cross-platform framework we support currently is React Native

jagged hawkBOT
vital cypress
#

yes natively

#

natively on android not cordova

jolly marlin
#

👋 jumping in here

Are you seeing the permissions dialogues when you run the app?

jagged hawkBOT
#

jack-android-terminal-discovery