bug: Application crashes if repeatedly trying to scan & fail
andreialinstoica opened this issue · 2 comments
Plugin version:
5.0.1
Platform(s):
Android
Current behavior:
Start scanning session then repeatedly tap the NFC tag on the NFC receiver. It will crash the application. Wrapping the write function in a try catch error will show the following error:
java.io.IOException: Only one TagTechnology can be connected at a time.
Expected behavior:
Exception will be thrown in scanSessionError listener
Steps to reproduce:
Start scanning session then repeatedly tap the NFC tag on the NFC receiver.
Related code:
Nfc.addListener('nfcTagScanned', async (event) => {
await Nfc.format();
await Nfc.write({ message: { records: [record] } });
await Nfc.stopScanSession();
});
await Nfc.startScanSession();
Capacitor doctor:
Latest Dependencies:
@capacitor/cli: 5.0.5
@capacitor/core: 5.0.5
@capacitor/android: 5.0.5
@capacitor/ios: 5.0.5
Installed Dependencies:
@capacitor/core: 5.0.4
@capacitor/cli: 5.0.4
@capacitor/android: 5.0.4
@capacitor/ios: 5.0.4
[error] Missing <manifest package=""> attribute in app/src/main
Can be fixed by replacing the write method with:
Android
public void write(....) .... {
try {
... original code
} catch (Exception exception) {
notifyScanSessionErrorListener(exception.getMessage());
}
}
Based on the looks of it (code), seems that on iOS this problem is not happening.
This does not reproduce on the latest version 5.0.2.