0% found this document useful (0 votes)
2 views4 pages

GoogleFit ReactNative Guide

This guide provides a step-by-step process for integrating Google Fit into a React Native app using Expo, either by ejecting the app or using a custom dev client. It covers necessary installations, Android permissions, Google Cloud Console setup, and writing the React Native code to fetch health data. Additionally, it suggests optional enhancements for charts and background sync functionalities.

Uploaded by

nallasujith.2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

GoogleFit ReactNative Guide

This guide provides a step-by-step process for integrating Google Fit into a React Native app using Expo, either by ejecting the app or using a custom dev client. It covers necessary installations, Android permissions, Google Cloud Console setup, and writing the React Native code to fetch health data. Additionally, it suggests optional enhancements for charts and background sync functionalities.

Uploaded by

nallasujith.2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Google Fit Integration in React Native (Expo Bare / Custom Dev Client)

This guide walks you through how to fetch smartwatch health data from Google Fit in a React Native

app using Expo (after ejecting or with a custom dev client).

---

STEP 1: Eject Expo App or Use Custom Dev Client

Option 1: Eject

$ npx expo eject

Option 2: Custom Dev Client

$ expo install react-native-google-fit

Add "react-native-google-fit" to plugins in app.json

$ eas build --profile development --platform android

---

STEP 2: Install Google Fit Package

$ npm install react-native-google-fit

$ npx pod-install

---

STEP 3: Android Permissions


In android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>

Add inside <application>:

<meta-data android:name="com.google.android.gms.version"

android:value="@integer/google_play_services_version"/>

---

STEP 4: Google Cloud Console Setup

1. Enable "Fitness API"

2. Create OAuth Client ID (type: Android)

3. Set package name (from app.json) and SHA1 key

Get SHA1 using:

$ keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android

-keypass android

---

STEP 5: Write React Native Code

import GoogleFit, { Scopes } from 'react-native-google-fit';

const options = {
scopes: [

Scopes.FITNESS_ACTIVITY_READ,

Scopes.FITNESS_ACTIVITY_WRITE,

Scopes.FITNESS_HEART_RATE_READ,

],

};

GoogleFit.authorize(options).then(authResult => {

if (authResult.success) {

GoogleFit.getDailyStepCountSamples({startDate: '2025-06-01T00:00:00.000Z', endDate: new

Date().toISOString()})

.then(res => console.log("Steps:", res));

GoogleFit.getHeartRateSamples({startDate: '2025-06-01T00:00:00.000Z', endDate: new

Date().toISOString()})

.then(res => console.log("Heart Rate:", res));

} else {

console.log("Auth failed", authResult.message);

});

---

STEP 6: Run on Device

$ expo run:android

Make sure the device has Google Fit app and permission to sync data from smartwatch.
---

Optional Enhancements:

- Charts: react-native-chart-kit

- Background sync: react-native-background-fetch

- Cloud sync: Appwrite, Firebase, etc.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy