#melecouvreur_api

1 messages ยท Page 1 of 1 (latest)

warm pulsarBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1331897766150148137

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

sterile needle
#

Which reader type do you use? Tap to Pay, WisePOS E... etc

hollow yarrow
#

Tap to Pay, mobile devices only and the problem only happens on iOS

#

Is it the case that even if i add this callback it will only work when app is not in background? so I can only attempt reconnect when app is not in background?

#

I found this which could solve it, but this is only for bluetooth readers? Hi, the latest release, 3.4.0, added autoReconnectOnUnexpectedDisconnect and autoReconnectionDelegate on the LocalMobileConnectionConfigurationBuilder (both must be set). Enabling that will enable the SDK to attempt to reconnect when the application becomes active after being backgrounded. Please give that a try and let us know if run in to any issues with that solution.

sterile needle
#

Thanks for sharing! That's mainly for bluetooth reader, so it might not as expected, but I'd recommend giving a try.

Is it the case that even if i add this callback it will only work when app is not in background?
Yes

so I can only attempt reconnect when app is not in background?
One way is to use useEffect() to reconnect to the reader when the app is in the foreground. Similar logic from iOS SDK can be applied to react-native SDK: https://docs.stripe.com/terminal/payments/connect-reader?terminal-sdk-platform=ios&reader-type=tap-to-pay#handle-disconnects

Connect your application to a Stripe Terminal reader.

hollow yarrow
#

would I need to rediscover the reader?

sterile needle
#

Yes

hollow yarrow
#

so it would mainly involve adding conditional that checks if app state is in foreground to existing useEffect for example:
useEffect(() => {
if (isInitialized && locationPermissionGranted && isStripeTapToPayEnabled) {
if (connectedReader === null || connectedReader === undefined) {
discoverReaders({ discoveryMethod: 'localMobile', simulated: DEV })
.then(({ error }) => {
if (undefined !== error) {
logger.error(logEvents.stripe, Error discovering readers: ${error.message} code: ${error.code});
if (error.code === 'UnsupportedMobileDeviceConfiguration') {
useAppSettingsStore.setState({ stripeTapToPayEnabled: false });
Alert.alert(
'Unsupported iOS version',
'Your device is running an unsupported iOS version. Please update to the latest version to continue'
);
}
if (error.code === 'INTEGRATION_ERROR.LOCAL_MOBILE_UNSUPPORTED_DEVICE') {
useAppSettingsStore.setState({ stripeTapToPayEnabled: false });
Alert.alert('NFC is not supported', 'Your device does not have NFC. Please use a different device.');
}
}
})
.catch((error: any) => {
logger.error(logEvents.stripe, Unexpected error discovering readers: ${serialiseErrorMessage(error)});
});
}
}
}, [isInitialized, locationPermissionGranted, connectedReader, isStripeTapToPayEnabled]);

#

what type of disconnection does onDidReportUnexpectedReaderDisconnect support?

#

just to understand whether it's still worth adding onDidReportUnexpectedReaderDisconnect

sterile needle
hollow yarrow
#

oh sorry, we do that onUpdateDiscoveredReaders: const { initialize, isInitialized, connectedReader, discoverReaders, connectLocalMobileReader, disconnectReader } = useStripeTerminal({
onUpdateDiscoveredReaders: (readers) => {
console.log(Discovered ${readers.length} reader(s));
handleConnectMobileReader(readers[0]);
},
});

#

I'll isolate it in a seperate useeffect
// Handle app state changes - reconnect when coming to foreground
useEffect(() => {
const subscription = AppState.addEventListener('change', (nextAppState) => {
if (nextAppState === 'active' && isStripeTapToPayEnabled && !connectedReader) {
logger.info(logEvents.stripe, 'App active, attempting to connect reader');
discoverReaders({ discoveryMethod: 'localMobile', simulated: DEV }).catch((error) => {
logger.error(logEvents.stripe, Failed to discover readers: ${serialiseErrorMessage(error)});
});
}
});

return () => {
  subscription.remove();
};

}, [isStripeTapToPayEnabled, connectedReader]);

#

sorry for the overload ๐Ÿ˜„

warm pulsarBOT
shrewd anchor
#

I'd recommend you write in to our team with a full reproduction and outline of the issue and we can work async to debug and provide a solution. Unfortunately the ask is a bit beyond the remit of Discord