I have been utilizing the library phonegap-nfc for scanning NFC tags, but I'm encountering an issue where instead of staying on the current

I have integrated the phonegap-nfc library into my vue project, and it is working fine. However, I am facing an issue where the information from my NFC card is being displayed on a different page instead of within my app. I want to show all the information that the NFC holds directly in my app. If anyone has any suggestions on how to achieve this, please help me out.

Below is the code snippet:

<template>
  <v-app>
    <v-card-actions>
      <div class="cardInfos">
        {{ tagId }}
        {{ message }}
      </div>
    </v-card-actions>
  </v-app>
</template>

<script>
export default {
  name: 'App',

  data: () => ({
    tagId: "",
    message: ""
  }),

  methods:{
    scanNFC(){
      window.nfc.enabled(
        () => {
          // NFC enabled
          this.registerTagEvent()
        },
        (error) => {
          if (error === 'NFC_DISABLED') {
            // Trigger the phone settings to enable the NFC settings
            window.nfc.showSettings()
          } else if (error === 'NO_NFC') {
            navigator.notification.alert('Cannot scan NFC', () => {}, 'No NFC', 'OK')
          }
        }
      )
    },

    registerTagEvent () {
      window.nfc.addTagDiscoveredListener(
        this.displayNdef,
        () => {
          console.log('succeess registering ndef listener')
        },
        (error) => {
          console.log('failure registering ndef listener', error)
        }
      )
    },

    displayNdef (nfcEvent) {
      const bgColor = document.getElementsByClassName(".v-application--wrap")
      bgColor.style.backgroudColor = "green"
      let tag = nfcEvent.tag
      let tagId = window.nfc.bytesToHexString(tag.id)
      let message = window.nfc.bytesToString(tag.ndefMessage[0].payload)
      this.tagId = tagId
      this.message = message

      window.ndefMessage(tagId, message)
    },

    deactivated () {
      this.unregisterTagEvent()
    },

    unregisterTagEvent () {
      if ((typeof nfc) !== 'undefined') {
        window.nfc.removeNdefListener(this.displayNdef)
      }
    },
};
</script>

If you have any insights or solutions, please assist me :)

Answer №1

After encountering an issue, I successfully resolved it by taking the following steps:

Here is how you can disable the Tags app on a stock Android device:

- Go to Settings - Navigate to Apps & Notifications - Select See all apps (usually located under Recently opened apps) - Tap on the three dots in the top right corner - Choose Show system (this will display all system installed apps) - Look for the app (typically the default NFC app, visible when choosing options while reading NFC tag) - The app is usually named "Tags": click on the Tags app from the list of applications - Click on Disable and confirm by clicking OK on any prompts that appear regarding disabling the app

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

iOS - A clever trick for manually setting focus on an input/textarea

Recently, there have been numerous discussions about the issue in iOS where focusing on an input/textarea element cannot be achieved through manual means. (Check out the threads here and here) It appears that iOS necessitates a genuine tap or click for foc ...

Allusion to a intricate data component

In my code, I have a model that is being represented by a class. For example, let's consider the model of a car: export class Car { public name : string; public color: string; public power : number; public service : boolean; } All c ...

What is the best way to establish a maximum limit for a counter within an onclick event?

I'm struggling to figure out how to set a maximum limit for a counter in my onclick event. Can someone help me? What is the best way to add a max limit to the counter of an onclick event? Do I need to use an if statement? If yes, how should it be w ...

Make sure the div is always positioned above everything, including any built-in pop-up windows

When working with two forms, one for user input and the other as a pop-up window to display results, users sometimes close the pop-up window prematurely if they think there is a network issue causing a delay in data execution. To prevent this, I am consi ...

Discovering the position of elements in relation to their (grand^N)parent

Among my possessions are elements A and B. B has the ability to exist as a direct child of A, or there may be anywhere from 0 to N elements separating them. It is imperative that I determine how B is situated in relation to A, specifically noting the dist ...

What is preventing me from accessing the additional JavaScript functions in Vue Laravel?

