Tizen Web App: readRecorderData TypeError: 'undefined' is not a function

483 Views Asked by At

I'm developing a Tizen web application for Gear Fit2 and i got an 'Type Error: undefined is not a function (tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror)' error when i called a "readRecorderData" function of a Human Activity API. However when i call a "start" function of the same API it works perfectly.

I put healthinfo and location privilege to my config.xml:

<tizen:privilege name="http://tizen.org/privilege/healthinfo"/>
<tizen:privilege name="http://tizen.org/privilege/location"/>

Hope you guys can help. Thanks.

There is a sample of my code that i used:

var type = 'PEDOMETER';
var now = new Date();
var startTime = now.setDate(now.getDate() - 7);
var anchorTime = (new Date(2018, 1, 2, 6)).getTime();
var query = {
  startTime: startTime / 1000,
  anchorTime: anchorTime / 1000,
  interval: 1440 /* 1 day */
};

try { tizen.humanactivitymonitor.readRecorderData(type, query, onread, onerror); } 
catch (err) { console.log(err.name + ': ' + err.message); }
1

There are 1 best solutions below

0
On BEST ANSWER

The reason is your device runs on 2.3.1 or below Tizen OS version.

Check the API References Doc for readRecorderData(): Since 2.3.2

If you create a project with 2.3.2 (or above) tizen version and deploy on Tizen device or Emulator running on tizen 2.3.2 (or above) this error will be gone.

But for your case, HRM Recorder is supported from tizen 2.3.2 so you can't use it. Try a different workaround like storing sensor data in local storage or file system manually.