{"_id":"@barnstable/react-native-fitness","_rev":"2-1ec46d65bf8e59cf2929767951439a61","name":"@barnstable/react-native-fitness","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@barnstable/react-native-fitness","version":"0.0.1","description":"A React Native package that gives you access to Apple kit and Google Fit data.","main":"./js/index.js","keywords":["react","native","react-native","health-kit","google-fit","fitness"],"author":{"name":"Andrew Noon"},"contributors":[{"name":"Andrew Noon","email":"andrew.noon@barn-stable.com"}],"license":"MIT","bugs":{"url":"https://github.com/Noony666/react-native-fitness/issues"},"homepage":"https://github.com/Noony666/react-native-fitness","peerDependencies":{"react-native":">=0.41.2"},"types":"./js/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/Noony666/react-native-fitness.git"},"_id":"@barnstable/react-native-fitness@0.0.1","gitHead":"5bb56eafe4a7516be40d9410ef4a47e719bfc247","_nodeVersion":"20.8.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-RS+oFX16zwE592JQ4gAHQwz9OQNTDA4g2KLiwM+ze5W4WbRLeazcqSZrsOvIQ1eeWzDFSxeaSFNHnYfSdGi+IA==","shasum":"1e0891d011bf3d5405025798ed5f5848ea269cc2","tarball":"https://registry.npmjs.org/@barnstable/react-native-fitness/-/react-native-fitness-0.0.1.tgz","fileCount":28,"unpackedSize":154070,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC0+HFnu+3b0YNEoFYoqXjkxwFkDwQONEkV0dw8oAz57QIgfI4qjEBX1GA+Nhw3pP/0T16yioIFSF8OPiQTVqEMnsc="}]},"_npmUser":{"name":"barnstable","email":"andrew.noon@resonateit.com.au"},"directories":{},"maintainers":[{"name":"barnstable","email":"andrew.noon@resonateit.com.au"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-native-fitness_0.0.1_1700476456585_0.22998798669871023"},"_hasShrinkwrap":false},"0.0.2":{"name":"@barnstable/react-native-fitness","version":"0.0.2","description":"A React Native package that gives you access to Apple kit and Google Fit data.","main":"./js/index.js","keywords":["react","native","react-native","health-kit","google-fit","fitness"],"author":{"name":"Andrew Noon"},"contributors":[{"name":"Andrew Noon","email":"andrew.noon@barn-stable.com"}],"license":"MIT","bugs":{"url":"https://github.com/Noony666/react-native-fitness/issues"},"homepage":"https://github.com/Noony666/react-native-fitness","peerDependencies":{"react-native":">=0.41.2"},"types":"./js/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/Noony666/react-native-fitness.git"},"_id":"@barnstable/react-native-fitness@0.0.2","gitHead":"5bb56eafe4a7516be40d9410ef4a47e719bfc247","_nodeVersion":"20.8.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-nFnX03hKn2NNNUNQxoTc0co5KA3pUWATTF9kng0YNIQ80wnZld3uXP+sm3c8exstkUvVcvAgC3zPYMlJpfKsPg==","shasum":"8c13909bd8cc8ea9dfe18d50eab1e966cc4d7c10","tarball":"https://registry.npmjs.org/@barnstable/react-native-fitness/-/react-native-fitness-0.0.2.tgz","fileCount":28,"unpackedSize":153633,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCKwkSnP8WEp2hhqW3AGDxqnNWPOpy/wrREeiW/z8SJVQIgOqiU3GTgvCCMuPbk7kelKy7jRPCZSVPPYK96pVvlD5Q="}]},"_npmUser":{"name":"barnstable","email":"andrew.noon@resonateit.com.au"},"directories":{},"maintainers":[{"name":"barnstable","email":"andrew.noon@resonateit.com.au"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-native-fitness_0.0.2_1700478118852_0.33171946677301856"},"_hasShrinkwrap":false},"0.0.3":{"name":"@barnstable/react-native-fitness","version":"0.0.3","description":"A React Native package that gives you access to Apple kit and Google Fit data.","main":"./js/index.js","keywords":["react","native","react-native","health-kit","google-fit","fitness"],"author":{"name":"Andrew Noon"},"contributors":[{"name":"Andrew Noon","email":"andrew.noon@barn-stable.com"}],"license":"MIT","bugs":{"url":"https://github.com/Noony666/react-native-fitness/issues"},"homepage":"https://github.com/Noony666/react-native-fitness","peerDependencies":{"react-native":">=0.41.2"},"types":"./js/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/Noony666/react-native-fitness.git"},"_id":"@barnstable/react-native-fitness@0.0.3","gitHead":"5bb56eafe4a7516be40d9410ef4a47e719bfc247","_nodeVersion":"20.8.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-nmsLRe0PfQu8nJgAn8Xnc7rAa9CQLokHQymYyTtWXxGLHGw5B1/Ky7+MpjdHyBxwFbXC/V2BREX4JkSI07jfqg==","shasum":"5c2c415d9a9b3226038b74e29c28a53deae26e01","tarball":"https://registry.npmjs.org/@barnstable/react-native-fitness/-/react-native-fitness-0.0.3.tgz","fileCount":28,"unpackedSize":153696,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICdpzYjaaCidQs4IfIvT/5wd+Y4QIozl58CVEgwlUBGYAiAsaPU7jTSygM4xnTYWBOyQhBxLxfOX7K9BVIjGeXcpbQ=="}]},"_npmUser":{"name":"barnstable","email":"andrew.noon@resonateit.com.au"},"directories":{},"maintainers":[{"name":"barnstable","email":"andrew.noon@resonateit.com.au"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-native-fitness_0.0.3_1700478789850_0.8528054900749982"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-20T10:34:16.463Z","0.0.1":"2023-11-20T10:34:16.796Z","modified":"2023-11-20T11:13:10.264Z","0.0.2":"2023-11-20T11:01:59.050Z","0.0.3":"2023-11-20T11:13:10.075Z"},"maintainers":[{"name":"barnstable","email":"andrew.noon@resonateit.com.au"}],"description":"A React Native package that gives you access to Apple kit and Google Fit data.","homepage":"https://github.com/Noony666/react-native-fitness","keywords":["react","native","react-native","health-kit","google-fit","fitness"],"repository":{"type":"git","url":"git+https://github.com/Noony666/react-native-fitness.git"},"contributors":[{"name":"Andrew Noon","email":"andrew.noon@barn-stable.com"}],"author":{"name":"Andrew Noon"},"bugs":{"url":"https://github.com/Noony666/react-native-fitness/issues"},"license":"MIT","readme":"\r\n# react-native-fitness\r\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.\r\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.\r\n\r\nNote:\r\nWe're open to receive PRs that contains new features or improvements, so feel free to contribute to this repo.\r\n\r\n## Getting started\r\n\r\n`npm install @ovalmoney/react-native-fitness --save`\r\n\r\nor\r\n\r\n`yarn add @ovalmoney/react-native-fitness`\r\n\r\n### Mostly automatic installation\r\n\r\n`react-native link @ovalmoney/react-native-fitness`\r\n\r\n### Manual installation\r\n\r\n\r\n#### iOS\r\n\r\n### Pods\r\n1. Add the line below to your `Podfile`.\r\n    ```pod\r\n    pod 'react-native-fitness', :path => '../node_modules/@ovalmoney/react-native-fitness'`\r\n    ```\r\n2. Run `pod install` in your iOS project directory.\r\n3. In XCode, select your project, go to `Build Phases` ➜ `Link Binary With Libraries` and add `libreact-native-fitness.a`.\r\n4. Add following to your `Info.plist` in order to ask permissions.\r\n    ```xml\r\n    <key>NSHealthShareUsageDescription</key>\r\n    <string>Read and understand health data.</string>\r\n    ```\r\n\r\n### Manually\r\n\r\n1. In XCode's project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`\r\n2. Go to `node_modules` ➜ `@ovalmoney` ➜ `react-native-fitness` and select `RNFitness.xcodeproj`\r\n3. In XCode select your project, go to `Build Phases` ➜ `Link Binary With Libraries` and add `libRNFitness.a`.\r\n4. Run your project (`Cmd+R`)\r\n\r\nIn order to make it run, it is necessary to turn on `Health Kit` in the `Capabilities`.\r\n\r\n#### Android\r\n1. Get an OAuth 2.0 Client ID as explained at https://developers.google.com/fit/android/get-api-key\r\n2. Open up `MainApplication.java`\r\n    - Add `import com.ovalmoney.fitness.RNFitnessPackage;` to the imports at the top of the file\r\n    - Add `new RNFitnessPackage()` to the list returned by the `getPackages()` method\r\n3. Append the following lines to `android/settings.gradle`:\r\n  \t```java\r\n  \tinclude ':@ovalmoney_react-native-fitness'\r\n  \tproject(':@ovalmoney_react-native-fitness').projectDir = new File(rootProject.projectDir, \t'../node_modules/@ovalmoney/react-native-fitness/android')\r\n  \t```\r\n4. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\r\n  \t```java\r\n    compile project(':@ovalmoney_react-native-fitness')\r\n  \t```\r\n5. (Optional) In order to better handle the right versions, add in your `android/build.gradle`:\r\n  \t```ext {\r\n      // Other build versions\r\n      fitnessPlayServices: \"<Your version>\" // default: 17.0.0\r\n      authPlayServices: \"<Your version>\" // default: 17.0.0\r\n    }\r\n  \t```\r\n\r\n## Usage\r\n\r\n```javascript\r\nimport Fitness from '@ovalmoney/react-native-fitness';\r\n\r\nconst permissions = [\r\n  { kind: Fitness.PermissionKinds.Steps, access: Fitness.PermissionAccesses.Write },\r\n];\r\n\r\nFitness.isAuthorized(permissions)\r\n  .then((authorized) => {\r\n    // Do something\r\n  })\r\n  .catch((error) => {\r\n    // Do something\r\n  });\r\n```\r\n### API\r\n\r\n- **Fitness.isAuthorized([{ kind: int, access: int }])**\r\nCheck if permissions are granted or not. It works on Android and iOS >= 12.0, while it returns an error when iOS < 12.\r\nIt requires an `Array` of `Object` with a mandatory key `kind` and an optional key `access`.\r\nPossible values for the keys can be found in `PermissionKinds` and `PermissionAccesses` under `Attributes` section.\r\nOn iOS at least one permissions with `Read` access must be provided, otherwise an `errorEmptyPermissions` will be thrown.\r\n\r\n- **Fitness.requestPermissions([{ kind: int, access: int }])**\r\nAsk permission and return if user granted or not(Android), while, due to Apple's privacy model, always true is returned in iOS.\r\nIt requires an `Array` of `Object` with a mandatory key `kind` and an optional key `access`.\r\nPossible values for the keys can be found in `PermissionKinds` and `PermissionAccesses` under `Attributes` section.\r\nOn iOS at least one permissions with `Read` access must be provided, otherwise an `errorEmptyPermissions` will be thrown.\r\n\r\n- **Fitness.logout()**\r\nAvailable only on android. It performs a logout from google account.\r\nIt returns `true` for a successful logout, `false` if user cancel action.\r\n\r\n- **Fitness.disconnect()**\r\nAvailable only on android. It performs a disconnect action from Google Fit.\r\nIt returns `true` for a successful logout, `false` if user cancel action.\r\n\r\n- **Fitness.getSteps({ startDate: string, endDate: string, interval: string })**\r\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`.\r\n\r\n- **Fitness.getDistances({ startDate: string, endDate: string, interval: string })**\r\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`.\r\n\r\n- **Fitness.getCalories({ startDate: string, endDate: string, interval: string })**\r\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`.\r\n\r\n- **Fitness.getHeartRate({ startDate: string, endDate: string, interval: string })**\r\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`.\r\n\r\n- **Fitness.getSleepAnalysis({ startDate: string, endDate: string })**\r\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.\r\n\r\n- **Fitness.subscribeToSteps()**\r\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.\r\nCall this function to get steps and eliminate the need to have Google Fit installed on the device.\r\n\r\n### Attributes\r\n\r\n#### Platform\r\nReturn the used provider.\r\n\r\n#### PermissionKinds\r\nReturn the information of what kind of Permission can be asked.\r\nAt the moment the list of possible kinds is:\r\n - ***Steps***: to required the access for `Steps`\r\n - ***Distances***: to required the access for `Distances`\r\n - ***Calories***: to required the access for `Calories`\r\n - ***HeartRate***: to required the access for `Heart rate`\r\n - ***Activity***: to required the access for `Activity` (only Android)\r\n - ***SleepAnalysis***: to required the access for `Sleep Analysis`\r\n\r\n\r\n#### PermissionAccesses\r\nReturn the information of what kind of Access can be asked.\r\nThe list of possible kinds is:\r\n - ***Read***: to required the access to `Read`\r\n - ***Write***: to required the access to `Write`\r\n\r\n#### Errors\r\nReturn the list of meaningful errors that can be possible thrown.\r\n\r\n##### iOS\r\nPossible values are:\r\n - ***hkNotAvailable***: thrown if HealthKit is not available\r\n - ***methodNotAvailable***: thrown if `isAuthorized` is called on iOS < 12.0\r\n - ***dateNotCorrect***: thrown if received date is not correct\r\n - ***errorEmptyPermissions***: thrown if no read permissions are provided\r\n - ***errorNoEvents***: thrown if an error occurs while try to retrieve data\r\n\r\n##### Android\r\nPossible values are:\r\n - ***methodNotAvailable***: thrown if `getSleepAnalysis` is called on Android less than N\r\n\r\n\r\n","readmeFilename":"README.md"}