mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +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 TapShareDialog from "components/TapShare/Dialog"
|
||||
import { Nfc, NfcUtils, NfcTagTechType } from "@capawesome-team/capacitor-nfc"
|
||||
|
||||
export default class NFC extends Core {
|
||||
static refName = "NFC"
|
||||
@ -13,6 +14,7 @@ export default class NFC extends Core {
|
||||
public = {
|
||||
incompatible: null,
|
||||
scanning: false,
|
||||
startScanning: this.startScanning.bind(this),
|
||||
instance: function () { return this.instance }.bind(this),
|
||||
subscribe: this.subscribe.bind(this),
|
||||
unsubscribe: this.unsubscribe.bind(this),
|
||||
@ -25,8 +27,12 @@ export default class NFC extends Core {
|
||||
|
||||
this.instance = new NDEFReader()
|
||||
|
||||
this.startScanning()
|
||||
}
|
||||
|
||||
async startScanning() {
|
||||
try {
|
||||
navigator.permissions.query({ name: "nfc" })
|
||||
//await navigator.permissions.query({ name: "nfc" })
|
||||
|
||||
this.instance.scan()
|
||||
|
||||
@ -43,6 +49,11 @@ export default class NFC extends Core {
|
||||
}
|
||||
|
||||
subscribe(callback) {
|
||||
// check if scan service is available, if not try to initialize
|
||||
if (this.public.scanning === false) {
|
||||
this.startScanning()
|
||||
}
|
||||
|
||||
this.subscribers.push(callback)
|
||||
|
||||
console.debug(`[NFC] SUBSCRIBED >`, this.subscribers.length)
|
||||
|
Loading…
x
Reference in New Issue
Block a user