Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    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.

    image.png
    Sean Noxious
    @SeanNoxious_twitter
    Sorry to be a bother but not really able to make any progress here. Anyone have any suggestions?
    sykenrussel
    @sykenrussel
    As much as I'd like to help you I think google made some changes that make this RN package difficult to work with
    Sean Noxious
    @SeanNoxious_twitter
    i ended up just using some old code i found on github randomly.
    Soham
    @shmkane
    @sykenrussel what changes in Google? And what exactly are the effects in the rn package?
    sykenrussel
    @sykenrussel
    well firstly it returns an object when i call in steps
    image.png
    How do I get that output? I tried using bucketUnit: BucketUnit.Minute and interval at 15 but I keep getting aggregated results
    image.png
    sykenrussel
    @sykenrussel
    I cant seem to choose the estimated as the datasource
    aboveyunhai
    @aboveyunhai

    you cant really choose the source, source just indicates the where the data comes from.
    it could come from some legacy code, and Google Fit store can't really tell you the true source once multiple data source existed in the same time span. You should rely on the data itself instead of text description.
    As far as I know, those description can be customized by implementation if you truly want to.

    For production usage, a well craft app should store customize user data by themselves and let google fit do all the fitness data work, of cuz, under whatever Google Fit Data guideline if the data involved some data policies.

    sykenrussel
    @sykenrussel
    I see. Is it possible to get minute by minute workout data?
    14 replies
    image.png
    Like that is the options I used but it still returns it as aggregate
    Screenshot_20211130-130819.jpg
    Like I want to get those data, but using the package it just aggregates it
    sykenrussel
    @sykenrussel
    image.png
    image.png
    sumitmaurya1
    @sumitmaurya1
    sds
    I am getting scopes issue while working with react-native-google-fit
    ======================= error ============================
    error: cannot find symbol
    GoogleSignInAccount gsa = GoogleSignIn.getAccountForScopes(mReactContext, new Scope(Scopes.FITNESS_ACTIVITY_READ));
    ^
    symbol: variable FITNESS_ACTIVITY_READ
    location: class com.google.android.gms.common.Scopes
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    aboveyunhai
    @aboveyunhai
    Read the discussion here for scope issue: StasDoskalenko/react-native-google-fit#268
    lucapaciello-tech4care
    @lucapaciello-tech4care
    hi. I have a question: does this library works for ios too?
    1 reply