{"id":4769,"url":"https://github.com/OvalMoney/react-native-fitness","last_synced_at":"2025-08-04T02:31:37.711Z","repository":{"id":43113856,"uuid":"162406751","full_name":"OvalMoney/react-native-fitness","owner":"OvalMoney","description":" A React Native module to interact with Apple Healthkit and Google Fit.","archived":false,"fork":false,"pushed_at":"2022-01-12T08:17:22.000Z","size":252,"stargazers_count":354,"open_issues_count":25,"forks_count":66,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-09T22:46:39.730Z","etag":null,"topics":["android","apple-health","fitness","google-fit","ios","react-native"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OvalMoney.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-19T08:30:27.000Z","updated_at":"2025-04-03T11:38:51.000Z","dependencies_parsed_at":"2022-09-17T11:01:04.651Z","dependency_job_id":null,"html_url":"https://github.com/OvalMoney/react-native-fitness","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/OvalMoney/react-native-fitness","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OvalMoney%2Freact-native-fitness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OvalMoney%2Freact-native-fitness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OvalMoney%2Freact-native-fitness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OvalMoney%2Freact-native-fitness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OvalMoney","download_url":"https://codeload.github.com/OvalMoney/react-native-fitness/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OvalMoney%2Freact-native-fitness/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268639931,"owners_count":24282678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","apple-health","fitness","google-fit","ios","react-native"],"created_at":"2024-01-05T20:17:22.730Z","updated_at":"2025-08-04T02:31:36.933Z","avatar_url":"https://github.com/OvalMoney.png","language":"Java","funding_links":[],"categories":["Components"],"sub_categories":["Integrations"],"readme":"\n# react-native-fitness\n`react-native-fitness` is a library that works on both `iOS` and `Android` with it you can interact with Apple Healthkit and Google Fit.\nCurrently the lib provides a set of [API](#API) that you can use to read steps count or distance count for a given period of time.\n\nNote:\nWe're open to receive PRs that contains new features or improvements, so feel free to contribute to this repo.\n\n## Getting started\n\n`npm install @ovalmoney/react-native-fitness --save`\n\nor\n\n`yarn add @ovalmoney/react-native-fitness`\n\n### Mostly automatic installation\n\n`react-native link @ovalmoney/react-native-fitness`\n\n### Manual installation\n\n\n#### iOS\n\n### Pods\n1. Add the line below to your `Podfile`.\n    ```pod\n    pod 'react-native-fitness', :path =\u003e '../node_modules/@ovalmoney/react-native-fitness'`\n    ```\n2. Run `pod install` in your iOS project directory.\n3. In XCode, select your project, go to `Build Phases` ➜ `Link Binary With Libraries` and add `libreact-native-fitness.a`.\n4. Add following to your `Info.plist` in order to ask permissions.\n    ```xml\n    \u003ckey\u003eNSHealthShareUsageDescription\u003c/key\u003e\n    \u003cstring\u003eRead and understand health data.\u003c/string\u003e\n    ```\n\n### Manually\n\n1. In XCode's project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`\n2. Go to `node_modules` ➜ `@ovalmoney` ➜ `react-native-fitness` and select `RNFitness.xcodeproj`\n3. In XCode select your project, go to `Build Phases` ➜ `Link Binary With Libraries` and add `libRNFitness.a`.\n4. Run your project (`Cmd+R`)\n\nIn order to make it run, it is necessary to turn on `Health Kit` in the `Capabilities`.\n\n#### Android\n1. Get an OAuth 2.0 Client ID as explained at https://developers.google.com/fit/android/get-api-key\n2. Open up `MainApplication.java`\n    - Add `import com.ovalmoney.fitness.RNFitnessPackage;` to the imports at the top of the file\n    - Add `new RNFitnessPackage()` to the list returned by the `getPackages()` method\n3. Append the following lines to `android/settings.gradle`:\n  \t```java\n  \tinclude ':@ovalmoney_react-native-fitness'\n  \tproject(':@ovalmoney_react-native-fitness').projectDir = new File(rootProject.projectDir, \t'../node_modules/@ovalmoney/react-native-fitness/android')\n  \t```\n4. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\n  \t```java\n    compile project(':@ovalmoney_react-native-fitness')\n  \t```\n5. (Optional) In order to better handle the right versions, add in your `android/build.gradle`:\n  \t```ext {\n      // Other build versions\n      fitnessPlayServices: \"\u003cYour version\u003e\" // default: 17.0.0\n      authPlayServices: \"\u003cYour version\u003e\" // default: 17.0.0\n    }\n  \t```\n\n## Usage\n\n```javascript\nimport Fitness from '@ovalmoney/react-native-fitness';\n\nconst permissions = [\n  { kind: Fitness.PermissionKinds.Steps, access: Fitness.PermissionAccesses.Write },\n];\n\nFitness.isAuthorized(permissions)\n  .then((authorized) =\u003e {\n    // Do something\n  })\n  .catch((error) =\u003e {\n    // Do something\n  });\n```\n### API\n\n- **Fitness.isAuthorized([{ kind: int, access: int }])**\nCheck if permissions are granted or not. It works on Android and iOS \u003e= 12.0, while it returns an error when iOS \u003c 12.\nIt requires an `Array` of `Object` with a mandatory key `kind` and an optional key `access`.\nPossible values for the keys can be found in `PermissionKinds` and `PermissionAccesses` under `Attributes` section.\nOn iOS at least one permissions with `Read` access must be provided, otherwise an `errorEmptyPermissions` will be thrown.\n\n- **Fitness.requestPermissions([{ kind: int, access: int }])**\nAsk permission and return if user granted or not(Android), while, due to Apple's privacy model, always true is returned in iOS.\nIt requires an `Array` of `Object` with a mandatory key `kind` and an optional key `access`.\nPossible values for the keys can be found in `PermissionKinds` and `PermissionAccesses` under `Attributes` section.\nOn iOS at least one permissions with `Read` access must be provided, otherwise an `errorEmptyPermissions` will be thrown.\n\n- **Fitness.logout()**\nAvailable only on android. It performs a logout from google account.\nIt returns `true` for a successful logout, `false` if user cancel action.\n\n- **Fitness.disconnect()**\nAvailable only on android. It performs a disconnect action from Google Fit.\nIt returns `true` for a successful logout, `false` if user cancel action.\n\n- **Fitness.getSteps({ startDate: string, endDate: string, interval: string })**\nFetch steps on a given period of time. It requires an `Object` with `startDate` and `endDate` attributes as string. If startDate is not provided an error will be thrown. Set `interval` to decide how detailed the returned data is, set it to `hour` or `minute` otherwise it defaults to `days`.\n\n- **Fitness.getDistances({ startDate: string, endDate: string, interval: string })**\nFetch distance in meters on a given period of time. It requires an `Object` with `startDate` and `endDate` attributes as string. If startDate is not provided an error will be thrown. Set `interval` to decide how detailed the returned data is, set it to `hour` or `minute` otherwise it defaults to `days`.\n\n- **Fitness.getCalories({ startDate: string, endDate: string, interval: string })**\nFetch calories burnt in kilocalories on a given period of time. It requires an `Object` with `startDate` and `endDate` attributes as string. If startDate is not provided an error will be thrown. Set `interval` to decide how detailed the returned data is, set it to `hour` or `minute` otherwise it defaults to `days`.\n\n- **Fitness.getHeartRate({ startDate: string, endDate: string, interval: string })**\nFetch heart rate bpm on a given period of time. It requires an `Object` with `startDate` and `endDate` attributes as string. If startDate is not provided an error will be thrown. Set `interval` to decide how detailed the returned data is, set it to `hour` or `minute` otherwise it defaults to `days`.\n\n- **Fitness.getSleepAnalysis({ startDate: string, endDate: string })**\nFetch sleep analysis data on a given period of time. It requires an `Object` with `startDate` and `endDate` attributes as string. If startDate is not provided an error will be thrown.\n\n- **Fitness.subscribeToSteps()**\nAvailable only on android. Subscribe only to steps from the Google Fit store. It returns a promise with `true` for a successful subscription and `false` otherwise.\nCall this function to get steps and eliminate the need to have Google Fit installed on the device.\n\n### Attributes\n\n#### Platform\nReturn the used provider.\n\n#### PermissionKinds\nReturn the information of what kind of Permission can be asked.\nAt the moment the list of possible kinds is:\n - ***Steps***: to required the access for `Steps`\n - ***Distances***: to required the access for `Distances`\n - ***Calories***: to required the access for `Calories`\n - ***HeartRate***: to required the access for `Heart rate`\n - ***Activity***: to required the access for `Activity` (only Android)\n - ***SleepAnalysis***: to required the access for `Sleep Analysis`\n\n\n#### PermissionAccesses\nReturn the information of what kind of Access can be asked.\nThe list of possible kinds is:\n - ***Read***: to required the access to `Read`\n - ***Write***: to required the access to `Write`\n\n#### Errors\nReturn the list of meaningful errors that can be possible thrown.\n\n##### iOS\nPossible values are:\n - ***hkNotAvailable***: thrown if HealthKit is not available\n - ***methodNotAvailable***: thrown if `isAuthorized` is called on iOS \u003c 12.0\n - ***dateNotCorrect***: thrown if received date is not correct\n - ***errorEmptyPermissions***: thrown if no read permissions are provided\n - ***errorNoEvents***: thrown if an error occurs while try to retrieve data\n\n##### Android\nPossible values are:\n - ***methodNotAvailable***: thrown if `getSleepAnalysis` is called on Android less than N\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOvalMoney%2Freact-native-fitness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOvalMoney%2Freact-native-fitness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOvalMoney%2Freact-native-fitness/lists"}