#thathquatch

1 messages · Page 1 of 1 (latest)

pure dockBOT
manic dock
#

The guide is very straight forward, but the first step is to discoverReaders and it immediately bombs. Docs are not great
quoting for context here

#

Which guide are you following?

manic dock
#

And are you just copy/pasting the code snippet we show here or are you modifying it?

summer palm
#

i copy pasted it...then i removed the useEffect and triggered the handleDiscoverReaders method via button

#

same result

manic dock
#

Also can I get the RN SDK version?

summer palm
#

yep one sec

#

swapping between 2 comps

#

u want the terminal SDK version or my RN version

#

RN: 0.71.14
Terminal: ^0.0.1-beta.12

manic dock
#

Can you share your code snippet?

summer palm
#

certainly

#
  const { discoverReaders, connectBluetoothReader, discoveredReaders } =
    useStripeTerminal({
      onUpdateDiscoveredReaders: (readers) => {
        // After the SDK discovers a reader, your app can connect to it.
        // Here, we're automatically connecting to the first discovered reader.
        handleConnectBluetoothReader(readers[0].id);
        console.log(readers)
      },
    });

  // useEffect(() => {
  //   handleDiscoverReaders();
  // }, []);

  const handleDiscoverReaders = async () => {
    // The list of discovered readers is reported in the `didUpdateDiscoveredReaders` method
    // within the `useStripeTerminal` hook.
    const { error } = await discoverReaders({
      simulated: true,
    });

    if (error) {
      alert(
        'Discover readers error: ',
        `${error.code}, ${error.message}`
      );
    }
  };

  const handleConnectBluetoothReader = async (id) => {
    const { reader, error } = await connectBluetoothReader({
      readerId: discoveredReaders[0].id,
      // Since the simulated reader is not associated with a real location, we recommend
      // specifying its existing mock location.
      locationId: discoveredReaders[0].locationId,
    });

    if (error) {
      console.log('connectBluetoothReader error', error);
      return;
    }

    console.log('Reader connected successfully', reader);
  };
  return (
    <View>
      <Button onPress={handleDiscoverReaders} title='Connect to a reader'/>
    </View>
  );
};```
#

so basically im hitting that button to try to trigger the discovery (as opposed to it happening in the useEffect) and it just immediately tells me the SDK is already busy discovering.

#

i also removed discoveryMethod: 'bluetoothScan', in the discoverReader props but that did nothing

#

also for context, the app is wrapped in a StripeTerminalProvider with a valid connection token generated from my own server.

cold finch
#

Hello 👋

#

can you try stopping, uninstalling and re-installing the app?

#

@summer palm

summer palm
#

sry was in work thing

#

reinstalling what app exactly?

cold finch
#

your react native app on the device you're using

summer palm
#

im using on an excode simulator currently, ios 17.0

cold finch
#

hmm okay, gotcha. Should work with simulator too i presume since we're not connecting to an actual reader

summer palm
#

are you able to recreate or see the problem on your side?

cold finch
#

Working on it, I recently tested this without expo and worked fine.

also, have you tried upgrading to the latest SDK?

#

0.0.1-beta.13 is the current version I think

summer palm
#

i will try that

#

i have a good feeling about this

#

worked, holy smokes

#

im getting a new error but i can work it from here!

cold finch
#

Awesome, glad that worked