Is reading a NFC chip as a web app possible - web

I'd like to use Vaadin to create a web app in Java that reads a NFC chip to identify the user and then proceeds with other options, is that possible?
My reason why I don't want to do that in an android app is to decentralize myself to perform the same work for multiple versions and/or different systems

The Web NFC API is what you're looking for: https://web.dev/nfc
Web NFC is available only on Chrome for Android for now. It is limited to NDEF because the security properties of reading and writing NDEF data are more easily quantifiable. Low-level I/O operations (e.g. ISO-DEP, NFC-A/B, NFC-F), Peer-to-Peer communication mode and Host-based Card Emulation (HCE) are not supported.
Here's a sample for you to play with: https://googlechrome.github.io/samples/web-nfc/
const ndef = new NDEFReader();
await ndef.scan();
ndef.addEventListener("reading", ({ message, serialNumber }) => {
console.log(`> Serial Number: ${serialNumber}`);
console.log(`> Records: (${message.records.length})`);
});

Related

What is the best way to manage google chrome extension payment system for in app purchases

I have developed a chrome extension with manifest 3. I want to offer free features as well as paid with in-app purchases. I have done that with extpay.js. extpay github. and extension pay site. links are here
But the issue is that extpay.js allows a user to log in on multiple devices at the same time and use the pro version on different devices at the same time.
I don't want users to use the pro version bought with a single account on multiple devices at the same time.
My requirements are simple. I want to link a complete payment system with proper checkpoints. I mean if a user wants to use it on a new device the older device should not able to use the pro version. That should be changed to a free one.
I have done all these things. I have arranged the flow if a user is paid then what and how the content will be shown I have done this completely. The only problem with extpay.js is. It lets the users use the same account on multiple devices at the same time to use the pro version.
Code I am using (extpay.js) for in-app purchases and identifying the user.
importScripts('ExtPay.js');
let user;
try {
const extpay = ExtPay('extensions-id');
extpay.startBackground();
(async function () {
user = await extpay.getUser();
if (user.paid) {
enableProFeatures();
}
})();
} catch (error) {
alert('Make sure you are connected to internet');
}
Please, guide me on the proper way of doing that...

Button is not showing in Google Nest devices but showing properly in Mobile Assistant

I am using google actions for one of our clients. We are using Button to navigate the user to a specific URL but Button is not showing in the Nest devices, but it is showing fine in Mobile Assistant devices.
Anyway, where we can enable the same?
Also if there is no option, what is the way to identify if the user logged in the device has button functionality enabled?
Buttons that link to a webpage are not available on smart displays. In the platform different devices have certain limitations. As such, the device running the action sends capabilities that define what is possible. You will need to check for the WEB_LINK capability.
In the Node.js library this would be done as such:
app.handle('handle-name', conv => {
const supportsWebLink = conv.device.capabilities.includes('WEB_LINK')
if (!supportsWebLink) {
// Behavior for Nest Hub and other devices
}
})
I see you have the dialogflow-es tag rather than actions-builder, so to do it in Dialogflow:
app.intent('intent-name', conv => {
const supportsWebLink = conv.device.capabilities.includes('WEB_LINK')
if (!supportsWebLink) {
// Behavior for Nest Hub and other devices
}
})

Web Bluetooth API get list of all available device nearby

