Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230444

NDEF_PUSH_DISABLED (ionic 3)

$
0
0

Okay so your plugin works fine thats great! :blush:

Try my code wich I wrote some days ago to test the NFC Plugin. I can assure you that this one is working fine.

  sendValue() {
    //Attaching the NFC Listener
    this.nfc.addNdefListener(() => {
      this.SuccessAttach();
    }, (err) => {
      this.ErrorAttach();


    }).subscribe((event) => {
      //Send the message
      let value = this.ndef.textRecord('I am going to be sent over!');
      this.nfc.share([value]);
    });
  }

  receiveValue() {
    //Attaching the NFC Listener
    this.nfc.addNdefListener(() => {
      this.SuccessAttach();
    }, (err) => {
      this.ErrorAttach();


      }).subscribe((event) => {
        let alert = this.alertCtrl.create({
          subTitle: 'RECEIVED!',
          buttons: ['Dismiss']
        });
        alert.present();
      this.receivedValue = event.tag;
    });
  }


  SuccessAttach() {
    let alert = this.alertCtrl.create({
      subTitle: 'Attached Listener',
      buttons: ['Dismiss']
    });
    alert.present();
  }
  ErrorAttach() {
    let alert = this.alertCtrl.create({
      subTitle: 'Error Attaching Listener',
      buttons: ['Dismiss']
    });
    alert.present();
  }
}

You can also try this methods wich are also working fine. (Just replace them with the methods above…)


  sendValue() {
      var value = [this.ndef.textRecord('I am going to be sent over!')];
      this.nfc.write(value);
  }


  receiveValue() {
    this.nfc.addTagDiscoveredListener(() => {
      this.SuccessAttach();
    }, (err) => {
      this.ErrorAttach();


    }).subscribe((event) => {
      let alert = this.alertCtrl.create({
        subTitle: 'RECEIVED!',
        buttons: ['Dismiss']
      });
      alert.present();
      this.receivedValue = event.tag;
    });
  }

Basicly what I am doing here is to create an NFC-Tag on the first Phone sendValue and with receiveValue I scan over it and receive my Value.

What you have todo in your HTML:
Create an ngModel to see the received value. Also buttons wich fire the methods. I think that is what you wanted in the first place.

<ion-input [(ngModel)]="receivedValue"></ion-input>

Note: This is just to test if everything is in order and works… you can do the fine tuning then.


Viewing all articles
Browse latest Browse all 230444

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>