After stumbling upon a code snippet online that utilized a class without specifying whether it was for Vue or JavaScript, I decided to test it out. However, I encountered an issue where I couldn't access any functions after importing the class. I bel ...

The swap feature in drag-and-drop does not have a defined function

I am currently developing a to-do app that utilizes drag and drop functionality to reorder items in the list. However, I have encountered an issue where swapping elements works perfectly for the first five elements but throws errors when dealing with the s ...

Having trouble accessing PDF files on Electron framework

Despite following the advice provided in similar questions' answers, such as including webPreferences: { plugins: true } in the options when creating a BrowserWindow instance, I am still encountering issues. Every attempt to open or view a PDF ...

Vue-Cli-Service - Bypassing webpack execution

Is there a way to instruct the vue cli service to compile code using only babel and skip webpack entirely? I want to avoid unnecessarily complex code structures like this: /******/(function (modules) { // webpackBootstrap /******/ // The module cache ...

Issue with Vue <transition-group> not being activated when the v-move class is used?

I've been struggling to understand how <transition-group> works. When I click on the box, it's supposed to change its position and trigger the v-move class. You can find more details about this in the Vue documentation here. If you want to ...

Guiding users who have disabled JavaScript through redirection

When faced with the following markup, users whose browser has JavaScript disabled will be redirected to an alternative page. This alternate page may attempt to mimic the site's functionality without JavaScript or simply display a warning message infor ...

What's the process for including delivery charges in Stripe transactions?

I am facing an issue with Stripe where I am unable to incorporate delivery fees into my transactions. How can I successfully integrate this feature? let line_items = []; for (let productId of uniqIds) { const quantity = productsIds.filter(id => id == ...

nodemon is launching an endless number of .node-xmlhttprequest-sync files

I am facing a strange issue with my app that imports a module containing a promise. Everything runs smoothly when I start the app using "node app.js" However, if I use "nodemon" to launch it, it constantly creates files with names like .node-xmlhttpreque ...

Create a PDF document with pdfkit and stream it to the browser in a Node.js Express application

I am currently using pdfkit to create a PDF file and I would like to send this PDF directly to the browser. However, I am encountering an error message stating "TypeError: listener must be a function", Additionally, the file is being generated in m ...

Mongoose: Enhancing Arrays with maximum values for each item

How to Update an Array Property in Mongoose with Item-Wise Max and Default Null Upon Instantiation I have a MongoDB collection that stores time series data in a fixed-length array (1 item per minute, 1 document per day). { 'series': '#1& ...

Encountering the "Next Router not mounted" error while attempting to retrieve the locale variable from the path

In order to access the locale and locales properties from use router, I am importing them from next/router. However, an issue arises when using next/router. Interestingly, the problem disappears when I switch the import to next/navigation. Unfortunately, ...

Leveraging the power of a JavaScript framework within the script tag

Hello there! I'm just starting out with vue.js and exploring different JavaScript frameworks. Recently, I came across an interesting example based on the documentation. import modal from 'vue-semantic-modal' export default { components ...

Vue: The function "priceFilter" is not defined in this context

function sanitizeInput(event) { event.target.value = event.target.value.replace(/[^\d.]/g, ""); event.target.value = event.target.value.replace(/^\./g, ""); event.target.value = event.target.value.replace(/\.{2,}/g, "."); event.targe ...

Unlocking the secrets of the Fibonacci function through mathematical equations

Looking for a better way to calculate the fibonacci function using a mathematical formula. I've tried the following formula without success: fib(n) = ((1 + 5^0.5) / 2)^n - ((1 - 5^0.5) / 2)^n / 5^0.5 const fib=(n)=>{ return ((1+(5**0.5))/2)* ...

Having trouble toggling journal entries in an HTML journal? The Jquery function might not be working properly

I have been tasked with creating a civil war journal for my 8th grade Social Studies class and I decided to present it as an HTML file featuring the title and date of each journal entry. The goal is to allow users to click on each entry to open it while au ...