chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
706 stars 555 forks source link

how to fix ERROR Un-expected encoding error, UTF-8 stream truncated, or incorrect in ionic #365

Closed saidbouhmouch closed 4 years ago

saidbouhmouch commented 5 years ago

Hi, i created an app that reads an NFC tag. after reading the nfc tag it displays the following error :

ERROR Un-expected encoding error, UTF-8 stream truncated, or incorrect I am using: ionic 4

My code:

scanNfc(){
    this.nfc.addNdefListener(() => {
      console.log('successfully attached ndef listener');
    }, (err) => {
      console.log('error attaching ndef listener', err);
    }).subscribe((event) => {
              console.log('received ndef message. the tag contains: ', event.tag);
              console.log('decoded tag id to hexstring', this.nfc.bytesToHexString(event.tag.id)); 

    },(error)=>{
       this.toastBox(error);
    });
  }
don commented 4 years ago

Maybe bad data? Closing issue since it's really old.