Apache Cordova NFC reader integration is the next step in modern technology

I am trying to utilize phonegap nfc ( PhoneGap tutorial ) to read NFC cards, but the event is not being triggered.

Here is the code from index.js:

 onDeviceReady: function() {
     app.receivedEvent('deviceready');

// Read NDEF formatted NFC Tags
nfc.addNdefListener (
    function (nfcEvent) {
        var tag = nfcEvent.tag,
            ndefMessage = tag.ndefMessage;

        // dump the raw json of the message
        // note: real code will need to decode
        // the payload from each record
        alert(JSON.stringify(ndefMessage));

        // assuming the first record in the message has
        // a payload that can be converted to a string.
        alert(nfc.bytesToString(ndefMessage[0].payload).substring(3));
    },
    function () { // success callback
        alert("Waiting for NDEF tag");
    },
    function (error) { // error callback
        alert("Error adding NDEF listener " + JSON.stringify(error));
    }
);
},

Any advice or suggestions?

Answer №1

Resolved using the nfc.addTagDiscoveredListener method in place of nfc.addNdefListener

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Showcasing pictures on ReactJS

I am currently working on developing an application to showcase images on my React webpage. These images have already been uploaded to a local folder. In order to integrate my React application with a NodeJS server and MongoDB, I connected the two. My goa ...

Create a dynamic calendar by integrating dates with Javascript and an HTML table

Recently, I decided to delve into web design again and embark on a challenging project for my father's baseball business. The main task at hand is creating a detailed calendar using HTML tables. After spending a considerable amount of time perfecting ...

Commitment of service within AngularJS controller using the "as" syntax

I'm experiencing an issue with the code snippet below. I prefer using the controller as syntax and assigning data to 'this' instead of $scope. The problem is that in this scenario, when using $scope.user everything works fine, but when tryin ...

Dependency injection in Angular is a powerful design pattern that

I recently completed an Angular 2 website, but I've run into some issues that I cannot seem to debug. I've spent the past week trying to find a solution but have had no luck. Below, I've included some snippets of my code. Feel free to ask fo ...

Transforming JSON data into Java objects is seamless with the JSON to Java Object Mapper that integrates smoothly with J2objc

Currently, I'm utilizing the org.json.* classes from the j2objc distribution for handling JSON objects in my DTO classes. The mapping between my DTO classes and JSON Objects is done manually at the moment. I am aware of GSOn and Jackson as other opti ...

Developing a unified input element containing numerous fields

After @grateful answered this question, I wanted to elaborate in case it could benefit others... In my project, there's a page called rsetup.php which has some PHP code to access a MySQL database for filling the HTML content of the page. This HTML ge ...

Hold on until the element becomes clickable

When attempting to logout from the menu drop down, I encountered an error stating "Unable to locate element." I suspect there may be a synchronization issue as adding a `browser.sleep(5000);` allowed the tests to pass, but this solution is not stable. ...

Using axiosjs to send FormData from a Node.js environment

I am facing an issue with making the post request correctly using Flightaware's API, which requires form data. Since Node does not support form data, I decided to import form-data from this link. Here is how my code looks like with axios. import { Fl ...

The path mappings specified in the tsconfig.json file are not resolving correctly during the

Everything runs smoothly with my imports during coding, but after building the project using tsc, the imported files are not resolving to valid paths. This is how my tsconfig.json looks: { "compilerOptions": { "target": "ES2 ...

Tips on incorporating a class into a div generated within a contenteditable container

Take a look at this sample code: <div> Text.. <div id="editable-editor" contenteditable="true">Some Text Here...</div> </div> If you hit enter inside the #editable-editor after Some Text, it will generate a <div>Here...& ...

Error: 'window not defined' or 'document not defined' encountered while importing a module in Next.js

I'm working on integrating a Wysiwyg editor into my web application. However, I encountered an error when trying to import the editor module. I tried using both react-draft-wysiwyg and react-quill. The former resulted in a "window not defined" error, ...

CSS/SCSS/JS: Adjusting header height dynamically while keeping it fixed at the

Check out my Codepen demo here: https://codepen.io/nickfindley/pen/dJqMQW I am seeking to replicate the current behavior of the page without specifying a fixed height for the header. The goal is to make the header adjust dynamically based on the content, ...

Guide to fetching external data with Next.js and importing the component into a different file

I have implemented the following code in my pages/github file, and when I navigate to localhost:3000/github, the code runs successfully and returns JSON data. function GithubAPI(props) { // Display posts... return (<div>{props.data.name}</div& ...

Unable to load JSON information into an ExtJS grid

I have exhausted all the solutions I found (there are many on Stackoverflow) in an attempt to fix my extjs store issue. Despite ensuring that the grid is displayed correctly, the data still refuses to show up. Feeling perplexed, I am sharing the "store" co ...

Guide to updating HTML table data using php and Javascript

Currently, my webpage fetches data from a MySQL database and displays it in an HTML table as soon as the page loads. Now I want to provide users with more advanced filtering options, such as filtering by name, age, etc. When a user submits their filterin ...

Exploring Node.js Express: Understanding the Difference Between Modules and Middleware

I am working on an express rest api and need to create a PDF document with a link to download it. I have successfully generated the PDF, but now I want to create a route specifically for returning the PDF link. In addition, I also need other routes that ...

Animating Angular for particular conditions

My goal is to create unique animations for specific state changes in my AngularJS app. I found inspiration from this tutorial: https://scotch.io/tutorials/animating-angularjs-apps-ngview, which works well. However, I am aiming for the following animations: ...

Loading Disqus comments dynamically upon clicking a button within a Next.js application

After noticing a significant decrease in page performance scores due to Disqus comments embedded on Vercel Analytics, I am considering implementing a "Load comments" button instead of loading the actual comments onClick. I have been using the disqus-react ...

Storing PHP usernames in AngularJS

Currently in the process of developing a dynamic AngularJS survey form that pulls the user's username from a WordPress setup. I've successfully retrieved the username, but encountered an issue where it disappears upon changing views and refreshi ...

Executing JavaScript files stored on my server using the Node.js command line interface

I need guidance on configuring an app that relies on running node generate.js and node generate_texts_index.js in the command prompt. These files are essential for building the necessary data for the app to function correctly. Running these files locally a ...