问题
Im trying to read the data in NFC tag using web development. I am able to detect tags from emulator, but on Gear S2 it does not work.
I have given all the privileges in config.xml
<tizen:privilege name="http://tizen.org/privilege/nfc.common"/>
<tizen:privilege name="http://tizen.org/privilege/nfc.tag"/>
<tizen:privilege name="http://tizen.org/privilege/bluetooth.admin"/>
<tizen:privilege name="http://tizen.org/privilege/nfc.admin"/>
<tizen:privilege name="http://tizen.org/privilege/nfc.cardemulation"/>
I am using whiztags NFC tags with Gear S2, they are working with my mobile(Nexus 5).
I have switched on the NFC in my watch, but still they don't respond to tags.
Code:
var adapter = tizen.nfc.getDefaultAdapter();
adapter.setPowered(
true, // Enable NFC adapter
function () {console.log('Power on success');}, // Handle succes
function () {console.log('Power on failed');}); // Handle failure
//
var onSuccessCB = {onattach : function(nfcTag) {
console.log("NFC Tag's type is " + nfcTag.type);
navigator.vibrate([600, 100, 300, 200, 0]);
for(var i in nfcTag.properties) {
console.log("key:" + i + " value:" + nfcTag.properties[i]);
}
}, ondetach : function() {
console.log("NFC Tag is detached");
}};
adapter.setTagListener(onSuccessCB);
回答1:
The NFC API is optional for both Tizen mobile and wearable profiles, which means that it may not be supported in all mobile and wearable devices. The NFC API is supported on the Tizen wearable Emulator, but not on the Tizen mobile Emulator.
Please go through this link for more details.
I've seen some other people having same issue. Have a look on this link too.
来源:https://stackoverflow.com/questions/38002194/nfc-tag-not-working-on-gear-s2