Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    aboveyunhai
    @aboveyunhai
    @enestatli I don't think you need to install any extra tools. But for other things you need to test it out locally by yourself
    enestatli
    @enestatli
    @aboveyunhai So can you please update the installation.MD :)
    I am trying test locally and kept getting same popup lol
    enestatli
    @enestatli
    Hello all, is there a way to write calories?
    hamzapiri
    @hamzapiri
    hi, can i use this lib in expo ?
    aboveyunhai
    @aboveyunhai

    hi, can i use this lib in expo ?

    you can use any native modules in expo bareflow. But there are some drawbacks. You need to check expo doc by yourself.

    ROBERT LI
    @lclrobert2020_gitlab
    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?
    aboveyunhai
    @aboveyunhai

    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

    Lisa
    @lloncham
    Hey guys, it's been three days thats i try to use this library, i create my OAuth 2.0, change my google-services.json, add the 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?
    aboveyunhai
    @aboveyunhai
    @lloncham I just create a quick walkthrough in documentation since a lot of people were asking the same problem over and over again
    If anyone didn't know how to do the authentication. just check the walkthrough step.
    I just quickly create a working sample based on it.
    Lisa
    @lloncham
    Thanks @aboveyunhai ! I just checked and everything has been done ... I don't know if react native fitness work at the same way but this library is working. My app is already publish then I can't add myself as a user tester, but should work even with that, right?
    solvd-mmelnyk
    @solvd-mmelnyk
    hey!
    can we somehow ask user to install Google Fit application if user does not have it on device?
    aboveyunhai
    @aboveyunhai
    @solvd-mmelnyk use deep link to open app store.
    solvd-mmelnyk
    @solvd-mmelnyk
    @aboveyunhai how can I know if Google Fit installed or no?
    Lloyd Dsouza
    @write2lloyd_twitter
    Hello everyone, I'm using this lib in an app to return Steps, Exercise and Sleep. It works great. There is one issue with Exercise though. If I delete an Exercise session in the Google Fit App, the getActivitySamples functions still returns that deleted session. Did a lot of searching but could not find if this is Google caching data on their servers or something else. Any clarity on this would be appreciated.
    Lloyd Dsouza
    @write2lloyd_twitter
    Seems like the deleted activity comes back as activityName = 'still' . So for now Im filtering it from the results for now.
    aboveyunhai
    @aboveyunhai
    @write2lloyd_twitter
    I cannot confirm whether the problem is from our code or Google Side, but since you mention it becomes 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.
    Airat Galiullin
    @galiullin_airat_twitter
    @StasDoskalenko Hi, is it possible to write a mindfulness data with your framework?
    aboveyunhai
    @aboveyunhai
    @galiullin_airat_twitter do you mean meditation?
    Airat Galiullin
    @galiullin_airat_twitter
    @aboveyunhai yes
    aboveyunhai
    @aboveyunhai
    @galiullin_airat_twitter currently no, if you ever check issues, there are many related to create activity data including meditation, etc. I'm actually on the feature and it's going to be the next release. But I'm currently busy with other projects.
    chamile
    @chamile
    Hi guys, I'm facing this strange message after doing all those installation steps correctly, can anybody give me some insights AUTH_DENIED. {
    "success": false,
    "message": "Authorization cancelled"
    }
    Soham
    @shmkane

    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?

    jsriganesh
    @jsriganesh
    Hi guys ... i have integrate the google fit and i have select the my primary mail id Then ... screen is continuously loading
    WhatsApp Image 2021-10-08 at 10.35.33.jpeg
    jsriganesh
    @jsriganesh
    {"message": "Authorization cancelled", "success": false}
    sykenrussel
    @sykenrussel
    Hi I tried doing the npm install as well as import GoogleFit, { Scopes } from 'react-native-google-fit'; but the authorization is still false
    sykenrussel
    @sykenrussel
    @aboveyunhai

    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.

    aboveyunhai
    @aboveyunhai
    @sykenrussel My best guess it to try to safely wrap your function inside Auth check. Individual call without auth check can fail or be interrupted under any circumstances.
    const auth = await GoogleFit.authorize(options);
    if (auth.success or auth) {
     call your function here
    }
    sykenrussel
    @sykenrussel
    @aboveyunhai thanks that works now! Would have been better if that was mentioned in the documentation haha
    image.png
    @aboveyunhai is it also normal that the output is like this?
    [{"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": []}]
    I am using android virtual emulator so would that be a possible cause?
    sykenrussel
    @sykenrussel
    I also get empty arrays even if I had set the options to minutes and the intervals to 15 as was mentioned here: StasDoskalenko/react-native-google-fit#207
    aboveyunhai
    @aboveyunhai
    @sykenrussel it's expected the result you would get. You need to try it in real device to record at least some data. Existing data that aren't from your app wouldn't be caught ussually
    sykenrussel
    @sykenrussel
    Ohhh dang what about the output just being []?
    image.png
    1 reply
    aboveyunhai
    @aboveyunhai
    @sykenrussel it means you currently had no data. If you don't have or record data by this app. What do you expect? By default it wouldn't read data recorded by other app.
    sykenrussel
    @sykenrussel
    Does it get the data from my google fit account then?
    sykenrussel
    @sykenrussel
    image.png
    Hi my step results are all object is there something wrong with it?
    Sean Noxious
    @SeanNoxious_twitter

    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?

    aboveyunhai
    @aboveyunhai
    @SeanNoxious_twitter Never trust the 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.
    Instead, use your 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 
    }
    Sean Noxious
    @SeanNoxious_twitter
    I believe i have tried this and it's still not working but let me give it a go and I'll let you know.
    Sean Noxious
    @SeanNoxious_twitter
    image.png

    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.