I'm using phonegap-nfc library in my vue project. Its working but I don't know why it open the information I have on my NFC car in other page information. What I want to do is show all the information that NFC have in my app. So if anyone knows how to do it could you help me please?
Here is my code:
<template>
<v-app>
<v-card-actions>
<div >
{{ 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) {
// Decode tag data from the plugin
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 () {
// Test if the plugin is defined
if ((typeof nfc) !== 'undefined') {
window.nfc.removeNdefListener(this.displayNdef)
}
},
};
</script>
Can anyone help me please :)
CodePudding user response:
I solved the problem with these steps:
Steps to disable Tags app on stock Android:
Navigate to Settings Click on Apps & Notifications Click on See all apps (Usually under Recently opened apps) Click on 3 dots on top right hand Click on Show system (which will enable all system installed apps) Search for the app (default nfc app, which you will see in Choose options while reading NFC tag) Usually the app is called Tags: click on Tags app in the list of apps Click on Disable and click on OK on any dialogs which are displayed around disabling the app