GoogleFit on iphone: problem with REST API calls

384 Views Asked by At

I'm trying to query, with the Fit rest API, segmented data from an iphone that have installed GoogleFit and configured the sync between apple health and googelfit.

To my android phone, I get the data as expected with this POST:

(*)

  "aggregateBy": [
    {
      "dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
      "dataTypeName": "com.google.step_count.delta"
    },
    {
      "dataSourceId": "derived:com.google.distance.delta:com.google.android.gms:merge_distance_delta",
      "dataTypeName": "com.google.distance.delta"
    }
    {
      "dataSourceId": "derived:com.google.active_minutes:com.google.android.gms:merge_active_minutes",
      "dataTypeName": "com.google.active_minutes"
    }
  ],
  "endTimeMillis": 1643325227000,
  "startTimeMillis": 1640991600000,
  "bucketByActivitySegment": {
    "minDurationMillis": 600000
  }

}

But from the iphone user, this returns an empty bucket.

I checked the available data dataSources for the apple user. I did some "trial and error" on the dataSourceIds connected to "active_minutes". In particular

  1. derived:com.google.active_minutes:com.google.ios.fit:appleinc.:iphone:1148c16f:top_level
  2. derived:com.google.active_minutes:com.google.ios.fit:appleinc.:watch:f40f5c4a:top_level

The trial and error werer conducted with aggregateBy post with one of the above sources, so no distance and step_count involved. The two above dataSourceIds were obtained from a "list post query" for available dataSources, done by the iphone user, with the following scopes:

fitness.activity.read
fitness.location.read

No segmented data is returned from either dataSourceIds (an empty bucket as well). Contents within the apple user's app indicates that there should be segmented data somewhere, see screenshot link.

(Edit: also tried setting "minDurationMillis: 0")

Meanwhile, queries such as:

(**)

{
  "aggregateBy": [
    {
      "dataSourceId": "derived:com.google.distance.delta:com.google.android.gms:merge_distance_delta",
      "dataTypeName": "com.google.distance.delta"
    }
  ],
  "endTimeMillis": 1643325227000,
  "startTimeMillis": 1640991600000,
  "bucketByTime": {
    "durationMillis": 2333627000
  }
}

does return data from the apple user. But I'm really interested in segments (minimum 10 minutes long)

So, question: Anyone with experience getting segmented data from apple-googlefit users?

Figure: iphone screenshot

1

There are 1 best solutions below

0
On

Update.

Since (**) (see first post) did return data from the iphones, I went with a 1-hour "bucketByTime"-solution for both androids and iphones.

If segments is important, it is possible to parse/filter the "bucketByTime" data into segments. However, activity type is not obtained with this POST.

New problem(s) have arisen:

As mentioned, (**) POST returned data. Particularly when:

"startTimeMillis" = [start of 2022]

and

"endTimeMillis" = [now].

A cron executor is configured such that (**) is repeated once a day where:

"startTimeMillis" = ["previous now"]

and

"endTimeMillis" = [now].

However, this does not return any data from the iphone users. To clarify, no daily data is received from the iphones.

Some preformed check-ups:

  1. The iphone users see data as normal on the front-end view of the GoogleFit app (see screenshot link in first post).
  2. Attempted (**) with every "dataStreamId" and "name" available (returned from "list post query" for available dataSources) - Nothing is returned.
  3. Asked the iphone users to check GoogleFit's permissions, in accordance with this support page. (I'll have to take their word that it's configured correctly)

Important finding:

For one iphone user, "incomplete"[2] data is occasionally returned. I'm imagining this data is data recorded by his apple watch. I asked him to wear his watch today.

You'd figure, when asking for eg. merge_distance_delta the app merges the available sources into a neat timeline. Questions on this level is not available publicly (to my knowledge).

[2] The sum does not (come close) to matching the GoogleFiT front-end results (as it does for the android users).