Q: "Not connected to Health Connect"

DisastrousLark1 month ago

Always in react native , when get any data through SDK for google fit it throws error "Not connected to Health Connect" even manually permitted our app in health connect and sync health connect in google fit app

terra

Chandruadmin1 month ago

Hey there

This error could be caused by a number of issues, for example:

  1. If the sufficient permissions have not been configured in your apps manifest (follow this guide)
  2. You are building in Release mode and not debug mode, before getting approval to use Google Health data in production. To get permissions you will need to submit an application with this form
  3. The user has revoked health connect permissions on their end

Google Fit with REST API

However, the best way to get data from Google Fit is to use our Webhook API or our REST services as Google Fit is cloud based and data can be retrieved without the need for the SDK. You can authenticate a user by generating a Google Auth URL and then making a GET request for the data you would like, for example:

const options = { method: 'GET', headers: { accept: 'application/json', 'dev-id': '<YOUR-DEV-ID>' 'x-api-key': '<YOUR-API-KEY>' } }; const data = fetch(`https://api.tryterra.co/v2/activity?start_date=2024-05-01&to_webhook=false&with_samples=true&user_id=<USER-ID>`, options) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err));

Hope this has clarified your issue!


DisastrousLark1 month ago

I run in debug . In sdk , after allow all permission from health connect trigger by terra-react .still show error as "Not connected health connect". when use you given fetch method throws error as "GOOGLEFIT does not support REST API requests. Please request data within the SDK instead."


terra

Chandruadmin1 month ago

Hey

To clarify, the most optimal method for retrieving data from Google is to authenticate the users' Google account using our REST api services, either via our widget or our /authenticateUser?resource=GOOGLE endpoint. Both options will provide you a url that you can display in a webview or the browser.

This way, you can retrieve Google data without needing the SDK. The SDKs are the only option if you wish to retrieve data from Samsung and Apple Health.