}
NFCManager.prototype.getDefaultAdapter = function() {
+ // First check NFC suppor on C++ level
+ var result = native_.callSync(
+ 'NFCManager_getDefaultAdapter',
+ {}
+ );
+ if(native_.isFailure(result)) {
+ throw new tizen.WebAPIException(0, result.error.message,
+ result.error.name);
+ }
+
+ // If NFC is supported then return new NFCAdapter instance
return new NFCAdapter();
};
// If failed then exception should be thrown.
if(native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message, result.error.name);
+ throw new tizen.WebAPIException(0, result.error.message,
+ result.error.name);
// Uncoment line below (and remove line above) when problem
// with error conversion is fixed:
//
void NFCInstance::GetDefaultAdapter(
const picojson::value& args, picojson::object& out) {
+ // Default NFC adapter is created at JS level
+ // Here there's only check for NFC support
+ LoggerD("Entered");
+ if(!nfc_manager_is_supported()) {
+ LoggerE("NFC manager is not supported");
+ // According to API reference only Security and Unknown
+ // exceptions are allowed here
+ auto ex = common::UnknownException("NFC manager not supported");
+ ReportError(ex, out);
+ }
+ else {
+ ReportSuccess(out);
+ }
}
void NFCInstance::SetExclusiveMode(