GithubHelp home page GithubHelp logo

eddyverbruggen / nativescript-nfc Goto Github PK

View Code? Open in Web Editor NEW
80.0 12.0 37.0 3.38 MB

:pencil: NativeScript plugin to discover, read, and write NFC tags

License: MIT License

TypeScript 96.50% Shell 3.50%
nativescript nativescript-plugin nfc nfc-tag rfid ndef

nativescript-nfc's Introduction

NativeScript NFC plugin

NPM version Downloads Twitter Follow

Installation

From the command prompt go to your app's root folder and execute:

NativeScript Version 7+:

ns plugin add nativescript-nfc

NativeScript Version 6 and below:

tns plugin add [email protected]

iOS Setup

iOS requires you to enable 'NFC Tag Reading' for your App ID here.

Also, add this to your App_Resources/iOS/app.entitlements (mind the name!) file:

<key>com.apple.developer.nfc.readersession.formats</key>
<array>
	<string>NDEF</string>
</array>

The demo app has this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.developer.nfc.readersession.formats</key>
	<array>
		<string>NDEF</string>
	</array>
</dict>
</plist>

Android Setup

⚠️ Since plugin version 4.0.0 this section is no longer needed, but you'll HAVE to run NativeScript 5.4.0 or newer. If you're using an older NativeScript, please stick to a plugin version < 4.0.0.

Update the activity entry in your App_Resources/Android/AndroidManifest.xml file:

<activity
        android:name="com.tns.NativeScriptNfcActivity"
        android:label="@string/title_activity_kimera"
        android:configChanges="keyboardHidden|orientation|screenSize">

So replace com.tns.NativeScriptActivity with com.tns.NativeScriptNfcActivity.

Webpack (again, no longer needed from plugin version 4.0.0)

If you're using Webpack to bundle your app you'll need to add 1 line of configuration in case you're targeting Android.

  • Open webpack.config.js (it's in the root of your project).
  • Look for an Array named appComponents, which likely contains stuff like "tns-core-modules/ui/frame".
  • Add resolve(__dirname, "node_modules/nativescript-nfc/nfc-activity.android.js") as shown here.

Demo app (those screenshots above)

Want to dive in quickly? Check out the demo!

You can run the demo app from the root of the project by typing npm run demo.ios.device or npm run demo.android.

This is what it looks like in action on iOS!

API

available

Not all devices have an NFC chip we can tap in to (and on iOS you need to build with Xcode 9+), so check this beforehand:

JavaScript
// require the plugin
var Nfc = require("nativescript-nfc").Nfc;

// instantiate the plugin
var nfc = new Nfc();

nfc.available().then(function (avail) {
  console.log(avail ? "Yes" : "No");
});
TypeScript
// require the plugin
import { Nfc } from "nativescript-nfc";

// instantiate the plugin
let nfc = new Nfc();

nfc.available().then(avail => {
  console.log(avail ? "Yes" : "No");
});

enabled

A device may have an NFC chip, but it needs to be turned on ✅ in order to be available for this plugin. So if available returns true and enabled returns false you should prompt the user to turn NFC on in the device settings.

JavaScript
nfc.enabled().then(function (on) {
  console.log(on ? "Yes" : "No");
});
TypeScript
nfc.enabled().then(on => {
  console.log(on ? "Yes" : "No");
});

setOnNdefDiscoveredListener

You may want to get notified when an Ndef tag was discovered. You can pass in a callback function that gets invoked when that is the case.

Note that blank/erased NFC tags are not returned here, but through setOnTagDiscoveredListener instead.

See the definition of NfcNdefData to learn what is returned to the callback function.

For iOS you can pass in these options (see the TypeScript example below):

  • stopAfterFirstRead: boolean (default false): don't continue scanning after a tag was read.
  • scanHint: string (default undefined): Show a little hint in the scan UI.
JavaScript
nfc
  .setOnNdefDiscoveredListener(function (data) {
    // see the TypeScript example below
  })
  .then(function () {
    console.log("OnNdefDiscovered listener added");
  });
TypeScript
import { NfcNdefData } from "nativescript-nfc";

nfc
  .setOnNdefDiscoveredListener(
    (data: NfcNdefData) => {
      // data.message is an array of records, so:
      if (data.message) {
        for (let m in data.message) {
          let record = data.message[m];
          console.log(
            "Ndef discovered! Message record: " + record.payloadAsString
          );
        }
      }
    },
    {
      // iOS-specific options
      stopAfterFirstRead: true,
      scanHint: "Scan a tag, baby!"
    }
  )
  .then(() => {
    console.log("OnNdefDiscovered listener added");
  });

You can pass in null instead of a callback function if you want to remove the listener.

TypeScript
nfc.setOnNdefDiscoveredListener(null).then(() => {
  console.log("OnNdefDiscovered listener removed");
});

setOnTagDiscoveredListener (Android only)

You may want to get notified when an NFC tag was discovered. You can pass in a callback function that gets invoked when that is the case.

Note that Ndef tags (which you may have previously written data to) are not returned here, but through setOnNdefDiscoveredListener instead.

See the definition of NfcTagData to learn what is returned to the callback function.

JavaScript
nfc
  .setOnTagDiscoveredListener(function (data) {
    console.log("Discovered a tag with ID " + data.id);
  })
  .then(function () {
    console.log("OnTagDiscovered listener added");
  });
TypeScript
import { NfcTagData } from "nativescript-nfc";

nfc
  .setOnTagDiscoveredListener((data: NfcTagData) => {
    console.log("Discovered a tag with ID " + data.id);
  })
  .then(() => {
    console.log("OnTagDiscovered listener added");
  });

You can pass in null instead of a callback function if you want to remove the listener.

TypeScript
nfc.setOnTagDiscoveredListener(null).then(() => {
  console.log("OnTagDiscovered listener removed");
});

writeTag (Android only)

You can write to a tag as well with this plugin. At the moment you can write either plain text or a Uri. The latter will launch the browser on an Android device if the tag is scanned (unless an app handling Ndef tags itself is active at that moment, like an app with this plugin - so just close the app to test this feature).

Note that you can write multiple items to an NFC tag so the input is an object with Arrays of various types (textRecord and uriRecord are currently supported). See the TypeScript definition for details, but these examples should get you going:

Writing 2 textRecords in JavaScript
nfc
  .writeTag({
    textRecords: [
      {
        id: [1],
        text: "Hello"
      },
      {
        id: [3, 7],
        text: "Goodbye"
      }
    ]
  })
  .then(
    function () {
      console.log("Wrote text records 'Hello' and 'Goodbye'");
    },
    function (err) {
      alert(err);
    }
  );
Writing a uriRecord in TypeScript
nfc
  .writeTag({
    uriRecords: [
      {
        id: [100],
        uri: "https://www.progress.com"
      }
    ]
  })
  .then(
    () => {
      console.log("Wrote Uri record 'https://www.progress.com");
    },
    err => {
      alert(err);
    }
  );

eraseTag (Android only)

And finally, you can erase all content from a tag if you like.

JavaScript
nfc.eraseTag().then(function () {
  console.log("Tag erased");
});
TypeScript
nfc.eraseTag().then(() => {
  console.log("Tag erased");
});

Tips

Writing to an empty tag

You first need to "discover" it with setOnTagDiscoveredListener (see below). While you're still "near" the tag you can call writeTag.

Writing to a non-empty tag

Same as above, but discovery is done through setOnNdefDiscoveredListener.

Future work

  • Peer to peer communication between two NFC-enabled devices.
  • Support for writing other types in addition to 'text' and 'uri'.

nativescript-nfc's People

Contributors

bradmartin avatar eddyverbruggen avatar krokofant avatar manojdcoder avatar neilsb avatar rosen-vladimirov avatar sylann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nativescript-nfc's Issues

package.json missing for demo app

Hello, Thanks for making this plugin. I downloaded the code and am trynna ing to run your demo. When I run npm run demo.android at the root of the project, I receive gives the following error:

npm ERR! enoent ENOENT: no such file or directory, open '/Projects/nativescript-nfc-master/package.json'
npm ERR! enoent This is related to npm not being able to find a file.

Is there something else I can try?

Plugin affects navigation in Nativescript with Angular app after installation (Android)

After installing the nativescript-nfc angular plugin navigation stopped working after the back button was pressed on an android device.

Both [nsRouterLink] in the html or routerExtensions.navigate() in typescript fail to produce navigation or an error message.

Can be reproduced simply by creating a new app from the template and installing teh nativescript-nfc plugin.

tns create testApp --ng
tns plugin add nativescript-nfc

After the plugin installation, the first tap to view item detail will work fine, but after tapping back further taps will not result in any item detail being displayed.

What is the current / correct build procedure for the demo?

I cannot get the demo to run properly, I have tried npm run demo.android, tns run android and tns build android

Both methods seem to work, but produce an error either in the emulator.

my tns info -

Component nativescript has 5.4.2 version and is up to date.
Component tns-core-modules has 6.0.0-next-2019-06-20-155941-01 version and is up to date.
Component tns-android has 6.0.0-2019-06-11-172137-01 version and is up to date.
Component tns-ios has 6.0.0-2019-06-10-154118-03 version and is up to date

And the error in the emulator

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5876)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: com.tns.NativeScriptException: Application entry point file not found. Please specify the file in package.json otherwise make sure the file index.js or bootstrap.js exists.\nIf using typescript make sure your entry point file is transpiled to javascript.
at com.tns.Module.bootstrapApp(Module.java:311)
at com.tns.Runtime.run(Runtime.java:624)
at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871)
... 8 more
Caused by: com.tns.NativeScriptException: Failed to find module: "./", relative to: app//
at com.tns.Module.resolvePathHelper(Module.java:146)
at com.tns.Module.bootstrapApp(Module.java:309)
... 12 more

This installation failed for me

npm ERR! code ENOGIT
npm ERR! Error while executing:
npm ERR! undefined ls-remote -h -t https://github.com/EddyVerbruggen/nativescript-custom-entitlements.git
npm ERR!
npm ERR! undefined
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.

npm ERR! A complete log of this run can be found in:

Hello, I have this error when I run this command : tns plugin add nativescript-nfc.
This is the first time I see this kind of error when installing a plugin.

tns run android --bundle errors with nativescript 3.4.0

Hi Eddy,

I would like to thank you for this plugin. it has been very helpful and mentions a couple of errors i have notice while running the command tns run android --bundle.

When i run tns run android command these errors don't appear.

I have two page where I want to use the NFC plugin home and test pages and I am using nfc.helper class to use the plugin method.

The First Error

This error comes up when I am importing the NFC helper class in both of my components pages

Exception in thread "main" java.io.IOException: File already exists. This may lead to undesired behavior.
Please change the name of one of the extended classes.
File:D:\Work\MOBILE\NATIVESCRIPT\NFCTest\platforms\android\app\src\main\java\com\tns\NativeScriptNfcActivity.java Class: com.tns.NativeScriptNfcActivity
        at org.nativescript.staticbindinggenerator.Generator.writeBindings(Generator.java:68)
        at org.nativescript.staticbindinggenerator.Main.main(Main.java:15)

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\Work\MOBILE\NATIVESCRIPT\NFCTest\platforms\android\build-tools\android-static-binding-generator\build.gradle' line: 284

* What went wrong:
Execution failed for task ':asbg:generateBindings'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_144\bin\java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 12s

I later try to import the plugin in both components instead of using the helper and the error still come up.

It looks like I am unable to use (import) the plugin in multiple pages/component. Do you have a workaround this issues?

The Second Error

After noticing the first error I tried to remove the class in one of the page/components and try to run the command again, this time around i am able to build the app but when it launches the following error come up:

System.err: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.nativescript.NFCTest/com.tns.NativeScriptNfcActivity}: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/NativeScriptNfcActivity'

Here is the relevant files of the app:

Home.component.ts

import { Component, OnInit } from "@angular/core";
import { RouterExtensions } from "nativescript-angular";
import { NfcHelper } from "../helper/nfc.helper";

@Component({
    selector: "Home",
    moduleId: module.id,
    templateUrl: "./home.component.html"
})
export class HomeComponent implements OnInit {

    nfcHelper: NfcHelper;

    constructor(private router: RouterExtensions) {
        this.nfcHelper = new NfcHelper();
    }

    ngOnInit(): void {
    }


    public goto() {
        this.router.navigate(['/test']);
    }
}

Test.component.ts

import { Component, OnInit } from "@angular/core";
import { NfcHelper } from "../helper/nfc.helper";


@Component({
    selector: "Test",
    moduleId: module.id,
    templateUrl: "./test.component.html"
})
export class TestComponent implements OnInit {

    nfcHelper: NfcHelper;

    constructor() {
        this.nfcHelper = new NfcHelper();
    }

    ngOnInit(): void {
    }

}

nfc.helper.ts

import { Nfc, NfcTagData, NfcNdefData } from "nativescript-nfc";

export class NfcHelper {
    private nfc: Nfc;

    constructor() {
        this.nfc = new Nfc();
    }

    public read() {
        this.nfc.available().then((avail) => {
            this.nfc.setOnTagDiscoveredListener((data: NfcTagData) => {
                console.log("Discovered a tag with ID " + data.id);

            }).then(() => {
                console.log("OnTagDiscovered listener added");
            });
        });

    }

    public remove() {
        this.nfc.setOnTagDiscoveredListener(null).then(() => {
            // Toast.makeText("OnNdefDiscovered listener removed").show();
            console.log("OnNdefDiscovered listener removed");
        })
    }

}

Package.json

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.NFCTest",
    "tns-android": {
      "version": "3.4.0"
    }
  },
  "dependencies": {
    "@angular/animations": "~5.0.0",
    "@angular/common": "~5.0.0",
    "@angular/compiler": "~5.0.0",
    "@angular/core": "~5.0.0",
    "@angular/forms": "~5.0.0",
    "@angular/http": "~5.0.0",
    "@angular/platform-browser": "~5.0.0",
    "@angular/platform-browser-dynamic": "~5.0.0",
    "@angular/router": "~5.0.0",
    "nativescript-angular": "^5.0.0",
    "nativescript-nfc": "2.1.2",
    "nativescript-theme-core": "1.0.4",
    "reflect-metadata": "0.1.10",
    "rxjs": "^5.5.0",
    "tns-core-modules": "^3.4.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~5.0.0",
    "@ngtools/webpack": "~1.8.2",
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "copy-webpack-plugin": "~4.0.1",
    "css-loader": "~0.28.7",
    "extract-text-webpack-plugin": "~3.0.0",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "0.5.1",
    "nativescript-dev-webpack": "^0.9.0",
    "nativescript-worker-loader": "~0.8.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.1.0",
    "typescript": "~2.4.2",
    "webpack": "~3.8.1",
    "webpack-bundle-analyzer": "^2.8.2",
    "webpack-sources": "~1.0.1"
  }
}

Can you please take a look and assist when possible.

Thanks

iOS: How get tag uid?

NfcNdefData should contain the id. In android it work but in iOS it is empty.

Is it possible get the tag uid?

System.err: Error: java.lang.IllegalStateException: Foreground dispatch can only be enabled when your activity is resumed

Try to tns run android to an Android 9 device, the app will check the availability of the nfc at startup as shown below.

checkNFC() {
    this.nfc = new Nfc();
    if (!this.isDoneChecking) {
      this.showLoader();
      Promise.all([this.nfc.available(), this.nfc.enabled()]).then(values => {
        this.isNfcAvailable = values[0];
        this.isNfcEnabled = values[1];
        this.loader.hide();
        this.isDoneChecking = true;
      });
    }
  }

If the device is unlocked when the app is starting, it works well. If the device is locked when starting the app, the following errors are logged in the console.

