Where communities thrive


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

    I need help.
    So I have fixed without Expo and sure it is working sucess after auth with RN-Cli. But!
    I don't understand how to get sampels from steps
    Why I get error dates and adjustment
    and also other error like com.reactnative.googlefit.StepHistory, com.reactnative.googlefit.GoogleFitManager.getSTepHistory()

    I went to check example
    but there are no demo examples how to get steps ...

    So here is mine

    /**  
     * Sample React Native App * https://github.com/facebook/react-native * * @format  
      * @flow strict-local  
     */  
    import type { Node } from "react";  
    import React, { useEffect } from "react";  
    import GoogleFit, { BucketUnit, Scopes } from "react-native-google-fit";  
    import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, useColorScheme, View } from "react-native";  
    
    import {  
      Colors,  
      DebugInstructions,  
      Header,  
      LearnMoreLinks,  
      ReloadInstructions,  
    } from "react-native/Libraries/NewAppScreen";  
    
    const Section = ({ children, title }): Node => {  
      const isDarkMode = useColorScheme() === "dark";  
     return (  
        <View style={styles.sectionContainer}>  
     <Text  style={[  
              styles.sectionTitle,  
      {  
                color: isDarkMode ? Colors.white : Colors.black,  
      },  
      ]}>  
      {title}  
          </Text>  
     <Text  style={[  
              styles.sectionDescription,  
      {  
                color: isDarkMode ? Colors.light : Colors.dark,  
      },  
      ]}>  
      {children}  
          </Text>  
     </View>  );  
    };  
    
    const App = () => {  
      const isDarkMode = useColorScheme() === "dark";  
    
     const backgroundStyle = {  
        backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,  
      };  
      useEffect(() => {  
    
        const options = {  
          scopes: [  
            Scopes.FITNESS_ACTIVITY_READ,  
      Scopes.FITNESS_ACTIVITY_WRITE,  
      Scopes.FITNESS_BODY_READ,  
      Scopes.FITNESS_BODY_WRITE,  
      ],  
      };  
      GoogleFit.authorize(options)  
          .then(authResult => {  
            if (authResult.success) {  
              console.log("AUTH SUCESS");  
      } else {  
              console.error("AUTH DENIED", authResult);  
      }  
          })  
          .catch(() => {  
            console.log("AUTH_ERROR");  
      });  
      });  
    
      GoogleFit.startRecording((callback) => {  
        // Process data from Google Fit Recording API (no google fit app needed)  
      });  
    
     const opt = {  
        startDate: "2017-01-01T00:00:17.971Z", // required ISO8601Timestamp  
      endDate: new Date().toISOString(), // required ISO8601Timestamp  
      bucketUnit: BucketUnit.DAY, // optional - default "DAY". Valid values: "NANOSECOND" | "MICROSECOND" | "MILLISECOND" | "SECOND" | "MINUTE" | "HOUR" | "DAY"  
      bucketInterval: 1, // optional - default 1.  
      };  
    
      GoogleFit.getDailyStepCountSamples(opt)  
        .then((res) => {  
          console.log('Daily steps >>> ', res)  
        })  
        .catch((err) => {console.warn(err)});  
    
    // or with async/await syntax  
      async function fetchData() {  
        const res = await GoogleFit.getDailyStepCountSamples(opt)  
      console.log(res);  
      }  
    
    // shortcut functions,  
    // return weekly or daily steps of given date  
    // all params are optional, using new Date() without given date,  
    // adjustment is 0 by default, determine the first day of week, 0 == Sunday, 1==Monday, etc.  
      GoogleFit.getDailySteps(date).then().catch()  
      GoogleFit.getWeeklySteps(date, adjustment).then().catch()  
    
    
      return (  
        <SafeAreaView style={backgroundStyle}>  
     <StatusBar barStyle={isDarkMode ? "light-content" : "dark-content"} />  
     <ScrollView  contentInsetAdjustmentBehavior="automatic"  
      style={backgroundStyle}>  
     <Header /> <View  style={{  
                backgroundColor: isDarkMode ? Colors.black
    Douglas-Hsieh
    @Douglas-Hsieh
    Hey, thanks for the package! It looks like there aren't methods for getting Heart Points, Step Count Cadence. Any plans to support those?
    Phước Thiện Đỗ
    @twins23:matrix.org
    [m]
    @aboveyunhai: Hi my boy
    I need some help!🤕
    Phước Thiện Đỗ
    @twins23:matrix.org
    [m]
    I ran app on real device by USB
    @sykenrussel
    Thien
    @twins23:matrix.org
    [m]
    I am always getting empty []
    Aloynz
    @Aloynz
    can i work with expo-cli instead of rn-cli to use the google fit api for my react native proj
    박건태
    @eatnug

    I just started working on daily step counter. for those who don't want users to access health kit for google fit api would like it.

    https://github.com/eatnug/react-native-daily-step-counter