# QRScanner just scan once

**URL:** <https://forum.ionicframework.com/t/qrscanner-just-scan-once/120343>\
**Category:** Ionic Native\
**Created:** [February 3, 2018, 4:56am UTC](https://forum.ionicframework.com/t/qrscanner-just-scan-once/120343 "2018-02-03T04:56:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rtalexk](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rtalexk/32/108700_2.png) [@rtalexk](https://forum.ionicframework.com/u/rtalexk)\
**Post date:** [February 3, 2018, 4:56am UTC](https://forum.ionicframework.com/t/qrscanner-just-scan-once/120343/1 "2018-02-03T04:56:38Z")

</div>

I have used [QRScanner](https://ionicframework.com/docs/native/qr-scanner/) to scan QR codes.

I decided to use QRScanner instead of BarcodeScanner because with the first one I can create my own design:

[[Album] Cordova QRScanner in Ionic 3 ![](https://i.imgur.com/YYx8PGq.jpg?fb "Cordova QRScanner in Ionic 3") ](https://imgur.com/a/eqOyL)

Docs says that `scan` method return and `observable` that `emits` the scanned text.

I have the next code to scan:

```auto
const scanSub = qrScanner.scan().subscribe((text: string) => {
  console.log('Scanned something', text);
  const slices = text.split('@');
  if (slices.length !== 3) {
    this._showToast({
      message: 'No es un código de seguridad válido',
      position: 'middle'
    });
  } else {
    viewCtrl.dismiss({
    code: slices[1]
    });
    qrScanner.hide();
    scanSub.unsubscribe();
    this._displayQRScanner(false);
  }
});
qrScanner.show();

```

That’s because I’m looking for a string like `0.234283489283412@somethingImportant@0.23482394273422342`  
where I need to retrieve whatever is between `@` sign. If it has not two `@` signs it is an invalid string and scan until a valid one, otherwise I close the modal returning `somethingImportant` and unsubscribe for scanning. But it just scan once

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:51pm UTC](https://forum.ionicframework.com/t/qrscanner-just-scan-once/120343/2 "2021-07-19T21:51:54Z")

</div>

Closed on July 19, 2021, 9:51pm UTC