System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method run failed
System.err: Error: java.lang.IllegalStateException: Foreground dispatch can only be enabled when your activity is resumed
System.err: 
System.err: StackTrace:
System.err: push.../node_modules/nativescript-nfc/nfc.js.Nfc.initNfcAdapter(file:///node_modules/nativescript-nfc/nfc.js:368:0)
System.err:     at Nfc(file:///node_modules/nativescript-nfc/nfc.js:231:0)
System.err:     at module.exports.push../shared/services/nfc.service.ts.NfcService.checkNFC(file:///app/shared/services/nfc.service.ts:18:15)
System.err:     at (file:///app/home/home.component.ts:52:22)
System.err:     at push.../node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js.ZoneDelegate.invokeTask(file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:421:0)
System.err:     at onInvokeTask(file:///node_modules/@angular/core/fesm5/core.js:26247:0)
System.err:     at push.../node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js.ZoneDelegate.invokeTask(file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:420:0)
System.err:     at push.../node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js.Zone.runTask(file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:188:0)
System.err:     at push.../node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js.ZoneTask.invokeTask(file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:496:0)
System.err:     at ZoneTask.invoke(file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:485:0)
System.err:     at timer(file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:1561:0)
System.err:     at invoke(file:///node_modules/@nativescript/core/timer/timer.js:20:30)
System.err:     at push.../node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js.ZoneDelegate.invoke(file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:388:0)
System.err:     at onInvoke(file:///node_modules/@angular/core/fesm5/core.js:26256:0)
System.err:     at push.../node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js.ZoneDelegate.invoke(file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:387:0)
System.err:     at push.../node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js.Zone.runGuarded(file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:151:0)
System.err:     at (file:///node_modules/@nativescript/angular/zone-js/dist/zone-nativescript.js:129:0)
System.err:     at run(file:///node_modules/@nativescript/core/timer/timer.js:24:0)
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1160)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1138)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1134)
System.err:     at com.tns.gen.java.lang.Runnable.run(Runnable.java:17)
System.err:     at android.os.Handler.handleCallback(Handler.java:873)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
System.err:     at android.os.Looper.loop(Looper.java:193)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6715)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
System.err: Caused by: java.lang.IllegalStateException: Foreground dispatch can only be enabled when your activity is resumed
System.err:     at android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1352)
System.err:     ... 14 more

After some debugging, it turns out that the error occurred during Nfc instantiating: this.nfc = new Nfc();

I don't know if this is a known issue or something that can be fixed.

Thanks!

4.0.0 - Foreground dispatch can only be enabled when your activity is resumed

I've created a fresh repo for you to reproduce the bug.
https://github.com/rebz/nfc-demo-error

I used tns run android --bundle

I am referencing a previous issue as this is where it started for me: #37

With 3.0 I was able to import or require the package within the <script> tags of a component. However, after upgrading to ^4.0.0 I receive the following error even when pulling into the <script> tag. I am now unable to get the package to work using the standard NativeScript-Vue template:
vue init nativescript-vue/vue-cli-template <project-name>

JS: [Vue warn]: Error in created hook: "Error: java.lang.IllegalStateException: Foreground dispatch can only be enabled when your activity is resumed
JS:     android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1517)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1070)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1050)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1042)
JS:     com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)
JS:     android.app.Activity.performCreate(Activity.java:6942)
JS:     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
JS:     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
JS:     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
JS:     android.app.ActivityThread.-wrap14(ActivityThread.java)
JS:     android.app.ActivityThread$H.handleMessa...
System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.site.example/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: 
System.err: Calling js method onCreate failed
System.err: 
System.err: Error: java.lang.IllegalStateException: Foreground dispatch can only be enabled when your activity is resumed
System.err:     android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1517)
System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1070)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1050)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1042)
System.err:     com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)
System.err:     android.app.Activity.performCreate(Activity.java:6942)
System.err:     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
System.err:     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
System.err:     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
System.err:     android.app.ActivityThread.-wrap14(ActivityThread.java)
System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
System.err:     android.os.Handler.dispatchMessage(Handler.java:102)
System.err:     android.os.Looper.loop(Looper.java:154)
System.err:     android.app.ActivityThread.main(ActivityThread.java:6682)
System.err:     java.lang.reflect.Method.invoke(Native Method)
System.err:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1534)
System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1424)
System.err: File: "file:///data/data/com.site.example/files/app/vendor.js, line: 9670, column: 6
System.err: 
System.err: StackTrace: 
System.err:     Frame: function:'Nfc', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 462, column: 27
System.err:     Frame: function:'created', file:'file:///data/data/com.site.example/files/app/bundle.js', line: 421, column: 17
System.err:     Frame: function:'callHook', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10735, column: 21
System.err:     Frame: function:'Vue._init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18651, column: 5
System.err:     Frame: function:'VueComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18802, column: 12
System.err:     Frame: function:'createComponentInstanceForVnode', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18335, column: 10
System.err:     Frame: function:'init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18182, column: 45
System.err:     Frame: function:'createComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10911, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10860, column: 9
System.err:     Frame: function:'createChildren', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10998, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10883, column: 9
System.err:     Frame: function:'patch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 11468, column: 7
System.err:     Frame: function:'Vue._update', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10481, column: 19
System.err:     Frame: function:'updateComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10590, column: 10
System.err:     Frame: function:'get', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9665, column: 25
System.err:     Frame: function:'Watcher', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9652, column: 45
System.err:     Frame: function:'mountComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10596, column: 3
System.err:     Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19189, column: 10
System.err:     Frame: function:'init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18183, column: 13
System.err:     Frame: function:'createComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10911, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10860, column: 9
System.err:     Frame: function:'createChildren', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10998, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10883, column: 9
System.err:     Frame: function:'createChildren', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10998, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10883, column: 9
System.err:     Frame: function:'patch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 11468, column: 7
System.err:     Frame: function:'Vue._update', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10481, column: 19
System.err:     Frame: function:'updateComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10590, column: 10
System.err:     Frame: function:'get', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9665, column: 25
System.err:     Frame: function:'Watcher', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9652, column: 45
System.err:     Frame: function:'mountComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10596, column: 3
System.err:     Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19189, column: 10
System.err:     Frame: function:'init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18183, column: 13
System.err:     Frame: function:'createComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10911, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10860, column: 9
System.err:     Frame: function:'patch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 11468, column: 7
System.err:     Frame: function:'Vue._update', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10481, column: 19
System.err:     Frame: function:'updateComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10590, column: 10
System.err:     Frame: function:'get', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9665, column: 25
System.err:     Frame: function:'Watcher', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9652, column: 45
System.err:     Frame: function:'mountComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10596, column: 3
System.err:     Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19189, column: 10
System.err:     Frame: function:'init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18183, column: 13
System.err:     Frame: function:'createComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10911, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10860, column: 9
System.err:     Frame: function:'createChildren', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10998, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10883, column: 9
System.err:     Frame: function:'patch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 11468, column: 7
System.err:     Frame: function:'Vue._update', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10481, column: 19
System.err:     Frame: function:'updateComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10590, column: 10
System.err:     Frame: function:'get', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9665, column: 25
System.err:     Frame: function:'Watcher', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9652, column: 45
System.err:     Frame: function:'mountComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10596, column: 3
System.err:     Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19189, column: 10
System.err:     Frame: function:'init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18183, column: 13
System.err:     Frame: function:'createComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10911, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10860, column: 9
System.err:     Frame: function:'patch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 11468, column: 7
System.err:     Frame: function:'Vue._update', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10481, column: 19
System.err:     Frame: function:'updateComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10590, column: 10
System.err:     Frame: function:'get', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9665, column: 25
System.err:     Frame: function:'Watcher', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9652, column: 45
System.err:     Frame: function:'mountComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10596, column: 3
System.err:     Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19189, column: 10
System.err:     Frame: function:'', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19205, column: 10
System.err:     Frame: function:'Observable.notify', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 23740, column: 15
System.err:     Frame: function:'notifyLaunch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 46149, column: 15
System.err:     Frame: function:'ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 46072, column: 20
System.err:     Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 45877, column: 10
System.err:     Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 43104, column: 21
System.err: 
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
System.err:     at android.app.ActivityThread.-wrap14(ActivityThread.java)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
System.err:     at android.os.Looper.loop(Looper.java:154)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6682)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1534)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1424)
System.err: Caused by: com.tns.NativeScriptException: 
System.err: Calling js method onCreate failed
System.err: 
System.err: Error: java.lang.IllegalStateException: Foreground dispatch can only be enabled when your activity is resumed
System.err:     android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1517)
System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1070)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1050)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1042)
System.err:     com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)
System.err:     android.app.Activity.performCreate(Activity.java:6942)
System.err:     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
System.err:     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
System.err:     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
System.err:     android.app.ActivityThread.-wrap14(ActivityThread.java)
System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
System.err:     android.os.Handler.dispatchMessage(Handler.java:102)
System.err:     android.os.Looper.loop(Looper.java:154)
System.err:     android.app.ActivityThread.main(ActivityThread.java:6682)
System.err:     java.lang.reflect.Method.invoke(Native Method)
System.err:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1534)
System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1424)
System.err: File: "file:///data/data/com.site.example/files/app/vendor.js, line: 9670, column: 6
System.err: 
System.err: StackTrace: 
System.err:     Frame: function:'Nfc', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 462, column: 27
System.err:     Frame: function:'created', file:'file:///data/data/com.site.example/files/app/bundle.js', line: 421, column: 17
System.err:     Frame: function:'callHook', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10735, column: 21
System.err:     Frame: function:'Vue._init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18651, column: 5
System.err:     Frame: function:'VueComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18802, column: 12
System.err:     Frame: function:'createComponentInstanceForVnode', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18335, column: 10
System.err:     Frame: function:'init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18182, column: 45
System.err:     Frame: function:'createComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10911, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10860, column: 9
System.err:     Frame: function:'createChildren', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10998, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10883, column: 9
System.err:     Frame: function:'patch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 11468, column: 7
System.err:     Frame: function:'Vue._update', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10481, column: 19
System.err:     Frame: function:'updateComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10590, column: 10
System.err:     Frame: function:'get', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9665, column: 25
System.err:     Frame: function:'Watcher', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9652, column: 45
System.err:     Frame: function:'mountComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10596, column: 3
System.err:     Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19189, column: 10
System.err:     Frame: function:'init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18183, column: 13
System.err:     Frame: function:'createComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10911, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10860, column: 9
System.err:     Frame: function:'createChildren', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10998, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10883, column: 9
System.err:     Frame: function:'createChildren', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10998, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10883, column: 9
System.err:     Frame: function:'patch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 11468, column: 7
System.err:     Frame: function:'Vue._update', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10481, column: 19
System.err:     Frame: function:'updateComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10590, column: 10
System.err:     Frame: function:'get', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9665, column: 25
System.err:     Frame: function:'Watcher', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9652, column: 45
System.err:     Frame: function:'mountComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10596, column: 3
System.err:     Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19189, column: 10
System.err:     Frame: function:'init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18183, column: 13
System.err:     Frame: function:'createComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10911, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10860, column: 9
System.err:     Frame: function:'patch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 11468, column: 7
System.err:     Frame: function:'Vue._update', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10481, column: 19
System.err:     Frame: function:'updateComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10590, column: 10
System.err:     Frame: function:'get', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9665, column: 25
System.err:     Frame: function:'Watcher', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9652, column: 45
System.err:     Frame: function:'mountComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10596, column: 3
System.err:     Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19189, column: 10
System.err:     Frame: function:'init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18183, column: 13
System.err:     Frame: function:'createComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10911, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10860, column: 9
System.err:     Frame: function:'createChildren', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10998, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10883, column: 9
System.err:     Frame: function:'patch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 11468, column: 7
System.err:     Frame: function:'Vue._update', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10481, column: 19
System.err:     Frame: function:'updateComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10590, column: 10
System.err:     Frame: function:'get', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9665, column: 25
System.err:     Frame: function:'Watcher', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9652, column: 45
System.err:     Frame: function:'mountComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10596, column: 3
System.err:     Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19189, column: 10
System.err:     Frame: function:'init', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 18183, column: 13
System.err:     Frame: function:'createComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10911, column: 9
System.err:     Frame: function:'createElm', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10860, column: 9
System.err:     Frame: function:'patch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 11468, column: 7
System.err:     Frame: function:'Vue._update', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10481, column: 19
System.err:     Frame: function:'updateComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10590, column: 10
System.err:     Frame: function:'get', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9665, column: 25
System.err:     Frame: function:'Watcher', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 9652, column: 45
System.err:     Frame: function:'mountComponent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 10596, column: 3
System.err:     Frame: function:'push.../node_modules/nativescript-vue/dist/index.js.Vue.$mount', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19189, column: 10
System.err:     Frame: function:'', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 19205, column: 10
System.err:     Frame: function:'Observable.notify', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 23740, column: 15
System.err:     Frame: function:'notifyLaunch', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 46149, column: 15
System.err:     Frame: function:'ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 46072, column: 20
System.err:     Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 45877, column: 10
System.err:     Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/com.site.example/files/app/vendor.js', line: 43104, column: 21
System.err: 
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1070)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1050)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1042)
System.err:     at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)
System.err:     at android.app.Activity.performCreate(Activity.java:6942)
System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
System.err:     ... 9 more
System.err: Caused by: java.lang.IllegalStateException: Foreground dispatch can only be enabled when your activity is resumed
System.err:     at android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1517)
System.err:     ... 19 more
Successfully synced application com.site.example on device 0915f9d4542e2a03.

