Hi there, I would like to ask some questions about this package
Does anyone know whats the difference between the step count of com.google.android.gms:merge_step_deltas and com.google.android.gms:estimated_steps?
I read some article said merge_step_deltas merge the step count of different sources, but i am not sure what it means
Also, i found out that there is a day which has not step data, but Google Fit app shows food step for that day, can anyone give me some hints on why this happen?
Different sources literally means the data can be from different devices like watch, mobile phone, etc. (imagine if you have two phones with app installed)
I don't know about food step
, but it can be from the estimation of manually added activity
implement
and the apply plugin
lines in my build.gradle but still have this error '_reactNativeGoogleFit.default.checkIsAuthorized' is undefined
. The only thing that I haven't is the validation by google... could be because of that?
still (not moving)
. I suspect that the problem might be, we enter a activity, which may include calories or Google Fit generate calories based on some prediction model. Then we delete the activity. Those calories still exists so it somehow fallback or categorized to still
or unknown
? Just my personal guess, can be the problem from code though. But you can use google Rest playground Api to check it out.
Asked this question in a Github issue but thought I'd pitch it here too.
Currently, I can only read heart rate going back a couple weeks. I found a stackoverflow post that said to go further back you need to make use of enableServerQueries.
I was wondering if this is already a feature of react-native-google-fit or if it would have to be requested/made?
const opt = {
startDate: "2017-01-01T00:00:17.971Z", // required ISO8601Timestamp
endDate: new Date().toISOString(), // required ISO8601Timestamp
bucketUnit: "DAY", // optional - default "DAY". Valid values: "NANOSECOND" | "MICROSECOND" | "MILLISECOND" | "SECOND" | "MINUTE" | "HOUR" | "DAY"
bucketInterval: 1, // optional - default 1.
};
async function fetchData() {
const res = await GoogleFit.getDailyStepCountSamples(opt);
console.log(res);
}
fetchData();
This is my simple code but I get attempt to invoke virtual method. I tried looking at this git thread: StasDoskalenko/react-native-google-fit#20 but it doesnt mention how to fix it even with authorization.
[{"activityName": "unknown", "device": "", "end": 1636331399095, "sourceId": "", "sourceName": "", "start": 1483228817971, "tracked": true}]
[{"rawSteps": [], "source": "com.google.android.gms:estimated_steps", "steps": []}, {"rawSteps": [], "source": "com.google.android.gms:merge_step_deltas", "steps": []}, {"rawSteps": [], "source": "com.xiaomi.hm.health", "steps": []}]
Hey, So i keep getting a similar issue as other folks.
My code looks like
async authorize() {
// The list of available scopes inside of src/scopes.js file
const options = {
scopes: [
Scopes.FITNESS_ACTIVITY_READ,
Scopes.FITNESS_ACTIVITY_WRITE,
Scopes.FITNESS_BODY_READ,
Scopes.FITNESS_BODY_WRITE,
Scopes.FITNESS_LOCATION_READ,
Scopes.FITNESS_LOCATION_WRITE
]
};
const authResult = await GoogleFit.authorize(options);
return !!authResult?.success;
}
and i've gone through the instructions located here:
https://github.com/StasDoskalenko/react-native-google-fit/blob/master/docs/INSTALLATION.md#demo-walkthrough
I'm on react-native "react-native": "^0.66.3",
in my package.json
So I only went through the Demo Walkthrough (Development Setup)
but whenever i run the authorize
function i see this error.
caught error TypeError: Cannot read property 'isAuthorized' of undefined
at _callee2$ (index.android.js:62)
at tryCatch (runtime.js:63)
at Generator.invoke [as _invoke] (runtime.js:294)
at Generator.next (runtime.js:119)
at tryCatch (runtime.js:63)
at invoke (runtime.js:155)
at runtime.js:190
at tryCallTwo (core.js:45)
at doResolve (core.js:200)
at new Promise (core.js:66)
And i tracked it down to this code file
react-native-google-fit/index.android.js
Specifcally line #19:const googleFit = NativeModules.RNGoogleFit
NativeModules doesn't seem to have a module for RNGoogleFit
Is there something else i can try?
GoogleFit.isAuthorized
. It's quite misleading, I guess I will need to remove it at some point. It's a legacy implementation. It probably used to work in the past. It's not persisted in storage after you close your app or something happen during the app.authorize()
to guard through all your google fit call. It wouldn't cause duplicated login. It seems like google fit api auto handle the auth process even though you called multiple times.const success = await authorize();
if (success) {
//call your function here
}
Hey @aboveyunhai
I've changed my code to the following.
async authorize() {
// The list of available scopes inside of src/scopes.js file
const options = {
scopes: [
Scopes.FITNESS_ACTIVITY_READ,
Scopes.FITNESS_ACTIVITY_WRITE,
Scopes.FITNESS_BODY_READ,
Scopes.FITNESS_BODY_WRITE,
Scopes.FITNESS_LOCATION_READ,
Scopes.FITNESS_LOCATION_WRITE
]
};
let authResult;
try {
authResult = await GoogleFit.authorize(options);
} catch (err) {
console.error(err);
throw err;
}
return !!authResult?.success;
and i still receive the following error.
caught error TypeError: Cannot read property 'isAuthorized' of undefined
at _callee2$ (index.android.js:62)
at tryCatch (runtime.js:63)
at Generator.invoke [as _invoke] (runtime.js:294)
at Generator.next (runtime.js:119)
at tryCatch (runtime.js:63)
at invoke (runtime.js:155)
at runtime.js:190
at tryCallTwo (core.js:45)
at doResolve (core.js:200)
at new Promise (core.js:66)
I'm not directly referencing the isAuthorized
property in my code.