mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
added startScanning
method
This commit is contained in:
parent
3a1127ef9e
commit
0be9adf117
@ -1,5 +1,6 @@
|
|||||||
import Core from "evite/src/core"
|
import Core from "evite/src/core"
|
||||||
import TapShareDialog from "components/TapShare/Dialog"
|
import TapShareDialog from "components/TapShare/Dialog"
|
||||||
|
import { Nfc, NfcUtils, NfcTagTechType } from "@capawesome-team/capacitor-nfc"
|
||||||
|
|
||||||
export default class NFC extends Core {
|
export default class NFC extends Core {
|
||||||
static refName = "NFC"
|
static refName = "NFC"
|
||||||
@ -13,6 +14,7 @@ export default class NFC extends Core {
|
|||||||
public = {
|
public = {
|
||||||
incompatible: null,
|
incompatible: null,
|
||||||
scanning: false,
|
scanning: false,
|
||||||
|
startScanning: this.startScanning.bind(this),
|
||||||
instance: function () { return this.instance }.bind(this),
|
instance: function () { return this.instance }.bind(this),
|
||||||
subscribe: this.subscribe.bind(this),
|
subscribe: this.subscribe.bind(this),
|
||||||
unsubscribe: this.unsubscribe.bind(this),
|
unsubscribe: this.unsubscribe.bind(this),
|
||||||
@ -25,8 +27,12 @@ export default class NFC extends Core {
|
|||||||
|
|
||||||
this.instance = new NDEFReader()
|
this.instance = new NDEFReader()
|
||||||
|
|
||||||
|
this.startScanning()
|
||||||
|
}
|
||||||
|
|
||||||
|
async startScanning() {
|
||||||
try {
|
try {
|
||||||
navigator.permissions.query({ name: "nfc" })
|
//await navigator.permissions.query({ name: "nfc" })
|
||||||
|
|
||||||
this.instance.scan()
|
this.instance.scan()
|
||||||
|
|
||||||
@ -43,6 +49,11 @@ export default class NFC extends Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
subscribe(callback) {
|
subscribe(callback) {
|
||||||
|
// check if scan service is available, if not try to initialize
|
||||||
|
if (this.public.scanning === false) {
|
||||||
|
this.startScanning()
|
||||||
|
}
|
||||||
|
|
||||||
this.subscribers.push(callback)
|
this.subscribers.push(callback)
|
||||||
|
|
||||||
console.debug(`[NFC] SUBSCRIBED >`, this.subscribers.length)
|
console.debug(`[NFC] SUBSCRIBED >`, this.subscribers.length)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user