I am looking for an API call that could be used to retrieve all the Bluetooth devices near me. These samples Web Bluetooth talk about getting different characteristics from a single Bluetooth device, however I couldn't find any example which retrieves all the Bluetooth devices(like available bluetooth devices list on windows native Bluetooth app). Is it even supported?
(Well, this question sent me down a rabbit hole...)
It's a couple years later and we're starting to signs of life from api.Bluetooth.getDevices. I eventually got an experimental demo working in Chrome.
You'll probably need to enable Chrome's "Web Bluetooth experiment". (Firefox has an equivalent but I didn't try it.)
Go to chrome://flags/ then search for bluetooth and enable the API.
Click the buttons on the demo page: Web Bluetooth / Get Devices Sample
Demo code from the same page:
function onGetBluetoothDevicesButtonClick() {
log('Getting existing permitted Bluetooth devices...');
navigator.bluetooth.getDevices()
.then(devices => {
log('> Got ' + devices.length + ' Bluetooth devices.');
for (const device of devices) {
log(' > ' + device.name + ' (' + device.id + ')');
}
})
.catch(error => {
log('Argh! ' + error);
});
}
function onRequestBluetoothDeviceButtonClick() {
log('Requesting any Bluetooth device...');
navigator.bluetooth.requestDevice({
// filters: [...] <- Prefer filters to save energy & show relevant devices.
acceptAllDevices: true
})
.then(device => {
log('> Requested ' + device.name + ' (' + device.id + ')');
})
.catch(error => {
log('Argh! ' + error);
});
}
Good luck!
I personally haven't experimented with Web Bluetooth API a lot, but I think you're looking for Device Discovery and Request Bluetooth Devices:
This version of the Web Bluetooth API specification allows websites,
running in the Central role, to connect to remote GATT Servers over a
BLE connection. It supports communication among devices that implement
Bluetooth 4.0 or later.
When a website requests access to nearby devices using
navigator.bluetooth.requestDevice, Google Chrome will prompt user with
a device chooser where they can pick one device or simply cancel the
request.
The navigator.bluetooth.requestDevice function takes a mandatory
Object that defines filters. These filters are used to return only
devices that match some advertised Bluetooth GATT services and/or the
device name.
Also, here's the list of GATT
Services.
A Web Bluetooth Scanning specification draft exists, but implementation isn't started anywhere as of 2018.

Multi Tenancy in Microsoft bot framework webchat

I have successfully hosted an instance of microsoft's Botframework web chat using directline on public domain, I want to make a chatbot in such a way that my customers can have their own channels completely separated from each other and I cannot find any kind of documentation anywhere, Kindly suggest me if this is possible and how?
I have written the complete code in Node.js and have very less idea about c#.
It seems that there is no such feature for uniform customized chat channel in bot framework. So we can leverage new builder.Message().address(address) to send messages to specific users from the official sample at https://github.com/Microsoft/BotBuilder-Samples/blob/master/Node/core-proactiveMessages/simpleSendMessage/index.js.
So I had a quick test which will save the users' addresses into an address list in server memory as a "customize channel", and trigger a key work to send message to these addresses in list as a broadcast in this "customize channel":
let channel_address = [];
bot.dialog('joinChannel',(session)=>{
channel_address.push(session.message.address);
}).triggerAction({
matches:/join/i
})
bot.dialog('broadcast',(session)=>{
channel_address.forEach((address)=>{
bot.send(
new builder.Message(session).address(address).text(session.message.text)
)
})
}).triggerAction({
matches:/^broadcast: .*/
})
Test Step:
Open two emulators connect to your local bot
in both emulators, type "join"
in either emulator, type text like broadcast: hi there

Using both activeTab and serial permissions

I am trying to use a hardware serial device to change what displays on a webpage in Chrome. I'm making a Chrome extension to do so, however it seems as if I cannot use both the activeTab and serial permissions at the same time. The activeTab permission requires the app to not be a packaged app, and the serial permission requires the app to be packaged.
How can I get around this if possible?
I am using the page redder sample code as the way to change the webpage, however it requires the activeTab permission. Maybe there is a workaround to this? Thanks
The only way I can think of is to create one Chrome Extension and one Chrome App that communicates to each other: https://developer.chrome.com/extensions/messaging#external
// The ID of the extension we want to talk to.
var laserExtensionId = "abcdefghijklmnoabcdefhijklmnoabc";
// Make a simple request:
chrome.runtime.sendMessage(laserExtensionId, {getTargetData: true},
function(response) {
if (targetInRange(response.targetData))
chrome.runtime.sendMessage(laserExtensionId, {activateLasers: true});
});
// Start a long-running conversation:
var port = chrome.runtime.connect(laserExtensionId);
port.postMessage(...);
An alternative is to make a Native Messaging host that communicates with the device and with your extension.
From architectural point of view this makes more sense, but limits your deployment options, as the host program can't be bundled with the extension in the Web Store.

Resources