Cordova plugin not available on platform.ready()

I am using the phonegap-nfc plugin. When I call it in platform->ready() it is not available.

The output from adb logcat is:

I/chromium(10314): [INFO:CONSOLE(5128)] "Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.", source: file:///android_asset/www/build/js/app.bundle.js (5128)
I/chromium(10314): [INFO:CONSOLE(3222)] "The platform is now ready", source: file:///android_asset/www/build/js/app.bundle.js (3222)
I/chromium(10314): [INFO:CONSOLE(32153)] "EXCEPTION: TypeError: Cannot read property 'nfc' of undefined", source: file:///android_asset/www/build/js/app.bundle.js (32153)
I/chromium(10314): [INFO:CONSOLE(32153)] "STACKTRACE:", source: file:///android_asset/www/build/js/app.bundle.js (32153)
I/chromium(10314): [INFO:CONSOLE(32153)] "TypeError: Cannot read property 'nfc' of undefined
I/chromium(10314):     at file:///android_asset/www/build/js/app.bundle.js:3228:31
I/chromium(10314):     at Zone.run (file:///android_asset/www/build/js/app.bundle.js:1183:18)
I/chromium(10314):     at Zone.run (file:///android_asset/www/build/js/app.bundle.js:17527:43)
I/chromium(10314):     at zoneBoundFn (file:///android_asset/www/build/js/app.bundle.js:1156:20)
I/chromium(10314):     at lib$es6$promise$$internal$$tryCatch (file:///android_asset/www/build/js/app.bundle.js:2556:17)
I/chromium(10314):     at lib$es6$promise$$internal$$invokeCallback (file:///android_asset/www/build/js/app.bundle.js:2568:18)
I/chromium(10314):     at lib$es6$promise$$internal$$publish (file:///android_asset/www/build/js/app.bundle.js:2539:12)
I/chromium(10314):     at file:///android_asset/www/build/js/app.bundle.js:1288:6
I/chromium(10314):     at Zone.run (file:///android_asset/www/build/js/app.bundle.js:1183:18)
I/chromium(10314):     at zoneBoundFn (file:///android_asset/www/build/js/app.bundle.js:1156:20)", source: file:///android_asset/www/build/js/app.bundle.js (32153)
I/BufferQueue(  197): [io.ionic.starter/io.ionic.starter.MainActivity](this:0x41c00588,id:143,api:1,p:10314,c:197) [queue] fps:0.20, dur:4909.34, max:4909.34, min:4909.34
I/BufferQueue(  197): [io.ionic.starter/io.ionic.starter.MainActivity](this:0x41c00588,id:143,api:1,p:10314,c:197) [release] fps:0.20, dur:4921.41, max:4921.41, min:4921.41
D/NfcPlugin(10314): execute init
D/NfcPlugin(10314): Enabling plugin Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=io.ionic.starter/.MainActivity }
W/PluginManager(10314): THREAD WARNING: exec() call to NfcPlugin.init blocked the main thread for 24ms. Plugin should use CordovaInterface.getThreadPool().
D/NfcPlugin(10314): parseMessage Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=io.ionic.starter/.MainActivity }
D/NfcPlugin(10314): action android.intent.action.MAIN
I/BufferQueue(  197): [io.ionic.starter/io.ionic.starter.MainActivity](this:0x41c00588,id:143,api:1,p:10314,c:197) [queue] fps:0.94, dur:1066.51, max:1066.51, min:1066.51
I/BufferQueue(  197): [io.ionic.starter/io.ionic.starter.MainActivity](this:0x41c00588,id:143,api:1,p:10314,c:197) [release] fps:0.94, dur:1067.63, max:1067.63, min:1067.63
I/chromium(10314): [INFO:CONSOLE(19)] "Initialized the NfcPlugin", source: file:///android_asset/www/plugins/phonegap-nfc/www/phonegap-nfc.js (19)

How do I get notified when the plugins are really ready?

3 things:

  1. Isn’t there a Cordova equivalent for that plugin?
  2. Are you testing in browser or in device?
  3. Try running the build command at least once, some people had issues related to plugins but fixed it with the build command, idk why though.
  1. I think it is a Cordova plugin (but I am new to this, so I could easily be wrong)
  2. On the device
  3. Have built it many times

For now I have put in a setTimeout, but would like to know what the real answer is. Seems like it may be a bug.

I think the problem is what the comment at https://github.com/chariotsolutions/phonegap-nfc/blob/master/www/phonegap-nfc.js#L9 explains.