Not fire on nativescript vue

Hi guys,
I have installed this plugin but the only methods that work are available and enabled.
This is my code on the mounted event:

            var nfc = new Nfc();

            nfc.available().then((avail) => {
                console.log(avail ? "Yes" : "No");
            });

            nfc.enabled().then((on) => {
                console.log(on ? "Yes" : "No");
            });
 

            nfc.setOnNdefDiscoveredListener(function(data) {
                if (data.message) {
                    for (let m in data.message) {
                    let record = data.message[m];
                    console.log("Ndef discovered! Message record: " + record.payloadAsString);
                    }
                }
                }).then(
                function() {
                    console.log("OnNdefDiscovered listener added");
                }
            );

            nfc.setOnTagDiscoveredListener(function(data) {
                console.log("Discovered a tag with ID " + data.id);
            }).then(function() {
                console.log("OnTagDiscovered listener added");
                }
            );

I declare NFC as:
import { Nfc } from "nativescript-nfc"

No errors and only logs on available and enabled on real android device but no read a mifare card.

Any suggest?
Thanks, P

setOnNdefDiscoveredListener callback is not invoked on main thread in iOS

In iOS setOnNdefDiscoveredListener callback not seems to be invoked on main thread due to which updating UI elements / changeDetectorRef.detectChanges() in angular app doesn't work.

A workaround was using a Promise.resolve().then(()=>{}) inside callback, but fixing this in the plugin will make it parity with Android.

Cannot detect tag - no response

Hi there,

I used the plugin in a sample demo app i have. However, i cannot get any response from either 2 methods:

public doStartNdefListener() {
this.nfc.setOnNdefDiscoveredListener((data: NfcNdefData) => {
if (data.message) {
let tagMessages = [];
// data.message is an array of records, so:
data.message.forEach(record => {
console.log("Read record: " + JSON.stringify(record));
tagMessages.push(record.payloadAsString);
});
this.set("lastNdefDiscovered", "Read: " + tagMessages.join(", "));
}
}, {
stopAfterFirstRead: true,
scanHint: "Scan a tag, baby!"
})
.then(() => this.set("lastNdefDiscovered", "Listening..."))
.catch(err => alert(err));
}

public doStartTagListener() {
let that = this;
this.nfc.setOnTagDiscoveredListener((data: NfcTagData) => {
console.log("Tag discovered! " + data.id);
that.set("lastTagDiscovered", data.id);
}).then(() => {
console.log("OnTagDiscovered Listener set");
}, (err) => {
console.log(err);
});
}

I verified with an app called NFC tools, the tag info were read instanteneously. Any idea?

Remove our custom activity because it's no longer needed (since NativeScript 5.4.0)

NativeScript 5.4.0 introduced a "new intent" event (actually added by yours truly) so we no longer need to override the NativeScript activity by our own. This makes setting up this plugin much easier and foolproof, and also Webpack compatibility is easier now (read: no longer an issue at all).

This is a breaking change, so will bump to a new major version because of this.

Angular Demo from local plugin won't scan tag

Scanning works from the official plugin but not from the local one. It doesn't find the tag and keeps waiting until times out.

Code: https://github.com/demetrius-tech/nativescript-nfc/tree/demo-ng2

I run manually:

cd src
npm run build
cd ../demo-ng2
tns plugin add ../src
tns run ios --for-device --team-id

Log snapshot:

Initializing connection
Removing all cached process handles
Sending handshake request attempt #1 to server
Creating connection to com.apple.runningboard
Handshake succeeded
Identity resolved as application<tech.demetrius.dev.nfc>
CONSOLE INFO file: node_modules/nativescript-dev-webpack/hot.js:3:0: HMR: Hot Module Replacement Enabled. Waiting for signal.
FBSWorkspace connecting to endpoint :
FBSWorkspace registering source:
FBSWorkspace connected to endpoint :
Added observer for process assertions expiration warning: <_RBSExpirationWarningAssertion: 0x283228c40; identifier: com.apple.runningboardservices.processExpirationWarningForHandle; reason: observation; valid: YES>
Retrieving resting unlock: 0
Registering for test daemon availability notify post.
notify_get_state check indicated test daemon not ready.
FBSWorkspace already connected to endpoint :
CONSOLE LOG file: node_modules/@angular/core/fesm5/core.js:25638:0: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
HTHangEventCreate: HangTracing is disabled. Not creating a new event.
Successfully run application tech.demetrius.dev.nfc on device with ID .
CONSOLE LOG file: src/Users/demetrius.tech/dev/nativescript-nfc/master/nativescript-nfc/src/nfc.ios.ts:57:18: here
Received configuration update from daemon (initial)
NativeScript debugger has opened inspector socket on port 18183 for tech.demetrius.dev.nfc.
Successfully synced application tech.demetrius.dev.nfc on device .
CONSOLE LOG file: node_modules/@nativescript/core/inspector_modules.ios.js:1:0: Loading inspector modules...
CONSOLE LOG file: node_modules/@nativescript/core/inspector_modules.ios.js:6:0: Finished loading inspector modules.
NativeScript debugger attached.
HTHangEventCreate: HangTracing is disabled. Not creating a new event.

card emulation

is any tutorial for card emulation of device ?
thx for advance

Cannot find namespace 'android'

after type in console tns run I'm getting this error:

ERROR in node_modules/nativescript-nfc/nfc.android.d.ts:3:18 - error TS2503: Cannot find namespace 'android'.

3     savedIntent: android.content.Intent;
                   ~~~~~~~
node_modules/nativescript-nfc/nfc.android.d.ts:11:22 - error TS2503: Cannot find namespace 'android'.

11     ndefToJSON(ndef: android.nfc.tech.Ndef): NfcNdefData;
                        ~~~~~~~
node_modules/nativescript-nfc/nfc.android.d.ts:12:28 - error TS2503: Cannot find namespace 'android'.

12     messageToJSON(message: android.nfc.NdefMessage): Array<NfcNdefRecord>;
                              ~~~~~~~
node_modules/nativescript-nfc/nfc.android.d.ts:13:26 - error TS2503: Cannot find namespace 'android'.

13     recordToJSON(record: android.nfc.NdefRecord): NfcNdefRecord;
                            ~~~~~~~

I'm working on Android Emulator, in Nativescript Angular

callback not get called when detect nfc

callback not getting called, when nfc detected. the device play the sound but nothing is happening ...

`
import { Injectable } from "@angular/core";
import { Nfc, NfcNdefData, NfcTagData } from "nativescript-nfc";
import { Subject } from "rxjs";

@Injectable({
providedIn: 'root'
})
export class NfcReaderService {
nfcData = new Subject();

private nfc: Nfc = new Nfc();

constructor() {
    this.nfc.available().then((avail) => {
        this.nfc.enabled().then((on) => {
            if (on) {
                console.log("NFC Enabled!!!");
                this.readNFC();
                this.onTagDiscoverd();
            } else {
                console.log("NFC Not Enabled");
            }
        });
    });
}

public readNFC() {
    this.nfc.setOnNdefDiscoveredListener((data: NfcNdefData) => {
        console.log("Nfc Data: ", data);
        this.nfcData.next(data);
        if (data.message) {
            for (let m in data.message) {
                let record = data.message[m];
                console.log("Ndef discovered! Message record: " + record.payloadAsString);
            }
        }
    }, {
            stopAfterFirstRead: false,
            scanHint: "Scan a tag, baby!"
        }).then(() => {
            console.log("OnNdefDiscovered listener added");
        });
}


public onTagDiscoverd() {
    this.nfc.setOnTagDiscoveredListener((data: NfcTagData) => {
        console.log("Discovered a tag with ID " + data.id);
    }).then(() => {
        console.log("OnTagDiscovered listener added");
    });
}

}

`

tns run android --bundle error with tns-android 5.2.1

Hi, i have a problem with plugin.
I was create tns create nfc-demo with Angular then install plugin tns plugin add nativescript-nfc
Added data to monifest and webpack.config and run tns run android --bundle

don't understand how import android to nfc.android.d.ts

ERROR in node_modules/nativescript-nfc/nfc.android.d.ts(3,18): error TS2503: Cannot find namespace 'android'.
node_modules/nativescript-nfc/nfc.android.d.ts(11,22): error TS2503: Cannot find namespace 'android'.
node_modules/nativescript-nfc/nfc.android.d.ts(12,28): error TS2503: Cannot find namespace 'android'.
node_modules/nativescript-nfc/nfc.android.d.ts(13,26): error TS2503: Cannot find namespace 'android'.

Android: Cannot read property getClass of undefined

Works perfectly fine on iOS, the moment I attempt to build for android the application refuses to launch. No matter how I try to import or require your package, I get the error; Cannot read property getClass of undefined. I saw another github issue opened for this, but no solution was made present.

The only way I got it to work was by requiring the package within the script tag of a component. Unfortunately, that is not a solution as I need to access the Nfc on app load, before components load... that and I shouldn't have to limit myself to a component script tag to use a package.

I have been banging my head against a wall for days trying to get this to work. I am not using TypeScript and I see that your demo is... is there perhaps something you're doing with your build that is causing issues in non-TypeScript projects?

Unsure how to move forward.

Support for NTAG424 and NTAG413?

Hey,

Thanks for your plugin, much appreciated.
I have 1 question regarding support types, is it possible to make this plugin work with NTAG424 and/or NTAG413?
Where you can have predefined "DNA" to make sure that nobody else can read it, only if you have the security code to unlock the data.

Greetings,
Cherimos

IllegalStateException when pausing app after new Nfc()

On android, in the Nfc constructor, you are delaying the initialisation of the adapter with a setTimeout of 3 seconds.
This is causing an IllegalStateException if you pause the app between these 3 seconds.

I can't seem to find a way to catch this error, any idea?

--
By the way, I get this because I try to ask the user to enable NFC in the settings (and it would be a good idea to explain this part in your doc if you have a little time).

--
EDIT: Right now, to avoid the bug, I have removed the setTimeout from your code and I always instantiate the nfc handler inside of a page, only if needed.

Nativescript 3.4 Ng 5.* compatibility

Hi Eddy,

sorry to disturb in this holiday season, but it seems after I update my tns to 3.4, nativescript nfc is now broken.

So I tried to create new project using tns create sample --ng, modify the sample page to looks like this, and got error.

It seems that we can not access application.android.foregroundActivity in NS 3.4

template

<StackLayout class="page">
    <Button text="scan nfc" (tap)="addNfcListener()"></Button>
</StackLayout>

component

export class ItemsComponent implements OnInit {
    items: Item[];
    nfc: Nfc;

    // This pattern makes use of Angular’s dependency injection implementation to inject an instance of the ItemService service into this class.
    // Angular knows about this service because it is included in your app’s main NgModule, defined in app.module.ts.
    constructor(private itemService: ItemService) {
        this.nfc = new Nfc;
    }

    ngOnInit(): void {
        this.items = this.itemService.getItems();
    }

    addNfcListener() {
        this.nfc.setOnNdefDiscoveredListener((data: NfcNdefData) => {
            if (data.message) {
                const records = [];

                data.message.forEach((record) => {
                    records.push(record.payloadAsString);
                });

                this.nfc.setOnNdefDiscoveredListener(null).then(() => {
                    dialogs.alert(records[0]);
                });
            }
        }, {stopAfterFirstRead: true}).then(() => {
            dialogs.alert('listener stopped');
        }, (err) => {
            dialogs.alert(err);
        });
    }
}

error

JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'getClass' of undefined
JS: TypeError: Cannot read property 'getClass' of undefined
JS:     at new Nfc (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/nativescript-nfc/nfc.js:268:127)
JS:     at new ItemsComponent (file:///data/data/org.nativescript.nsnfcdemo/files/app/item/items.component.js:12:20)
JS:     at createClass (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/core/bundles/core.umd.js:12204:20)
JS:     at createDirectiveInstance (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/core/bundles/core.umd.js:12051:37)
JS:     at createViewNodes (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/core/bundles/core.umd.js:13489:53)
JS:     at createRootView (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/core/bundles/core.umd.js:13379:5)
JS:     at callWithDebugContext (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/core/bundles/core.umd.js:14780:42)
JS:     at Object.debugCreateRootView [as createRootView] (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/core/bundles/core.umd.js:14081:12)
JS:     at ComponentFactory_.create (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/core/bundles/core.umd.js:11000:46)
JS:     at ComponentFactoryBoundToModule.create (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/core/bundles/core.umd.js:3961:29)
JS:     at ViewContainerRef_.createComponent (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/core/bundles/core.umd.js:11197:62)
JS:     at PageRouterOutlet.activateOnGoForward (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/nativescript-angular/router/page-router-outlet.js:246:44)
JS:     at PageRouterOutlet.activateWith (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/nativescript-angular/router/page-router-outlet.js:235:14)
JS:     at ActivateRoutes.activateRoutes (file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/router/bundles/router.umd.js:5652:40)
JS:     at file:///data/data/org.nativescript.nsnfcdemo/files/app/tns_modules/@angular/router/bundles/router.umd.js:5592:19

Cannot add plugin for local build

Hi,

OS: MacOS
NativeScript: latest (platforms: 6.5.1, tns-core-modules: 6.5.5)

I am trying to add the plugin from an NativeScript angular project:

tns plugin add ../src

and it throws the following error on build:

tns build ios
Preparing project...
Hash: 6d5d3e256f940282df6d
Version: webpack 4.27.1
Time: 6805ms
Built at: 06/15/2020 21:32:52
4 assets
Entrypoint bundle = runtime.js vendor.js bundle.js
Entrypoint tns_modules/tns-core-modules/inspector_modules = runtime.js vendor.js tns_modules/tns-core-modules/inspector_modules.js
[../$$_lazy_route_resource lazy recursive] ../$$_lazy_route_resource lazy namespace object 160 bytes {bundle} [built]
[../../src/nfc.ts] /Users/demetrius.tech/dev/nativescript/nativescript-nfc/src/nfc.ts 927 bytes {bundle} [built] [failed] [1 error]
[./app.css] 1.57 KiB {bundle} [built]
[./app/app-routing.module.ts] 647 bytes {bundle} [built]
[./app/app.component.html] 167 bytes {bundle} [built]
[./app/app.component.ts] 379 bytes {bundle} [built]
[./app/app.module.ts] 1.39 KiB {bundle} [built]
[./app/main/main.component.html] 651 bytes {bundle} [built]
[./app/main/main.component.ts] 4.27 KiB {bundle} [built]
[./main.ts] 1.67 KiB {bundle} [built]
[./package.json] 100 bytes {bundle} {tns_modules/tns-core-modules/inspector_modules} [optional] [built]
+ 600 hidden modules

ERROR in /Users/demetrius.tech/dev/nativescript/nativescript-nfc/src/nfc.ts
Module build failed (from ../node_modules/@ngtools/webpack/src/index.js):
Error: /Users/demetrius.tech/dev/nativescript/nativescript-nfc/src/nfc.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.

at NativeScriptAngularCompilerPlugin.getCompiledFile (/Users/demetrius.tech/dev/nativescript/nativescript-nfc/demo-ng/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:933:23)
at NativeScriptAngularCompilerPlugin.getCompiledFile (/Users/demetrius.tech/dev/nativescript/nativescript-nfc/demo-ng/node_modules/nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin.js:28:26)
at /Users/demetrius.tech/dev/nativescript/nativescript-nfc/demo-ng/node_modules/@ngtools/webpack/src/loader.js:41:31
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:97:5)
@ ./app/main/main.component.ts 3:0-39 9:24-27
@ ./app/app.module.ts
@ ./main.ts
Executing webpack failed with exit code 2.

