Open pke opened 2 months ago
Hi @pke, as I recon, there's no way on iOS to set that timeout, but the timeout is treated as an NfcError, so you can check against it when you receive an error. By the way, I've not used the library with its listeners but with only more imperative solutions due the kind of app I'm developing, but I think that you can listen for NfcErrors.
Here's an example of how I've implemented it.
try {
// Modal should appear
await NfcManager.requestTechnology(NfcTech.Ndef, {
alertMessage: t('holdYourPhone')
});
} catch (err) {
if (err instanceof NfcError.Timeout) {
// Here's the timeout.
}
} finally {
// do stuff.
}
There's also a NfcError.UserCancel
whitch can come very handy to know when the user has pressed on the cancel button.
@giuliobracci have you tested this? This causes a "uncaught exception" in my app when the timeout occurs.
Similar UserCancel
is not caught in the catch
clause.
I recon on iOS (Android not tested) an open scan session sometimes closes itself. This means the iOS bottom sheet that displays the alert messages is closed and there is no more active session. Is this a default timeout somewhere (it seems to be around 20 secs)?
The
NfcEvents.SessionClosed
event listener reports "Unexpected" error.The phones log reads as follow: