First time NFC read doesn't work


Hi everyone!

I have to read a NFC tag with ionic 2, the problem is the first attempt doesn’t read then if I read again is working fine,

This is my code:

  selector: 'page-dispositivo',
  templateUrl: 'dispositivo.html',
  providers: [NFC, Ndef, Diagnostic, Vibration]
export class DispositivoPage {

  subscriptions: Array<Subscription> = new Array<Subscription>();

    public navCtrl: NavController,
    public navParams: NavParams,
    private auth: AuthService,
    public loading: LoadingController,
    public alertCtrl: AlertController,
    public toastCtrl: ToastController,
    private nfc: NFC,
    private ndef: Ndef,
    public diagnostic: Diagnostic,
    public platform: Platform,
    public vibration: Vibration
  ) {

    platform.ready().then(() => {

  initNFC() {
      .then(() => {
      }).catch(err => {
        let alert = this.alertCtrl.create({
          subTitle: 'Active la conexión NFC para para leer artículos',
          buttons: [
              text: 'Activar más tarde',
              handler: () => {
              text: 'Ir a Ajustes para activar',
              handler: () => {
                this.nfc.showSettings().then(rs => {

  addListenNFC() {
    this.subscriptions.push(this.nfc.addTagDiscoveredListener().subscribe(nfcData => {

I don’t know what is happening, somebody can help me?

First time NFC read doesn’t work
Working NFC Plugin method needed - DONATION FOR SOLUTION

Me too. @Carlosvel60 did you found a work around?



I know this is bit late but , the solution is much simpler than the problem ,
first use only single subscription dont use the array.

subscriptions:Subscription = new Subscription();

later in code;
this.ndeflistner = this.nfc.addMimeTypeListener(this.tpe);

u may use addndefListner() too

then subscrible to it

this.subscriptions = this.ndeflistner.subscribe(data=>{
//your code


Thank you for the help.

I didn’t understand what is the class “Subscription”. Where is it defined?

This is my code:

import { Component } from '@angular/core';
import { Platform, AlertController } from 'ionic-angular';
import { NFC } from '@ionic-native/nfc';
import { SplashScreen } from '@ionic-native/splash-screen';
import { InAppBrowser } from '@ionic-native/in-app-browser';

  selector: 'page-home',
  templateUrl: 'home.html'
export class HomePage {
    tagId: string = "??"
    timeout: any
    scrivibile: string
    proteggibile: string
    maxSize: number
    readOnly: string

    constructor(private nfc: NFC, private platform: Platform,
                private alertCtrl: AlertController, private splashScreen: SplashScreen,
                private iab: InAppBrowser) {
        platform.ready().then(() => {
            console.log('Platform ready: checking for nfc enabled...')
            this.timeout = setInterval(() => {
            }, 1000*0.5);
            console.log('Timeout started');
            nfc.enabled().then((flag) => {
                console.log('nfc enabled risponde: ' + flag);
                        (data: Event) => this.nfcOkNdef(data),
                        (err)  => console.log(err)


    timeoutExpired() {
        let noNfc = this.alertCtrl.create({
            title: 'NFC not enabled',
            message: 'App will expired; do you want NFC setup to open?',
            buttons: [
                {text: 'Yes', handler: () => { this.nfc.showSettings(); this.platform.exitApp(); } },
                {text: 'No', handler: () => { this.platform.exitApp() } }

    .....some other functions.....


Any help will be appreciated.


use import {Subscription} from ‘rxjs/Subscription’
You need to learn the angular basics to really understand all the things .
Writing nfc service is not a cake walk .

I will give you an advice , if your using nfc tags then you can use write and ndef listner combo,
if you want to transfer data between two android devices , then android beam ,
functions to use for android beam is nfc.share and listner at other end.


Thanks a lot for helping…
I tried, but it’s the same: the first scan does not trigger the subscription. Then all run OK.
By the way, I need only the ID of the NFC. I read also the data programmed in, but this is no important. And I don’t write the nfc, anyway.



I have implemented it , use single subscription and attached that listner to subscription , and are you reading tags of android phone