Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added extra feedback to demo #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions demo/app/main-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class HelloWorldModel extends observable.Observable {
public doCheckAvailable() {
this.nfc.available().then((avail) => {
console.log("Available? " + avail);
alert("" + avail);
alert("NFC Available: " + avail);
}, (err) => {
alert(err);
});
Expand All @@ -23,7 +23,7 @@ export class HelloWorldModel extends observable.Observable {
public doCheckEnabled() {
this.nfc.enabled().then((on) => {
console.log("Enabled? " + on);
alert("" + on);
alert("NFC Enabled: " + on);
}, (err) => {
alert(err);
});
Expand All @@ -32,10 +32,11 @@ export class HelloWorldModel extends observable.Observable {
public doStartTagListener() {
let that = this;
this.nfc.setOnTagDiscoveredListener((data: NfcTagData) => {
console.log("Tag discovered! " + data.id);
that.set("lastTagDiscovered", data.id);
console.log("Tag discovered! " + JSON.stringify(data));
that.set("lastNdefDiscovered", data.id + " => " + data.techList.join(", "));
}).then(() => {
console.log("OnTagDiscovered Listener set");
console.log("TagListener Listening...");
this.set("lastNdefDiscovered", "Listening...");
}, (err) => {
console.log(err);
});
Expand All @@ -44,6 +45,7 @@ export class HelloWorldModel extends observable.Observable {
public doStopTagListener() {
this.nfc.setOnTagDiscoveredListener(null).then(() => {
console.log("OnTagDiscovered nulled");
this.set("lastNdefDiscovered", "Stopped listening.");
}, (err) => {
console.log(err);
});
Expand All @@ -63,13 +65,15 @@ export class HelloWorldModel extends observable.Observable {
}, {
stopAfterFirstRead: true,
scanHint: "Scan a tag, baby!"
})
.then(() => this.set("lastNdefDiscovered", "Listening..."))
.catch(err => alert(err));
}).then(() => {
console.log("NdefListener Listening...");
this.set("lastNdefDiscovered", "Listening...");
}).catch(err => alert(err));
}

public doStopNdefListener() {
this.nfc.setOnNdefDiscoveredListener(null).then(() => {
console.log("OnNdefDiscovered nulled");
this.set("lastNdefDiscovered", "Stopped listening.");
}, (err) => {
alert(err);
Expand All @@ -85,6 +89,7 @@ export class HelloWorldModel extends observable.Observable {
}
]
}).then(() => {
console.log("Wrote text 'Hello!'");
this.set("lastNdefDiscovered", "Wrote text 'Hello!'");
}, (err) => {
console.log(err);
Expand All @@ -100,14 +105,16 @@ export class HelloWorldModel extends observable.Observable {
}
]
}).then(() => {
this.set("lastNdefDiscovered", "Wrote uri 'https://www.telerik.com");
console.log("Wrote uri 'https://www.telerik.com'");
this.set("lastNdefDiscovered", "Wrote uri 'https://www.telerik.com'");
}, (err) => {
console.log(err);
});
}

public doEraseTag() {
this.nfc.eraseTag().then(() => {
console.log("Tag erased");
this.set("lastNdefDiscovered", "Tag erased");
}, (err) => {
console.log(err);
Expand Down