It works adding the nativescript-nfc plugin from the repository.

Question: iOS support

Are you planning to add iOS support for the remaining functions that are android only?

I'm particularly interested in the writeTag function

Not compatible with nativescript 5.0.0

App crashes at startup, probably because they switched to FragmentActvity?

Event: activityResumed, Activity: com.tns.NativeScriptNfcActivity@1ed9f66 System.err: com.tns.NativeScriptException: System.err: Calling js method onViewAttachedToWindow failed System.err: System.err: TypeError: this._context.getSupportFragmentManager is not a function System.err: File: "file:///data/data/com.ibm.hrl.workright/files/app/tns_modules/tns-core-modules/ui/core/view/view.js, line: 190, column: 46 System.err: System.err: StackTrace: System.err: Frame: function:'View._getRootFragmentManager', file:'file:///data/data/com.ibm.hrl.workright/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 190, column: 47 System.err: Frame: function:'View._getFragmentManager', file:'file:///data/data/com.ibm.hrl.workright/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 215, column: 32 System.err: Frame: function:'Frame._processNextNavigationEntry', file:'file:///data/data/com.ibm.hrl.workright/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 134, column: 28 System.err: Frame: function:'Frame._onAttachedToWindow', file:'file:///data/data/com.ibm.hrl.workright/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 118, column: 14 System.err: Frame: function:'AttachListener.onViewAttachedToWindow', file:'file:///data/data/com.ibm.hrl.workright/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 35, column: 27 System.err: System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116) System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:996) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:983) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:967) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:959) System.err: at com.tns.gen.java.lang.Object_frame_29_36_AttachListener.onViewAttachedToWindow(Object_frame_29_36_AttachListener.java:17) System.err: at android.view.View.dispatchAttachedToWindow(View.java:15568) System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2955) System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2962) System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2962) System.err: at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2962) System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1656) System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1372) System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6774) System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:926) System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:735) System.err: at android.view.Choreographer.doFrame(Choreographer.java:667) System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:912) System.err: at android.os.Handler.handleCallback(Handler.java:761) System.err: at android.os.Handler.dispatchMessage(Handler.java:98) System.err: at android.os.Looper.loop(Looper.java:156) System.err: at android.app.ActivityThread.main(ActivityThread.java:6523) System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)

Always not fire

Hi,

I testing in a real device (SONY Xperia1 - Android 7)
tns version = 4.0.0

I just execute following code, I got message "OnNdefDiscovered listener added!".
But tap the NFC tag to testing, Always can't fire the block to processing the data. (Can't see "Fire me!!!").

What wrong the code?

nfc.setOnNdefDiscoveredListener(function(data){
console.log('Fire me!!!');
}).then(()=>{
console.log("OnNdefDiscovered listener added!");
});

And, nfc.available() and nfc.enabled() is return true.

Thank you
Willow

Android Demo do not detect nfc tags

This plugin seemed promising to me, but unfortunately I am not able to make it work.

I have a Samsung Galaxy A3.
I am using the following type of nfc tag: Link
I have use the command npm run test.android. The app builds correctly and appear loads on the device.
Button nfc avaiable and enables work (show true when activated, false otherwise).
But neither set ndef listener, nor set tag listener seem to detect my nfc tags.

Moreover I also noticed that the image having the text 'ready to scan' on yout github and on your video with the iphone, does not appear.

All others application on the market detect those nfc tags, but your demo was not able.

Is there anything I am doing wrong?

Support for isodep contactless cards

Hello,
Thanks for this library.
Does this library support isodep and iso 14443 type A cards, for example desfire cards
And for example mifare ultralight cards? Support read write these cards?

Question: Open NS app when NFC Tag read

Hey!
first of all, happy birthday @EddyVerbruggen 🎂

Is it possible to let Android start my NativeScript app when a NFC-Tag has been detected? Especially, a tag written by me using nativescript-nfc?

What I tried
Adding the following to AndroidManifest.xml within activity

<intent-filter>
  <action android:name="android.nfc.action.NDEF_DISCOVERED" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:scheme="vnd.android.nfc" android:host="ext" android:pathPrefix="/de.ketrwu.appname:customtype" />
</intent-filter>

Writing on a tag using:

this.nfc.writeTag({
    textRecords: [
        {
            id: [1],
            text: "some payload to identify tag"
        },
        {
            id: [2],
            text: "de.ketrwu.appname:customtype"
        }
    ]
});

I also tried various variations and methods I found online. But maybe I miss something.

My setup

  • Android: v8.1 (API Level 27)
  • nativescript-angular: v5.3.0
  • nativescript-nfc: v2.1.2

Thanks 😃

Listeners do not work on Angular w/ Android

Problem:
setOnTagDiscoveredListener and setOnNdefDiscoveredListener do not call their callbacks when scanning their respective tags.
Versions:

"nativescript": {
        "id": "org.nativescript.SurvivalRunApp",
        "tns-android": {
            "version": "5.2.1"
        },
        "tns-ios": {
            "version": "5.0.0"
        }
    },
    "dependencies": {
        "@angular/animations": "~7.0.0",
        "@angular/common": "~7.0.0",
        "@angular/compiler": "~7.0.0",
        "@angular/core": "~7.0.0",
        "@angular/forms": "~7.0.0",
        "@angular/http": "~7.0.0",
        "@angular/platform-browser": "~7.0.0",
        "@angular/platform-browser-dynamic": "~7.0.0",
        "@angular/router": "~7.0.0",
        "nativescript-angular": "~7.0.0",
        "nativescript-nfc": "^3.0.1",
        "nativescript-theme-core": "~1.0.4",
        "reflect-metadata": "~0.1.8",
        "rxjs": "~6.3.0",
        "tns-core-modules": "~5.0.2",
        "tns-platform-declarations": "^5.2.1",
        "zone.js": "^0.8.26"
    },
    "devDependencies": {
        "@nativescript/schematics": "~0.4.0",
        "nativescript-dev-typescript": "~0.7.0",
        "nativescript-dev-webpack": "~0.18.0",
        "@angular/compiler-cli": "~7.1.0",
        "@ngtools/webpack": "~7.1.0"
    },

app.component.ts:

constructor() {
        android.on(AndroidApplication.activityResumedEvent, (args: AndroidActivityEventData) => {
            // Does log
            console.log("Event: " + args.eventName + ", Activity: " + args.activity);

            if (!this.nfc) {
                // Gets executed once
                this.nfc = new Nfc();

                // Does log
                this.nfc.available().then((avail) => console.log("NFC is " + (avail ? '' : 'not ') + 'available'));
                // Does log
                this.nfc.enabled().then((isOn) => console.log("NFC is " + (isOn ? '' : 'not ') + 'on'));

                this.nfc.setOnTagDiscoveredListener((data: NfcTagData) => {
                    // Does NOT log
                    console.log("Discovered a tag with ID " + data.id);
                }).then(() => {
                    // Does Log
                    console.log("OnTagDiscovered listener added");
                });

                this.nfc.setOnNdefDiscoveredListener((data: NfcNdefData) => {
                    // Does NOT log
                    console.log("Discovered a tag with ID " + data.id);
                }).then(() => {
                    // Does log
                    console.log("OnNdef listener added");
                });
            }
        });
    }

Note:
nfc.available() and nfc.enabled() do return their values correctly.
When scanning a tag, AndroidApplication.activityResumedEvent gets called everytime.

Things i've already tried:

  • Uninstalling/Installing everything.
  • Trying previous versions of nativescript-nfc and nativescript.
  • Using the constructor to init the Nfc class, which results the same error as: #13 (comment)

How to write service?

I can't get routerExtension inside callback when i write service

component:

`
@component({
selector: 'app-sporttrack',
templateUrl: './sporttrackSearch.component.html',
styleUrls: ['./sporttrack.component.scss']
})
export class SporttrackSearchComponent implements OnInit, OnDestroy {
constructor(public routerExtensions: RouterExtensions, private nfc: SporttrackNfcService, public zone: NgZone) {
}

ngOnInit(): void {
    this.nfc.doStartTagListener.bind(this)
    this.nfc.doStartTagListener(this.searchAthlet).then(() => console.log(this))
}

ngOnDestroy(): void {
    this.nfc.doStopTagListener()
}

searchAthlet(data: NfcTagData) {
    this.routerExtensions.navigate(['sporttrack', athlet.phone])
}

}

`
service

`
@Injectable({
providedIn: 'root'
})
export class SporttrackNfcService {
nfc: Nfc

constructor() {
    this.nfc = new Nfc()
}

doStartTagListener(fn: (data: NfcTagData) => any): Promise<any> {
    return this.nfc.setOnTagDiscoveredListener((data: NfcTagData) => {
        console.dir(data, this.nfc)
        console.log('Tag discovered sporttrack scan! ' + JSON.stringify(data))
        fn(data)
    }).then(() => {
        console.log('OnTagDiscovered Listener set')
    }, (err) => {
        console.log(err)
    })
}

doStopTagListener() {
    this.nfc.setOnTagDiscoveredListener(null).then(() => {
        console.log('OnTagDiscovered nulled')
    }, (err) => {
        console.log(err)
    })
}

}

`

ERROR
`

Tag discovered sporttrack scan! {"id":[4,72,-37,26,-32,95,-127],"techList":["android.nfc.tech.NfcA","android.nfc.tech.MifareUltralight","android.nfc.tech.NdefFormatable"]}
JS: 123
JS: Unhandled Promise rejection: Cannot read property 'routerExtensions' of undefined ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot read property 'routerExtensions' of undefined TypeError: Cannot read property 'routerExtensions' of undefined
JS: at file:///src/app/sporttrack/sporttrack.component.ts:243:21
JS: at file:///node_modules/nativescript-plugin-firebase/firebase.js:2348:51
JS: at Array.map ()
JS: at QuerySnapshot.push.../node_modules/nativescript-plugin-firebase/firebase.js.QuerySnapshot.forEach file:///node_modules/nativescript-plugin-firebase/firebase.js:2348:0
JS: at file:///src/app/sporttrack/sporttrack.component.ts:241:21
JS:

`

Error UnhandledPromiseRejectionWarning and NFC permission required

Hello. I asked a question on stackoverflow where I got told I should open an issue on github, sorry for not opening an issue here.
I'm currently working on a project I have to read/write NFC tags with a Samsung Tablet which supports NFC.

I simply created a new project based on Vue.Js with NativeScript Sidekick and installed the nativescript-nfc.

I first of all implemented a method which executes the available function of the plugin, which returns 'yes'. After that I'm getting the error that the NFC permission is required.

I tried to change the Manifest file to let the user ask for the permissions but somehow I couldn't make it work. (Most probably the reason will be that it's not possible on LiveSync? I'm new to NativeScript sorry.)

I get these logs on my device console:

LOG from device Galaxy Tab Active2: ''NativeScript-Vue has "Vue.config.silent" set to true, to see output logs set it to false.''
LOG from device Galaxy Tab Active2: ''Yes''
LOG from device Galaxy Tab Active2: An uncaught Exception occurred on "main" thread.
Calling js method run failed
Error: java.lang.SecurityException: NFC permission required: Neither user 10155 nor current process has android.permission.NFC.
android.os.Parcel.readException(Parcel.java:2029)
android.os.Parcel.readException(Parcel.java:1975)
android.nfc.INfcAdapter$Stub$Proxy.setForegroundDispatch(INfcAdapter.java:1012)
android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1648)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
com.tns.Runtime.callJSMethod(Runtime.java:1109)
com.tns.Runtime.callJSMethod(Runtime.java:1089)
com.tns.Runtime.callJSMethod(Runtime.java:1081)
com.tns.gen.java.lang.Runnable.run(Runnable.java:17)
android.os.Handler.handleCallback(Handler.java:790)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:164)
android.app.ActivityThread.main(ActivityThread.java:7000)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

StackTrace:
Frame: function:'', file:'file:///data/data/org.nativescript.preview/files/app/vendor.js', line: 672, column: 31
Frame: function:'invoke', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/timer/timer.js', line: 19, column: 45
Frame: function:'run', file:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/timer/timer.js', line: 23, column: 7
at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
at com.tns.Runtime.callJSMethod(Runtime.java:1109)
at com.tns.Runtime.callJSMethod(Runtime.java:1089)
at com.tns.Runtime.callJSMethod(Runtime.java:1081)
at com.tns.gen.java.lang.Runnable.run(Runnable.java:17)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.SecurityException: NFC permission required: Neither user 10155 nor current process has android.permission.NFC.
at android.os.Parcel.readException(Parcel.java:2029)
at android.os.Parcel.readException(Parcel.java:1975)
at android.nfc.INfcAdapter$Stub$Proxy.setForegroundDispatch(INfcAdapter.java:1012)
at android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1648)
... 14 more

and these errors are on the errors section:

[19-08-02 15:27:52.337] (CLI) (node:18276) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'hash' of null
at PreviewAppController. (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:130:64)
at Generator.next ()
at fulfilled (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:10:58)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
at emitWarning (internal/process/promises.js:99:15)
at processPromiseRejections (internal/process/promises.js:140:9)
at processTicksAndRejections (internal/process/next_tick.js:82:32)
[19-08-02 15:27:52.340] (CLI) (node:18276) TypeError: Cannot read property 'hash' of null
at PreviewAppController. (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:130:64)
at Generator.next ()
at fulfilled (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:10:58)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
(node:18276) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:113:13)
at emitWarning (internal/process/promises.js:106:3)
at processPromiseRejections (internal/process/promises.js:140:9)
at processTicksAndRejections (internal/process/next_tick.js:82:32)
[19-08-02 15:32:26.783] (CLI) (node:18276) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'hash' of null
at PreviewAppController. (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:130:64)
at Generator.next ()
at fulfilled (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:10:58)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
at emitWarning (internal/process/promises.js:99:15)
at processPromiseRejections (internal/process/promises.js:140:9)
at processTicksAndRejections (internal/process/next_tick.js:82:32)
(node:18276) TypeError: Cannot read property 'hash' of null
at PreviewAppController. (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:130:64)
at Generator.next ()
at fulfilled (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:10:58)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
[19-08-02 15:32:57.564] (CLI) (node:18276) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'hash' of null
at PreviewAppController. (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:130:64)
at Generator.next ()
at fulfilled (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:10:58)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
at emitWarning (internal/process/promises.js:99:15)
at processPromiseRejections (internal/process/promises.js:140:9)
at processTicksAndRejections (internal/process/next_tick.js:82:32)
(node:18276) TypeError: Cannot read property 'hash' of null
at PreviewAppController. (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:130:64)
at Generator.next ()
at fulfilled (C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:10:58)
at processTicksAndRejections (internal/process/next_tick.js:81:5)

I would be really glad if you guys could help me solving these issues. Thank you in advance.

Webpack Issues Angular

When i am installing the plugin and running webpack command i am getting the following error

`Execution failed for task ':asbg:generateBindings'.

Process 'command 'C:\Program Files\Java\jdk1.8.0_144\bin\java.exe'' finished with non-zero exit value 1
`

What could be the issue?? and how can I make it work??

Can not write to tag; didn't receive an intent

When I try to write tag on Android I get the following error: Can not write to tag; didn't receive an intent.

nfc.writeTag({
            textRecords: [
                {
                    id: [1],
                    text: "Hello"
                },
                {
                    id: [3, 7],
                    text: "Goodbye"
                }
            ]
        });

I have enabled NFC on my smartphone. I have tested it on Android 6 and Android 9 and on both I have the same error. Both available and enabled methods return true.

Error: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.nfc.Tag.hasTech(int)' on a null object reference

Hi, when i try to write an nfc tag on android, the following error occurs:

I´m working with the latest version

[Error: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.nfc.Tag.hasTech(int)' on a null object reference JS: android.nfc.tech.Ndef.get(Ndef.java:146) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:1083) JS: com.tns.Runtime.callJSMethod(Runtime.java:1070) JS: com.tns.Runtime.callJSMethod(Runtime.java:1050) JS: com.tns.Runtime.callJSMethod(Runtime.java:1042) JS: com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(Async_CompleteCallback.java:20) JS: org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:573) JS: org.nativescript.widgets.Async$Http$1$1.run(Async.java:304) JS: android.os.Handler.handleCallback(Handler.java:789) JS: android.os.Handler.dispatchMessage(Handler.java:98) JS: android.os.Looper.loop(Looper.java:180) JS: android.app.ActivityThread.main(ActivityThread.java:6950) JS: java.lang.reflect.Method.invo...

how to view NFC Tags ID on setOnTag?

my School ID has NFC tag in it and would like to view its data.
Itried the setOnNdef and returned this:

Tag discovered, but no listener was set via setOnTagDiscoveredListener. Ndef: {"id":[86,56,70,70],"techList":["android.nfc.tech.NfcA","android.nfc.tech.MifareClassic","android.nfc.tech.NdefFormatable"]}

also did the setOnTag and returned:

Discovered a tag with ID 86,56,70,70

I'd like to view the data on the ID before writing on it. is this possible?

iOS app crashes - hexToDec / hex.toLowerCase - HEX data issue?

Hi! My iOS app built with nativescript vuejs template crashes, this is last bit of log:

CONSOLE LOG file:///app/bundle.js:185:18: 'listenNFC()'
CONSOLE LOG 'lastNdefDiscovered' 'Listening...'
***** Fatal JavaScript exception - application has been terminated. *****
Native stack trace:
1   0x10553bf84 NativeScript::reportFatalErrorBeforeShutdown(JSC::ExecState*, JSC::Exception*, bool, bool)
2   0x105568fdc NativeScript::FFICallback<NativeScript::ObjCMethodCallback>::ffiClosureCallback(ffi_cif*, void*, void**, void*)
3   0x106041578 ffi_closure_SYSV_inner
4   0x1060441b4 .Ldo_closure
5   0x182690b24 <redacted>
6   0x182690ae4 <redacted>
7   0x18269aa38 <redacted>
8   0x18269b380 <redacted>
9   0x18269bd4c <redacted>
10  0x1826a411c <redacted>
11  0x1829c3e70 _pthread_wqthread
12  0x1829c3b08 start_wqthread
JavaScript stack trace:
1   hexToDec@file:///app/vendor.js:6715:14
2   recordToJSON@file:///app/vendor.js:6686:36
3   messageToJSON@file:///app/vendor.js:6675:36
4   ndefToJson@file:///app/vendor.js:6667:34
5   readerSessionDidDetectNDEFs@file:///app/vendor.js:6651:40
6   UIApplicationMain@[native code]
7   _start@file:///app/vendor.js:21621:22
8   run@file:///app/vendor.js:21663:9
9   $start@file:///app/vendor.js:20923:18
10  $start@file:///app/vendor.js:7411:25
11  @file:///app/bundle.js:470:10
12  ./main.js@file:///app/bundle.js:474:34
13  __webpack_require__@file:///app/bundle.js:76:34
14  checkDeferredModules@file:///app/bundle.js:45:42
15  @file:///app/bundle.js:149:38
16  anonymous@file:///app/bundle.js:150:12
17  evaluate@[native code]
18  moduleEvaluation@[native code]
19  promiseReactionJob@[native code]
20  require@[native code]
21  anonymous@file:///app/starter.js:2:8
22  evaluate@[native code]
23  moduleEvaluation@[native code]
24  promiseReactionJob@[native code]
JavaScript error:
file:///app/vendor.js:6715:14: JS ERROR TypeError: undefined is not an object (evaluating 'hex.toLowerCase')

and this is template App.vue component:

<template>
    <Page>
        <ActionBar title="Welcome to NativeScript-Vue!"/>
        <GridLayout columns="*" rows="*,*">
            <Button class="message" :text="msg1" col="0" row="0" @tap="onButtonTap"/>
            <Button class="message" :text="msg2" col="0" row="1" @tap="enableNFC"/>
        </GridLayout>
    </Page>
</template>

<script >
const Nfc = require("nativescript-nfc").Nfc;
const nfc = new Nfc();

export default {
	
    data() {
      return {
        msg1: 'Available?',
        msg2: 'Enable',
		appNFC: nfc  
      }
    },
	
	 methods: {
		 listenNFC: function() {
			 console.log('listenNFC()')
			this.appNFC.setOnNdefDiscoveredListener((data) => {
			  if (data.message) {
				let tagMessages = [];
				// data.message is an array of records, so:
				data.message.forEach(record => {
				  console.log("Read record: " + JSON.stringify(record));
				  tagMessages.push(record.payloadAsString);
				});
				console.log("lastNdefDiscovered", "Read: " + tagMessages.join(", "));
			  }
			}, {
			  stopAfterFirstRead: true,
			  scanHint: "Scan a tag, baby!"
			})
				.then(() => console.log("lastNdefDiscovered", "Listening..."))
				.catch(err => alert(err));
		 },
		 onButtonTap: function(e) {
			this.appNFC.available()
				.then(avail => console.log(avail ? "Available" : "Not Available"));			 
		 },
		enableNFC: function() {
			this.appNFC.enabled()
				.then(on => console.log('on:',on))
				.catch(err => console.log("error:", err.message))
				.finally(() => this.listenNFC() )
			//this.listenNFC();
	 	}
	 }
  }
</script>

Not sure what is the problem with hexToDec and then hex.toLowerCase, is it because my tag contains non-standard record maybe? I am guessing this case when I tried to read this tag with other apps it saying 'error data' or not displaying anything... but other native apps from Apple Store at least do not crash badly like mine.

evaluating 'hex.toLowerCase'

My knowledge of NFC data payload is tiny. What I've done and it's not crashing the app, I went to
nativescript-nfc/nfc.ios.js and commented this bit o code

    NFCNDEFReaderSessionDelegateImpl.prototype.hexToDec = function (hex) {
		//let result = 'Dupa';
        var result = 0, digitValue;
//		
//		console.log('HEX??', hex)
//		
//        hex = hex.toLowerCase();
//        for (var i = 0; i < hex.length; i++) {
//            digitValue = '0123456789abcdefgh'.indexOf(hex[i]);
//            result = result * 16 + digitValue;
//        }
        return result;
    };

Now my app does not crash and the result is

{"tnf":0,"type":0,"id":"[]","payload":"[]","payloadAsHexString":"","payloadAsStringWithPrefix":"","payloadAsString":""}'

So it looks like hexToDec function needs some extra tweaks.
Also I have found interesting article regarding NFC, would be great at some point to implement some solutions like this https://medium.com/@vinceyuan/reading-and-parsing-nfc-tag-on-ios-11-60f4bc7a11ea - anyways any help, much appreciated.

getClass of undefined error (android)

hi,
just trying to get this plugin up and running with my nativescript-vue project for android. following the installation instructions i reached this: Error is: Cannot find module 'nativescript-custom-entitlements/lib/before-prepare.js’. which i fixed by installing the nativescript-custom-entitlements package but carrying on, i cannot run the Nfc constructor var nfc = new Nfc(); (after var Nfc = require("nativescript-nfc").Nfc; of course) without getting this getClass error:

System.err: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:
System.err:
System.err: Error calling module function
System.err:
System.err: Error calling module function
System.err:
System.err: TypeError: Cannot read property 'getClass' of undefined
System.err: File: "file:///data/data/org.***/files/app/vendor.js, line: 441, column: 67
System.err:
System.err: StackTrace:
System.err:     Frame: function:'Nfc', file:'file:///data/data/org.***/files/app/vendor.js', line: 441, column: 68
System.err:     Frame: function:'', file:'file:///data/data/org.***/files/app/bundle.js', line: 1346, column: 11
System.err:     Frame: function:'./main.js', file:'file:///data/data/org.***/files/app/bundle.js', line: 1368, column: 30
System.err:     Frame: function:'__webpack_require__', file:'file:///data/data/org.***/files/app/bundle.js', line: 76, column: 30
System.err:     Frame: function:'checkDeferredModules', file:'file:///data/data/org.***/files/app/bundle.js', line: 45, column: 23
System.err:     Frame: function:'module.exports.../node_modules/mini-css-extract-plugin/dist/loader.js!../node_modules/css-loader/index.js?!../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../node_modules/vue-loader/lib/index.js?!./components/HelloWorld.vue?vue&type=style&index=0&id=763db97b&scoped=true&lang=css&', file:'file:///data/data/org.***/files/app/bundle.js', line: 149, column: 18
System.err:     Frame: function:'', file:'file:///data/data/org.***/files/app/bundle.js', line: 152, column: 10
System.err:     Frame: function:'require', file:'', line: 1, column: 266
System.err:     Frame: function:'', file:'file:///data/data/org.***/files/app/starter.js', line: 2, column: 1
System.err:     Frame: function:'require', file:'', line: 1, column: 266

any thoughts on how to fix this would be greatly appreciated!

Android setOnTagDiscoveredListener Error

i use setOnNdefDiscoveredListener and implement like this
exports.doStartTagListener = function(){ nfc.setOnTagDiscoveredListener(function(data) { console.log("Discovered a tag with ID " + data.id); }).then( function() { console.log("OnTagDiscovered listener added"); } ); }
When i read rfid . i found error

JS: Tag discovered, but no listener was set via setOnTagDiscoveredListener. Ndef: {"id":[94,-11,-7,114],"techList":["android.nfc.tech.MifareClassic","android.nfc.tech.NfcA","android.nfc.tech.NdefFormatable"]}

I need to get data from rfid and alert to screen . How can i implement this function.

demo will not build

Hello I tried to implement this NFC scanner but all I get on android is a beep and then nothing happens.

In order to try and figure out what I'm doing wrong I downloaded this demo repo and then tried to do a cloud build with that on NS, but it failed...

I'm also trying in JS and your demo is in TS ... but after half a day of trial and error, I'm kind of stuck without any pointers?

Ability to set tag read only

The NFC standard allows for tags to be set as read only.

Is there any possibility to do this using nativescript-nfc?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.