Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data for users who never used Google Fit #331

Open
kaishuvam7 opened this issue Dec 7, 2022 · 3 comments
Open

Data for users who never used Google Fit #331

kaishuvam7 opened this issue Dec 7, 2022 · 3 comments

Comments

@kaishuvam7
Copy link

This library has worked very well for us - so thank you again!

We're trying to make this work now for users who don't want to download Google Fit (which seems to be required to use our app).
We've noticed people who used to have the Fit app, but have uninstalled, are getting their data correctly. A new Google account, in comparison, is getting no data.

We've looked at and implemented most suggestions such as this helpful one, but nothing works for this specific case.

What could we be doing wrong? Do we have to write and then read the required data, or something else entirely?

Our scopes:

Scopes.FITNESS_ACTIVITY_READ,
Scopes.FITNESS_HEART_RATE_READ,
Scopes.FITNESS_LOCATION_READ,

Obtaining data:

static getFitnessData = async ({
    startDate,
    endDate,
    isSession = true,
    check = true,
  } = {}) => {
    console.log("getData>>>>");
    try {
      const fitnessFetchStart = moment();
      if (check) {
        const isFitnessAllowed = await Utils.getFitnessPermission();
        if (!isFitnessAllowed) return;
      }
      const interval = "hour";
      const bucketInterval = 1;
      var start = startDate.format(fitnessDateFormat);
      var end = endDate.format(fitnessDateFormat);
      // console.log({ startDate: start, endDate: end });
      const stps =
        Platform.OS === "android"
          ? await GoogleFit.getDailyStepCountSamples({
              startDate: startDate,
              endDate: endDate,
              bucketInterval,
            })
              .then((res) => {
                // console.log(
                //   "Daily steps >>>123123>>>>>",
                //   JSON.stringify(res[res.length - 1].steps)
                // );
                return res[res.length - 1]?.steps || [];
              })
              .catch((err) => {
                console.warn(err);
              })
          : await Fitness.getSteps({
              startDate: startDate,
              endDate: endDate,
              interval,
            });
      const cals =
        Platform.OS === "android"
          ? await GoogleFit.getDailyCalorieSamples({
              startDate: startDate,
              endDate: endDate,
              bucketInterval,
            })
              .then((res) => {
                // console.log("Daily cals >>> ", res);
                return res;
              })
              .catch((err) => {
                console.warn(err);
              })
          : await Fitness.getCalories({
              startDate: startDate,
              endDate: endDate,
              interval,
            });

      const dist =
        Platform.OS === "android"
          ? await GoogleFit.getDailyDistanceSamples({
              startDate: startDate,
              endDate: endDate,
              bucketInterval,
            })
              .then((res) => {
                // console.log("Daily Distance >>> ", res);
                return res;
              })
              .catch((err) => {
                console.warn(err);
              })
          : await Fitness.getDistances({
              startDate: startDate,
              endDate: endDate,
              interval,
            });
@shmkane
Copy link

shmkane commented Feb 21, 2024

Did you find some solution to this?

@ninjz
Copy link

ninjz commented Apr 21, 2024

@kaishuvam7 Did you end up coming with a solution for this?

@kaishuvam7
Copy link
Author

No - we were unable to. Thankfully, this segment of users proved to be small enough for it to not be a major worry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants