diff --git a/404.html b/404.html index 85630ec..db5b7d9 100644 --- a/404.html +++ b/404.html @@ -4,13 +4,13 @@ Page Not Found | React Native Health Connect - +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

- + \ No newline at end of file diff --git a/assets/js/7485ae2a.6eafc43a.js b/assets/js/7485ae2a.6eafc43a.js new file mode 100644 index 0000000..370c698 --- /dev/null +++ b/assets/js/7485ae2a.6eafc43a.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[852],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>h});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var p=a.createContext({}),s=function(e){var t=a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=s(e.components);return a.createElement(p.Provider,{value:t},e.children)},d="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,p=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),d=s(n),m=r,h=d["".concat(p,".").concat(m)]||d[m]||u[m]||i;return n?a.createElement(h,o(o({ref:t},c),{},{components:n})):a.createElement(h,o({ref:t},c))}));function h(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=m;var l={};for(var p in t)hasOwnProperty.call(t,p)&&(l[p]=t[p]);l.originalType=e,l[d]="string"==typeof e?e:r,o[1]=l;for(var s=2;s{n.r(t),n.d(t,{assets:()=>p,contentTitle:()=>o,default:()=>d,frontMatter:()=>i,metadata:()=>l,toc:()=>s});var a=n(7462),r=(n(7294),n(3905));const i={sidebar_position:2,title:"Get started"},o=void 0,l={unversionedId:"get-started",id:"get-started",title:"Get started",description:"Requirements",source:"@site/docs/get-started.md",sourceDirName:".",slug:"/get-started",permalink:"/react-native-health-connect/docs/get-started",draft:!1,editUrl:"https://github.com/matinzd/react-native-health-connect/tree/main/docs/docs/get-started.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,title:"Get started"},sidebar:"tutorialSidebar",previous:{title:"Introduction",permalink:"/react-native-health-connect/docs/intro"},next:{title:"Permissions",permalink:"/react-native-health-connect/docs/permissions"}},p={},s=[{value:"Requirements",id:"requirements",level:2},{value:"Installation",id:"installation",level:2},{value:"Expo installation",id:"expo-installation",level:2},{value:"Example",id:"example",level:2}],c={toc:s};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"requirements"},"Requirements"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"https://play.google.com/store/apps/details?id=com.google.android.apps.healthdata&hl=en&gl=US"},"Health Connect")," needs to be installed on the user's device. Starting from Android 14 (Upside Down Cake), Health Connect is part of the Android Framework. Read more ",(0,r.kt)("a",{parentName:"li",href:"https://developer.android.com/health-and-fitness/guides/health-connect/develop/get-started#step-1"},"here"),"."),(0,r.kt)("li",{parentName:"ul"},"Health Connect API requires ",(0,r.kt)("inlineCode",{parentName:"li"},"minSdkVersion=26")," (Android Oreo / 8.0)."),(0,r.kt)("li",{parentName:"ul"},"If you are planning to release your app on Google Play, you will need to submit a ",(0,r.kt)("a",{parentName:"li",href:"https://docs.google.com/forms/d/1LFjbq1MOCZySpP5eIVkoyzXTanpcGTYQH26lKcrQUJo/viewform?edit_requested=true"},"declaration form"),". ")),(0,r.kt)("admonition",{type:"note"},(0,r.kt)("p",{parentName:"admonition"},"Health Connect does not appear on the Home screen by default. To open Health Connect, go to Settings > Apps > Health Connect, or add Health Connect to your Quick Settings menu.")),(0,r.kt)("admonition",{type:"note"},(0,r.kt)("p",{parentName:"admonition"},"Health Connect requires the user to have screen lock enabled with a PIN, pattern, or password so that the health data being stored within Health connect is protected from malicious parties while the device is locked. Please go to Settings > Security > Screen lock to set a screen lock.")),(0,r.kt)("h2",{id:"installation"},"Installation"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},"Install react-native-health-connect by running: ")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-bash"},"yarn add react-native-health-connect@latest\n")),(0,r.kt)("p",null,"Since this module is Android-only, you do not need to run ",(0,r.kt)("inlineCode",{parentName:"p"},"pod install"),"."),(0,r.kt)("h2",{id:"expo-installation"},"Expo installation"),(0,r.kt)("p",null,"This package cannot be used in the ",(0,r.kt)("a",{parentName:"p",href:"https://expo.io/client"},"Expo Go")," app, but it can be used with custom managed apps.\nJust add the ",(0,r.kt)("a",{parentName:"p",href:"https://docs.expo.io/guides/config-plugins/"},"config plugin")," to the ",(0,r.kt)("a",{parentName:"p",href:"https://docs.expo.io/versions/latest/config/app/#plugins"},(0,r.kt)("inlineCode",{parentName:"a"},"plugins"))," array of your ",(0,r.kt)("inlineCode",{parentName:"p"},"app.json")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"app.config.js"),":"),(0,r.kt)("p",null,"First install the package with yarn, npm, or ",(0,r.kt)("a",{parentName:"p",href:"https://docs.expo.io/workflow/expo-cli/#expo-install"},(0,r.kt)("inlineCode",{parentName:"a"},"expo install")),"."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"expo install react-native-health-connect\n")),(0,r.kt)("p",null,"Then add the prebuild ",(0,r.kt)("a",{parentName:"p",href:"https://docs.expo.io/guides/config-plugins/"},"config plugin")," to the ",(0,r.kt)("a",{parentName:"p",href:"https://docs.expo.io/versions/latest/config/app/#plugins"},(0,r.kt)("inlineCode",{parentName:"a"},"plugins"))," array of your ",(0,r.kt)("inlineCode",{parentName:"p"},"app.json")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"app.config.js"),":"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-json"},'{\n "expo": {\n "plugins": ["react-native-health-connect"]\n }\n}\n')),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"Edit your app.json again and add this")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-json"},'{\n "expo": {\n ...\n "plugins": [\n [\n "expo-build-properties",\n {\n "android": {\n "compileSdkVersion": 34,\n "targetSdkVersion": 34,\n "minSdkVersion": 26\n },\n }\n ]\n ]\n ...\n }\n}\n')),(0,r.kt)("p",null,"Then rebuild the native app:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},"Run ",(0,r.kt)("inlineCode",{parentName:"li"},"expo prebuild"),(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"This will apply the config plugin using ",(0,r.kt)("a",{parentName:"li",href:"https://expo.fyi/prebuilding"},"prebuilding"),"."))),(0,r.kt)("li",{parentName:"ul"},"Rebuild the app",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"yarn android")," -- Build on Android.")))),(0,r.kt)("blockquote",null,(0,r.kt)("p",{parentName:"blockquote"},"If the project doesn't build correctly with ",(0,r.kt)("inlineCode",{parentName:"p"},"yarn android"),", please file an issue and try setting the project up manually.")),(0,r.kt)("p",null,"Finally create a new EAS development build"),(0,r.kt)("p",null,(0,r.kt)("inlineCode",{parentName:"p"},"eas build --profile development --platform android")),(0,r.kt)("h2",{id:"example"},"Example"),(0,r.kt)("p",null,"A quick example at a glance:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-ts"},"import {\n initialize,\n requestPermission,\n readRecords,\n} from 'react-native-health-connect';\n\nconst readSampleData = async () => {\n // initialize the client\n const isInitialized = await initialize();\n\n // request permissions\n const grantedPermissions = await requestPermission([\n { accessType: 'read', recordType: 'ActiveCaloriesBurned' },\n ]);\n\n // check if granted\n\n const result = await readRecords('ActiveCaloriesBurned', {\n timeRangeFilter: {\n operator: 'between',\n startTime: '2023-01-09T12:00:00.405Z',\n endTime: '2023-01-09T23:53:15.405Z',\n },\n });\n // {\n // result: [\n // {\n // startTime: '2023-01-09T12:00:00.405Z',\n // endTime: '2023-01-09T23:53:15.405Z',\n // energy: {\n // inCalories: 15000000,\n // inJoules: 62760000.00989097,\n // inKilojoules: 62760.00000989097,\n // inKilocalories: 15000,\n // },\n // metadata: {\n // id: '239a8cfd-990d-42fc-bffc-c494b829e8e1',\n // lastModifiedTime: '2023-01-17T21:06:23.335Z',\n // clientRecordId: null,\n // dataOrigin: 'com.healthconnectexample',\n // clientRecordVersion: 0,\n // device: 0,\n // },\n // },\n // ],\n // }\n};\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/7485ae2a.d03514db.js b/assets/js/7485ae2a.d03514db.js deleted file mode 100644 index a8e2625..0000000 --- a/assets/js/7485ae2a.d03514db.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[852],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>h});var a=n(7294);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var p=a.createContext({}),s=function(e){var t=a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=s(e.components);return a.createElement(p.Provider,{value:t},e.children)},d="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,i=e.mdxType,r=e.originalType,p=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),d=s(n),m=i,h=d["".concat(p,".").concat(m)]||d[m]||u[m]||r;return n?a.createElement(h,o(o({ref:t},c),{},{components:n})):a.createElement(h,o({ref:t},c))}));function h(e,t){var n=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var r=n.length,o=new Array(r);o[0]=m;var l={};for(var p in t)hasOwnProperty.call(t,p)&&(l[p]=t[p]);l.originalType=e,l[d]="string"==typeof e?e:i,o[1]=l;for(var s=2;s{n.r(t),n.d(t,{assets:()=>p,contentTitle:()=>o,default:()=>d,frontMatter:()=>r,metadata:()=>l,toc:()=>s});var a=n(7462),i=(n(7294),n(3905));const r={sidebar_position:2,title:"Get started"},o=void 0,l={unversionedId:"get-started",id:"get-started",title:"Get started",description:"Requirements",source:"@site/docs/get-started.md",sourceDirName:".",slug:"/get-started",permalink:"/react-native-health-connect/docs/get-started",draft:!1,editUrl:"https://github.com/matinzd/react-native-health-connect/tree/main/docs/docs/get-started.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,title:"Get started"},sidebar:"tutorialSidebar",previous:{title:"Introduction",permalink:"/react-native-health-connect/docs/intro"},next:{title:"Permissions",permalink:"/react-native-health-connect/docs/permissions"}},p={},s=[{value:"Requirements",id:"requirements",level:2},{value:"Installation",id:"installation",level:2},{value:"Expo installation",id:"expo-installation",level:2},{value:"Example",id:"example",level:2}],c={toc:s};function d(e){let{components:t,...n}=e;return(0,i.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,i.kt)("h2",{id:"requirements"},"Requirements"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"https://play.google.com/store/apps/details?id=com.google.android.apps.healthdata&hl=en&gl=US"},"Health Connect")," needs to be installed on the user's device, However the goal is to have this app preinstalled on Android devices in the future."),(0,i.kt)("li",{parentName:"ul"},"Health Connect API requires ",(0,i.kt)("inlineCode",{parentName:"li"},"minSdkVersion=26")," (Android Oreo / 8.0).")),(0,i.kt)("admonition",{type:"note"},(0,i.kt)("p",{parentName:"admonition"},"Health Connect does not appear on the Home screen by default. To open Health Connect, go to Settings > Apps > Health Connect, or add Health Connect to your Quick Settings menu.")),(0,i.kt)("admonition",{type:"note"},(0,i.kt)("p",{parentName:"admonition"},"Health Connect requires the user to have screen lock enabled with a PIN, pattern, or password so that the health data being stored within Health connect is protected from malicious parties while the device is locked. Please go to Settings > Security > Screen lock to set a screen lock.")),(0,i.kt)("h2",{id:"installation"},"Installation"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},"Install react-native-health-connect by running: ")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-bash"},"yarn add react-native-health-connect@latest\n")),(0,i.kt)("p",null,"Since this module is Android-only, you do not need to run ",(0,i.kt)("inlineCode",{parentName:"p"},"pod install"),"."),(0,i.kt)("h2",{id:"expo-installation"},"Expo installation"),(0,i.kt)("p",null,"This package cannot be used in the ",(0,i.kt)("a",{parentName:"p",href:"https://expo.io/client"},"Expo Go")," app, but it can be used with custom managed apps.\nJust add the ",(0,i.kt)("a",{parentName:"p",href:"https://docs.expo.io/guides/config-plugins/"},"config plugin")," to the ",(0,i.kt)("a",{parentName:"p",href:"https://docs.expo.io/versions/latest/config/app/#plugins"},(0,i.kt)("inlineCode",{parentName:"a"},"plugins"))," array of your ",(0,i.kt)("inlineCode",{parentName:"p"},"app.json")," or ",(0,i.kt)("inlineCode",{parentName:"p"},"app.config.js"),":"),(0,i.kt)("p",null,"First install the package with yarn, npm, or ",(0,i.kt)("a",{parentName:"p",href:"https://docs.expo.io/workflow/expo-cli/#expo-install"},(0,i.kt)("inlineCode",{parentName:"a"},"expo install")),"."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-sh"},"expo install react-native-health-connect\n")),(0,i.kt)("p",null,"Then add the prebuild ",(0,i.kt)("a",{parentName:"p",href:"https://docs.expo.io/guides/config-plugins/"},"config plugin")," to the ",(0,i.kt)("a",{parentName:"p",href:"https://docs.expo.io/versions/latest/config/app/#plugins"},(0,i.kt)("inlineCode",{parentName:"a"},"plugins"))," array of your ",(0,i.kt)("inlineCode",{parentName:"p"},"app.json")," or ",(0,i.kt)("inlineCode",{parentName:"p"},"app.config.js"),":"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "expo": {\n "plugins": ["react-native-health-connect"]\n }\n}\n')),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"Edit your app.json again and add this")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "expo": {\n ...\n "plugins": [\n [\n "expo-build-properties",\n {\n "android": {\n "compileSdkVersion": 34,\n "targetSdkVersion": 34,\n "minSdkVersion": 26\n },\n }\n ]\n ]\n ...\n }\n}\n')),(0,i.kt)("p",null,"Then rebuild the native app:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"Run ",(0,i.kt)("inlineCode",{parentName:"li"},"expo prebuild"),(0,i.kt)("ul",{parentName:"li"},(0,i.kt)("li",{parentName:"ul"},"This will apply the config plugin using ",(0,i.kt)("a",{parentName:"li",href:"https://expo.fyi/prebuilding"},"prebuilding"),"."))),(0,i.kt)("li",{parentName:"ul"},"Rebuild the app",(0,i.kt)("ul",{parentName:"li"},(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"yarn android")," -- Build on Android.")))),(0,i.kt)("blockquote",null,(0,i.kt)("p",{parentName:"blockquote"},"If the project doesn't build correctly with ",(0,i.kt)("inlineCode",{parentName:"p"},"yarn android"),", please file an issue and try setting the project up manually.")),(0,i.kt)("p",null,"Finally create a new EAS development build"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"eas build --profile development --platform android")),(0,i.kt)("h2",{id:"example"},"Example"),(0,i.kt)("p",null,"A quick example at a glance:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"import {\n initialize,\n requestPermission,\n readRecords,\n} from 'react-native-health-connect';\n\nconst readSampleData = async () => {\n // initialize the client\n const isInitialized = await initialize();\n\n // request permissions\n const grantedPermissions = await requestPermission([\n { accessType: 'read', recordType: 'ActiveCaloriesBurned' },\n ]);\n\n // check if granted\n\n const result = await readRecords('ActiveCaloriesBurned', {\n timeRangeFilter: {\n operator: 'between',\n startTime: '2023-01-09T12:00:00.405Z',\n endTime: '2023-01-09T23:53:15.405Z',\n },\n });\n // {\n // result: [\n // {\n // startTime: '2023-01-09T12:00:00.405Z',\n // endTime: '2023-01-09T23:53:15.405Z',\n // energy: {\n // inCalories: 15000000,\n // inJoules: 62760000.00989097,\n // inKilojoules: 62760.00000989097,\n // inKilocalories: 15000,\n // },\n // metadata: {\n // id: '239a8cfd-990d-42fc-bffc-c494b829e8e1',\n // lastModifiedTime: '2023-01-17T21:06:23.335Z',\n // clientRecordId: null,\n // dataOrigin: 'com.healthconnectexample',\n // clientRecordVersion: 0,\n // device: 0,\n // },\n // },\n // ],\n // }\n};\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.2534f944.js b/assets/js/runtime~main.49c67724.js similarity index 98% rename from assets/js/runtime~main.2534f944.js rename to assets/js/runtime~main.49c67724.js index 7b82213..64cf9b5 100644 --- a/assets/js/runtime~main.2534f944.js +++ b/assets/js/runtime~main.49c67724.js @@ -1 +1 @@ -(()=>{"use strict";var e,t,r,a,d,f={},o={};function n(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={id:e,loaded:!1,exports:{}};return f[e].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=f,n.c=o,e=[],n.O=(t,r,a,d)=>{if(!r){var f=1/0;for(b=0;b=d)&&Object.keys(n.O).every((e=>n.O[e](r[c])))?r.splice(c--,1):(o=!1,d0&&e[b-1][2]>d;b--)e[b]=e[b-1];e[b]=[r,a,d]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var d=Object.create(null);n.r(d);var f={};t=t||[null,r({}),r([]),r(r)];for(var o=2&a&&e;"object"==typeof o&&!~t.indexOf(o);o=r(o))Object.getOwnPropertyNames(o).forEach((t=>f[t]=()=>e[t]));return f.default=()=>e,n.d(d,f),d},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((t,r)=>(n.f[r](e,t),t)),[])),n.u=e=>"assets/js/"+({53:"935f2afb",54:"704dfb2d",69:"5319b26b",80:"4d54d076",85:"1f391b9e",107:"9035e9dd",237:"1df93b7f",294:"a5605d85",360:"9d9f8394",400:"734f6a92",414:"393be207",483:"1a7a41a3",488:"8100fd08",514:"1be78505",587:"d31ff8a3",619:"17b5edc8",628:"86e6f3ef",639:"d9db67ef",643:"65df3d35",663:"3d534e40",671:"0e384e19",689:"89df0d0a",716:"ce85f662",755:"11b279ee",764:"7cead0af",767:"bc120623",807:"256f9d56",817:"14eb3368",852:"7485ae2a",882:"628d7a0c",918:"17896441"}[e]||e)+"."+{53:"9ebd5635",54:"133e8b6d",69:"01c52a97",80:"4c6ee879",85:"03f0be22",107:"7bcf08e6",237:"93e6fa8f",294:"ed9ec6f1",360:"1fc309ec",400:"41de33da",414:"ced84f88",483:"8f335347",488:"c4a8d805",514:"009dddd0",587:"d4d86e28",619:"42972385",628:"51891a9e",639:"7cc008f9",643:"d136d375",663:"9c8ae0f6",666:"f0bfb704",671:"1fb6903f",689:"1cf9bf4d",716:"8a39e996",755:"f46b4aae",764:"c359db06",767:"0333822d",807:"9e84bfc1",817:"dac4c597",852:"d03514db",882:"acb94a1e",918:"6947a02e",972:"d5cc17b1"}[e]+".js",n.miniCssF=e=>{},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},d="docs:",n.l=(e,t,r,f)=>{if(a[e])a[e].push(t);else{var o,c;if(void 0!==r)for(var i=document.getElementsByTagName("script"),b=0;b{o.onerror=o.onload=null,clearTimeout(s);var d=a[e];if(delete a[e],o.parentNode&&o.parentNode.removeChild(o),d&&d.forEach((e=>e(r))),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),c&&document.head.appendChild(o)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="/react-native-health-connect/",n.gca=function(e){return e={17896441:"918","935f2afb":"53","704dfb2d":"54","5319b26b":"69","4d54d076":"80","1f391b9e":"85","9035e9dd":"107","1df93b7f":"237",a5605d85:"294","9d9f8394":"360","734f6a92":"400","393be207":"414","1a7a41a3":"483","8100fd08":"488","1be78505":"514",d31ff8a3:"587","17b5edc8":"619","86e6f3ef":"628",d9db67ef:"639","65df3d35":"643","3d534e40":"663","0e384e19":"671","89df0d0a":"689",ce85f662:"716","11b279ee":"755","7cead0af":"764",bc120623:"767","256f9d56":"807","14eb3368":"817","7485ae2a":"852","628d7a0c":"882"}[e]||e,n.p+n.u(e)},(()=>{var e={303:0,532:0};n.f.j=(t,r)=>{var a=n.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var d=new Promise(((r,d)=>a=e[t]=[r,d]));r.push(a[2]=d);var f=n.p+n.u(t),o=new Error;n.l(f,(r=>{if(n.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var d=r&&("load"===r.type?"missing":r.type),f=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+d+": "+f+")",o.name="ChunkLoadError",o.type=d,o.request=f,a[1](o)}}),"chunk-"+t,t)}},n.O.j=t=>0===e[t];var t=(t,r)=>{var a,d,f=r[0],o=r[1],c=r[2],i=0;if(f.some((t=>0!==e[t]))){for(a in o)n.o(o,a)&&(n.m[a]=o[a]);if(c)var b=c(n)}for(t&&t(r);i{"use strict";var e,t,r,a,d,f={},o={};function n(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={id:e,loaded:!1,exports:{}};return f[e].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=f,n.c=o,e=[],n.O=(t,r,a,d)=>{if(!r){var f=1/0;for(b=0;b=d)&&Object.keys(n.O).every((e=>n.O[e](r[c])))?r.splice(c--,1):(o=!1,d0&&e[b-1][2]>d;b--)e[b]=e[b-1];e[b]=[r,a,d]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var d=Object.create(null);n.r(d);var f={};t=t||[null,r({}),r([]),r(r)];for(var o=2&a&&e;"object"==typeof o&&!~t.indexOf(o);o=r(o))Object.getOwnPropertyNames(o).forEach((t=>f[t]=()=>e[t]));return f.default=()=>e,n.d(d,f),d},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((t,r)=>(n.f[r](e,t),t)),[])),n.u=e=>"assets/js/"+({53:"935f2afb",54:"704dfb2d",69:"5319b26b",80:"4d54d076",85:"1f391b9e",107:"9035e9dd",237:"1df93b7f",294:"a5605d85",360:"9d9f8394",400:"734f6a92",414:"393be207",483:"1a7a41a3",488:"8100fd08",514:"1be78505",587:"d31ff8a3",619:"17b5edc8",628:"86e6f3ef",639:"d9db67ef",643:"65df3d35",663:"3d534e40",671:"0e384e19",689:"89df0d0a",716:"ce85f662",755:"11b279ee",764:"7cead0af",767:"bc120623",807:"256f9d56",817:"14eb3368",852:"7485ae2a",882:"628d7a0c",918:"17896441"}[e]||e)+"."+{53:"9ebd5635",54:"133e8b6d",69:"01c52a97",80:"4c6ee879",85:"03f0be22",107:"7bcf08e6",237:"93e6fa8f",294:"ed9ec6f1",360:"1fc309ec",400:"41de33da",414:"ced84f88",483:"8f335347",488:"c4a8d805",514:"009dddd0",587:"d4d86e28",619:"42972385",628:"51891a9e",639:"7cc008f9",643:"d136d375",663:"9c8ae0f6",666:"f0bfb704",671:"1fb6903f",689:"1cf9bf4d",716:"8a39e996",755:"f46b4aae",764:"c359db06",767:"0333822d",807:"9e84bfc1",817:"dac4c597",852:"6eafc43a",882:"acb94a1e",918:"6947a02e",972:"d5cc17b1"}[e]+".js",n.miniCssF=e=>{},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},d="docs:",n.l=(e,t,r,f)=>{if(a[e])a[e].push(t);else{var o,c;if(void 0!==r)for(var i=document.getElementsByTagName("script"),b=0;b{o.onerror=o.onload=null,clearTimeout(s);var d=a[e];if(delete a[e],o.parentNode&&o.parentNode.removeChild(o),d&&d.forEach((e=>e(r))),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),c&&document.head.appendChild(o)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="/react-native-health-connect/",n.gca=function(e){return e={17896441:"918","935f2afb":"53","704dfb2d":"54","5319b26b":"69","4d54d076":"80","1f391b9e":"85","9035e9dd":"107","1df93b7f":"237",a5605d85:"294","9d9f8394":"360","734f6a92":"400","393be207":"414","1a7a41a3":"483","8100fd08":"488","1be78505":"514",d31ff8a3:"587","17b5edc8":"619","86e6f3ef":"628",d9db67ef:"639","65df3d35":"643","3d534e40":"663","0e384e19":"671","89df0d0a":"689",ce85f662:"716","11b279ee":"755","7cead0af":"764",bc120623:"767","256f9d56":"807","14eb3368":"817","7485ae2a":"852","628d7a0c":"882"}[e]||e,n.p+n.u(e)},(()=>{var e={303:0,532:0};n.f.j=(t,r)=>{var a=n.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var d=new Promise(((r,d)=>a=e[t]=[r,d]));r.push(a[2]=d);var f=n.p+n.u(t),o=new Error;n.l(f,(r=>{if(n.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var d=r&&("load"===r.type?"missing":r.type),f=r&&r.target&&r.target.src;o.message="Loading chunk "+t+" failed.\n("+d+": "+f+")",o.name="ChunkLoadError",o.type=d,o.request=f,a[1](o)}}),"chunk-"+t,t)}},n.O.j=t=>0===e[t];var t=(t,r)=>{var a,d,f=r[0],o=r[1],c=r[2],i=0;if(f.some((t=>0!==e[t]))){for(a in o)n.o(o,a)&&(n.m[a]=o[a]);if(c)var b=c(n)}for(t&&t(r);i Exceptions | React Native Health Connect - +

Exceptions

Exceptions

The SDK throws exceptions for operations when an issue is encountered and you should make sure that these are appropriately caught and handled. Each exception contains a code and a message that describes the error. In general, the following exceptions may occur:

  • PERMISSION_ERROR - This exception is thrown when the SDK does not have the required permissions to perform the operation. You need to define nessesary permissions inside your application manifest as described here.
  • SDK_VERSION_ERROR - This exception is thrown when the SDK version is incompatible with the service or the operation being performed.
  • IO_EXCEPTION - This exception is thrown when there is an issue with input/output operations, such as file reading or writing.
  • SERVICE_UNAVAILABLE - This exception is thrown when the service that the SDK is trying to connect to is unavailable on device or not supported.
  • ARGUMENT_VALIDATION_ERROR - This exception is thrown when one or more of the arguments passed to a method is invalid.
  • UNDERLYING_ERROR - This exception is thrown when there is an error with the underlying service or technology the SDK is using.
  • INVALID_RECORD_TYPE - This exception is thrown when the type of record passed to a method is not valid.
  • CLIENT_NOT_INITIALIZED - This exception is thrown when the SDK client has not been properly initialized.
  • INVALID_TEMPERATURE - This exception is thrown when an invalid temperature value is passed to a method.
  • INVALID_ENERGY - This exception is thrown when an invalid energy value is passed to a method.
  • INVALID_BLOOD_GLUCOSE_LEVEL - This exception is thrown when an invalid blood glucose value is passed to a method.
  • INVALID_BLOOD_PRESSURE - This exception is thrown when an invalid blood pressure value is passed to a method.
  • INVALID_MASS - This exception is thrown when an invalid mass value is passed to a method.
  • AGGREGATION_NOT_SUPPORTED - This exception is thrown for some records that does not support aggregation metrics.
  • UNKNOWN_ERROR - This exception is thrown when the SDK encounters an error that is not covered by any other specific exception.
- + \ No newline at end of file diff --git a/docs/api/methods/aggregateRecord/index.html b/docs/api/methods/aggregateRecord/index.html index 6cb5509..7123305 100644 --- a/docs/api/methods/aggregateRecord/index.html +++ b/docs/api/methods/aggregateRecord/index.html @@ -4,13 +4,13 @@ aggregateRecord | React Native Health Connect - +

aggregateRecord

Reads aggregated result according to requested read criteria, for e.g, data origin filter and within a time range. Some record types do not support aggregation.

Method

aggregateRecord<T extends AggregateResultRecordType>(
request: AggregateRequest<T>
): Promise<AggregateResult<T>>

Example

import { aggregateRecord } from 'react-native-health-connect';

const aggregateSampleData = () => {
aggregateRecord({
recordType: 'ActiveCaloriesBurned',
timeRangeFilter: {
operator: 'between',
startTime: '2023-01-09T12:00:00.405Z',
endTime: '2023-01-09T23:53:15.405Z',
},
}).then((result) => {
console.log('Aggregated record: ', { result }); // Aggregated record: {"result": {"dataOrigins": ["com.healthconnectexample"], "inCalories": 15000000, "inJoules": 62760000.00989097, "inKilocalories": 15000, "inKilojoules": 62760.00000989097}}
});
};
- + \ No newline at end of file diff --git a/docs/api/methods/deleteRecordsByTimeRange/index.html b/docs/api/methods/deleteRecordsByTimeRange/index.html index 6abc912..f44a4df 100644 --- a/docs/api/methods/deleteRecordsByTimeRange/index.html +++ b/docs/api/methods/deleteRecordsByTimeRange/index.html @@ -4,13 +4,13 @@ deleteRecordsByTimeRange | React Native Health Connect - +

deleteRecordsByTimeRange

Deletes one or more record by their identifiers. Deletion of multiple record is executed in single transaction - if one fails, none is deleted.

Method

deleteRecordsByTimeRange(
recordType: RecordType,
timeRangeFilter: TimeRangeFilter
): Promise<void>

Example

import { deleteRecordsByTimeRange } from 'react-native-health-connect';

// ...
deleteRecordsByTimeRange('ActiveCaloriesBurned', {
operator: 'between',
startTime: '2023-01-09T12:00:00.405Z',
endTime: '2023-01-09T23:53:15.405Z',
});
- + \ No newline at end of file diff --git a/docs/api/methods/deleteRecordsByUuids/index.html b/docs/api/methods/deleteRecordsByUuids/index.html index 33ebe08..4c636d0 100644 --- a/docs/api/methods/deleteRecordsByUuids/index.html +++ b/docs/api/methods/deleteRecordsByUuids/index.html @@ -4,13 +4,13 @@ deleteRecordsByUuids | React Native Health Connect - +

deleteRecordsByUuids

Deletes one or more Record by their identifiers. Deletion of multiple Record is executed in single transaction - if one fails, none is deleted.

Method

deleteRecordsByUuids(
recordType: RecordType,
recordIdsList: string[],
clientRecordIdsList: string[] = []
): Promise<void>

Example

import { deleteRecordsByUuids } from 'react-native-health-connect';

// ...
deleteRecordsByUuids('ActiveCaloriesBurned', [
'47066a7c-8994-4caf-b031-c54b2b6a2023',
'2279fa69-683b-44c7-8cfa-930fb5fc64eb',
]);
- + \ No newline at end of file diff --git a/docs/api/methods/getGrantedPermissions/index.html b/docs/api/methods/getGrantedPermissions/index.html index e85a2a6..ace0572 100644 --- a/docs/api/methods/getGrantedPermissions/index.html +++ b/docs/api/methods/getGrantedPermissions/index.html @@ -4,13 +4,13 @@ getGrantedPermissions | React Native Health Connect - +

getGrantedPermissions

Returns a set of all health permissions granted by the user to the calling provider app.

Method

getGrantedPermissions(): Promise<Permission[]>

Example

import { getGrantedPermissions } from 'react-native-health-connect';

const readGrantedPermissions = () => {
getGrantedPermissions().then((permissions) => {
console.log('Granted permissions ', { permissions });
});
};
- + \ No newline at end of file diff --git a/docs/api/methods/getSdkStatus/index.html b/docs/api/methods/getSdkStatus/index.html index a760ffd..fe41190 100644 --- a/docs/api/methods/getSdkStatus/index.html +++ b/docs/api/methods/getSdkStatus/index.html @@ -4,13 +4,13 @@ getSdkStatus | React Native Health Connect - +

getSdkStatus

Determines whether an implementation of HealthConnectClient is available on the device at the moment. If none is available, apps may choose to redirect to package installers to find suitable providers. If providerPackageName is not provided, the default Health Connect application package name will be considered com.google.android.apps.healthdata.

Method

getSdkStatus(providerPackageName: string): Promise<number>;

Example

import {
getSdkStatus,
SdkAvailabilityStatus,
} from 'react-native-health-connect';

const checkAvailability = async () => {
const status = await getSdkStatus();
if (status === SdkAvailabilityStatus.SDK_AVAILABLE) {
console.log('SDK is available');
}

if (status === SdkAvailabilityStatus.SDK_UNAVAILABLE) {
console.log('SDK is not available');
}

if (
status === SdkAvailabilityStatus.SDK_UNAVAILABLE_PROVIDER_UPDATE_REQUIRED
) {
console.log('SDK is not available, provider update required');
}
};
- + \ No newline at end of file diff --git a/docs/api/methods/initialize/index.html b/docs/api/methods/initialize/index.html index 5303b0d..431f93b 100644 --- a/docs/api/methods/initialize/index.html +++ b/docs/api/methods/initialize/index.html @@ -4,13 +4,13 @@ initialize | React Native Health Connect - +

initialize

Initializes the health connect client with specific providers. If providerPackageName is not provided, the default Health Connect application package name will be considered com.google.android.apps.healthdata.

Method

initialize(providerPackageName: string): Promise<boolean>;

Example

import { initialize } from 'react-native-health-connect';

const initializeHealthConnect = async () => {
const isInitialized = await initialize();
console.log({ isInitialized });
};
- + \ No newline at end of file diff --git a/docs/api/methods/insertRecords/index.html b/docs/api/methods/insertRecords/index.html index 8a96fb0..be583af 100644 --- a/docs/api/methods/insertRecords/index.html +++ b/docs/api/methods/insertRecords/index.html @@ -4,13 +4,13 @@ insertRecords | React Native Health Connect - +

insertRecords

Inserts one or more record and returns newly generated records' uuids. Insertion of multiple records is executed in a transaction - if one fails, none is inserted.

Method

insertRecords(records: HealthConnectRecord[]): Promise<string[]>;

Example

import { insertRecords } from 'react-native-health-connect';

const insertSampleData = () => {
insertRecords([
{
recordType: 'ActiveCaloriesBurned',
energy: { unit: 'kilocalories', value: 10000 },
startTime: '2023-01-09T10:00:00.405Z',
endTime: '2023-01-09T11:53:15.405Z',
},
{
recordType: 'ActiveCaloriesBurned',
energy: { unit: 'kilocalories', value: 15000 },
startTime: '2023-01-09T12:00:00.405Z',
endTime: '2023-01-09T23:53:15.405Z',
},
]).then((ids) => {
console.log('Records inserted ', { ids }); // Records inserted {"ids": ["06bef46e-9383-4cc1-94b6-07a5045b764a", "a7bdea65-86ce-4eb2-a9ef-a87e6a7d9df2"]}
});
};
- + \ No newline at end of file diff --git a/docs/api/methods/openHealthConnectDataManagement/index.html b/docs/api/methods/openHealthConnectDataManagement/index.html index 7a4ce74..8ac13a8 100644 --- a/docs/api/methods/openHealthConnectDataManagement/index.html +++ b/docs/api/methods/openHealthConnectDataManagement/index.html @@ -4,13 +4,13 @@ openHealthConnectDataManagement | React Native Health Connect - +

openHealthConnectDataManagement

Opens Health Connect data management screen

Method

openHealthConnectDataManagement(providerPackageName?: string): void

Example

import { openHealthConnectDataManagement } from 'react-native-health-connect';

// ...
openHealthConnectDataManagement();
- + \ No newline at end of file diff --git a/docs/api/methods/openHealthConnectSettings/index.html b/docs/api/methods/openHealthConnectSettings/index.html index fa78be5..e37324b 100644 --- a/docs/api/methods/openHealthConnectSettings/index.html +++ b/docs/api/methods/openHealthConnectSettings/index.html @@ -4,13 +4,13 @@ openHealthConnectSettings | React Native Health Connect - + - + \ No newline at end of file diff --git a/docs/api/methods/readRecord/index.html b/docs/api/methods/readRecord/index.html index 13f4319..08c42d5 100644 --- a/docs/api/methods/readRecord/index.html +++ b/docs/api/methods/readRecord/index.html @@ -4,13 +4,13 @@ readRecord | React Native Health Connect - +

readRecord

Retrieves a single record of the specified type.

Method

function readRecord<T extends RecordType>(
recordType: T,
recordId: string
): Promise<RecordResult<T>>;

Example

import { readRecord } from 'react-native-health-connect';

const readSampleDataSingle = () => {
readRecord(
'ActiveCaloriesBurned',
'a7bdea65-86ce-4eb2-a9ef-a87e6a7d9df2'
).then((result) => {
console.log('Retrieved record: ', JSON.stringify({ result }, null, 2));
});
};
- + \ No newline at end of file diff --git a/docs/api/methods/readRecords/index.html b/docs/api/methods/readRecords/index.html index e6a3af1..151acba 100644 --- a/docs/api/methods/readRecords/index.html +++ b/docs/api/methods/readRecords/index.html @@ -4,13 +4,13 @@ readRecords | React Native Health Connect - +

readRecords

Retrieves a collection of records.

Method

function readRecords<T extends RecordType>(
// record type e.g activeCaloriesBurned
recordType: T,

// read options such as time range filter, data origin filter, ordering and pagination
options: ReadRecordsOptions
): Promise<RecordResult<T>[]>

Example

import { readRecords } from 'react-native-health-connect';

const readSampleData = () => {
readRecords('ActiveCaloriesBurned', {
timeRangeFilter: {
operator: 'between',
startTime: '2023-01-09T12:00:00.405Z',
endTime: '2023-01-09T23:53:15.405Z',
},
}).then((result) => {
console.log('Retrieved records: ', JSON.stringify({ result }, null, 2)); // Retrieved records: {"result":[{"startTime":"2023-01-09T12:00:00.405Z","endTime":"2023-01-09T23:53:15.405Z","energy":{"inCalories":15000000,"inJoules":62760000.00989097,"inKilojoules":62760.00000989097,"inKilocalories":15000},"metadata":{"id":"239a8cfd-990d-42fc-bffc-c494b829e8e1","lastModifiedTime":"2023-01-17T21:06:23.335Z","clientRecordId":null,"dataOrigin":"com.healthconnectexample","clientRecordVersion":0,"device":0}}]}
});
};
- + \ No newline at end of file diff --git a/docs/api/methods/requestPermission/index.html b/docs/api/methods/requestPermission/index.html index 4953cea..c109c4f 100644 --- a/docs/api/methods/requestPermission/index.html +++ b/docs/api/methods/requestPermission/index.html @@ -4,13 +4,13 @@ requestPermission | React Native Health Connect - +

requestPermission

Request permission for specified record types and access types.

Method

requestPermission(permissions: Permission[], providerPackageName: string): Promise<Permission[]>

Example

import { requestPermission } from 'react-native-health-connect';

const requestPermissions = () => {
requestPermission([
{
accessType: 'read',
recordType: 'ActiveCaloriesBurned',
},
{
accessType: 'write',
recordType: 'ActiveCaloriesBurned',
},
]).then((permissions) => {
console.log('Granted permissions ', { permissions });
});
};
- + \ No newline at end of file diff --git a/docs/api/methods/revokeAllPermissions/index.html b/docs/api/methods/revokeAllPermissions/index.html index b7b54a7..6c4d4ba 100644 --- a/docs/api/methods/revokeAllPermissions/index.html +++ b/docs/api/methods/revokeAllPermissions/index.html @@ -4,13 +4,13 @@ revokeAllPermissions | React Native Health Connect - + - + \ No newline at end of file diff --git a/docs/api/overview/index.html b/docs/api/overview/index.html index b24a816..c1f6133 100644 --- a/docs/api/overview/index.html +++ b/docs/api/overview/index.html @@ -4,13 +4,13 @@ Overview | React Native Health Connect - +

Overview

Available methods

MethodDescription
getSdkStatusDetermines whether an implementation of HealthConnectClient is available on the device at the moment. If none is available, apps may choose to redirect to package installers to find suitable providers.
initializeInitialize the health connect client.
openHealthConnectSettingsOpens Health Connect app's settings app.
openHealthConnectDataManagementOpens Health Connect data management screen app.
requestPermissionRequest permission for specified record types and access types.
getGrantedPermissionsReturns a set of all health permissions granted by the user to the calling provider app.
revokeAllPermissionsRevokes all previously granted permissions by the user to the calling app.
insertRecordsInserts one or more records and returns newly assigned generated UUIDs. Insertion of multiple records is executed in a transaction - if one fails, none is inserted.
readRecordsRetrieves a collection of records.
readRecordRetrieves a single record of the specified type.
aggregateRecordReads aggregated results according to requested read criteria, for e.g, data origin filter and within a time range.
deleteRecordsByUuidsDeletes one or more records by their identifiers. Deletion of multiple records is executed in a single transaction - if one fails, none is deleted.
deleteRecordsByTimeRangeDeletes any record of the given record type in the given time range (automatically filtered to a record belonging to the calling application). Deletion of multiple records is executed in a transaction - if one fails, none is deleted.
- + \ No newline at end of file diff --git a/docs/category/api-reference/index.html b/docs/category/api-reference/index.html index 0ef6723..897d00d 100644 --- a/docs/category/api-reference/index.html +++ b/docs/category/api-reference/index.html @@ -4,13 +4,13 @@ API Reference | React Native Health Connect - + - + \ No newline at end of file diff --git a/docs/category/methods/index.html b/docs/category/methods/index.html index 005551d..db2fb01 100644 --- a/docs/category/methods/index.html +++ b/docs/category/methods/index.html @@ -4,13 +4,13 @@ Methods | React Native Health Connect - +

Methods

- + \ No newline at end of file diff --git a/docs/contributing/index.html b/docs/contributing/index.html index 22e1ecf..b82ea03 100644 --- a/docs/contributing/index.html +++ b/docs/contributing/index.html @@ -4,13 +4,13 @@ Contributing | React Native Health Connect - +

Contributing

Contributions are always welcome, no matter how large or small!

We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project.

Development workflow

To get started with the project, run yarn in the root directory to install the required dependencies for each package:

yarn

While it's possible to use npm, the tooling is built around yarn, so you'll have an easier time if you use yarn for development.

While developing, you can run the example app to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app.

To start the packager:

yarn example start

To run the example app on Android:

yarn example android

To run the example app on iOS:

yarn example ios

By default, the example is configured to build with the old architecture. To run the example with the new architecture, you can do the following:

  1. For Android, run:

    ORG_GRADLE_PROJECT_newArchEnabled=true yarn example android
  2. For iOS, run:

    RCT_NEW_ARCH_ENABLED=1 yarn example pods
    yarn example ios

If you are building for a different architecture than your previous build, make sure to remove the build folders first. You can run the following command to cleanup all build folders:

yarn clean

To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:

Running "HealthConnectExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}

Note the "fabric":true and "concurrentRoot":true properties.

Make sure your code passes TypeScript and ESLint. Run the following to verify:

yarn typecheck
yarn lint

To fix formatting errors, run the following:

yarn lint --fix

Remember to add tests for your change if possible. Run the unit tests by:

yarn test

To edit the Objective-C or Swift files, open example/ios/HealthConnectExample.xcworkspace in XCode and find the source files at Pods > Development Pods > react-native-health-connect.

To edit the Java or Kotlin files, open example/android in Android studio and find the source files at react-native-health-connect under Android.

Commit message convention

We follow the conventional commits specification for our commit messages:

  • fix: bug fixes, e.g. fix crash due to deprecated method.
  • feat: new features, e.g. add new method to the module.
  • refactor: code refactor, e.g. migrate from class components to hooks.
  • docs: changes into documentation, e.g. add usage example for the module..
  • test: adding or updating tests, e.g. add integration tests using detox.
  • chore: tooling changes, e.g. change CI config.

Our pre-commit hooks verify that your commit message matches this format when committing.

Linting and tests

ESLint, Prettier, TypeScript

We use TypeScript for type checking, ESLint with Prettier for linting and formatting the code, and Jest for testing.

Our pre-commit hooks verify that the linter and tests pass when committing.

Scripts

The package.json file contains various scripts for common tasks:

  • yarn bootstrap: setup project by installing all dependencies and pods.
  • yarn typecheck: type-check files with TypeScript.
  • yarn lint: lint files with ESLint.
  • yarn test: run unit tests with Jest.
  • yarn example start: start the Metro server for the example app.
  • yarn example android: run the example app on Android.
  • yarn example ios: run the example app on iOS.

Sending a pull request

Working on your first pull request? You can learn how from this free series: How to Contribute to an Open Source Project on GitHub.

When you're sending a pull request:

  • Prefer small pull requests focused on one change.
  • Verify that linters and tests are passing.
  • Review the documentation to make sure it looks good.
  • Follow the pull request template when opening a pull request.
  • For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
- + \ No newline at end of file diff --git a/docs/get-started/index.html b/docs/get-started/index.html index 35423a2..c2e7389 100644 --- a/docs/get-started/index.html +++ b/docs/get-started/index.html @@ -4,14 +4,14 @@ Get started | React Native Health Connect - +
-

Get started

Requirements

  • Health Connect needs to be installed on the user's device, However the goal is to have this app preinstalled on Android devices in the future.
  • Health Connect API requires minSdkVersion=26 (Android Oreo / 8.0).
note

Health Connect does not appear on the Home screen by default. To open Health Connect, go to Settings > Apps > Health Connect, or add Health Connect to your Quick Settings menu.

note

Health Connect requires the user to have screen lock enabled with a PIN, pattern, or password so that the health data being stored within Health connect is protected from malicious parties while the device is locked. Please go to Settings > Security > Screen lock to set a screen lock.

Installation

  1. Install react-native-health-connect by running:
yarn add react-native-health-connect@latest

Since this module is Android-only, you do not need to run pod install.

Expo installation

This package cannot be used in the Expo Go app, but it can be used with custom managed apps. +

Get started

Requirements

  • Health Connect needs to be installed on the user's device. Starting from Android 14 (Upside Down Cake), Health Connect is part of the Android Framework. Read more here.
  • Health Connect API requires minSdkVersion=26 (Android Oreo / 8.0).
  • If you are planning to release your app on Google Play, you will need to submit a declaration form.
note

Health Connect does not appear on the Home screen by default. To open Health Connect, go to Settings > Apps > Health Connect, or add Health Connect to your Quick Settings menu.

note

Health Connect requires the user to have screen lock enabled with a PIN, pattern, or password so that the health data being stored within Health connect is protected from malicious parties while the device is locked. Please go to Settings > Security > Screen lock to set a screen lock.

Installation

  1. Install react-native-health-connect by running:
yarn add react-native-health-connect@latest

Since this module is Android-only, you do not need to run pod install.

Expo installation

This package cannot be used in the Expo Go app, but it can be used with custom managed apps. Just add the config plugin to the plugins array of your app.json or app.config.js:

First install the package with yarn, npm, or expo install.

expo install react-native-health-connect

Then add the prebuild config plugin to the plugins array of your app.json or app.config.js:

{
"expo": {
"plugins": ["react-native-health-connect"]
}
}
  • Edit your app.json again and add this
{
"expo": {
...
"plugins": [
[
"expo-build-properties",
{
"android": {
"compileSdkVersion": 34,
"targetSdkVersion": 34,
"minSdkVersion": 26
},
}
]
]
...
}
}

Then rebuild the native app:

  • Run expo prebuild
  • Rebuild the app
    • yarn android -- Build on Android.

If the project doesn't build correctly with yarn android, please file an issue and try setting the project up manually.

Finally create a new EAS development build

eas build --profile development --platform android

Example

A quick example at a glance:

import {
initialize,
requestPermission,
readRecords,
} from 'react-native-health-connect';

const readSampleData = async () => {
// initialize the client
const isInitialized = await initialize();

// request permissions
const grantedPermissions = await requestPermission([
{ accessType: 'read', recordType: 'ActiveCaloriesBurned' },
]);

// check if granted

const result = await readRecords('ActiveCaloriesBurned', {
timeRangeFilter: {
operator: 'between',
startTime: '2023-01-09T12:00:00.405Z',
endTime: '2023-01-09T23:53:15.405Z',
},
});
// {
// result: [
// {
// startTime: '2023-01-09T12:00:00.405Z',
// endTime: '2023-01-09T23:53:15.405Z',
// energy: {
// inCalories: 15000000,
// inJoules: 62760000.00989097,
// inKilojoules: 62760.00000989097,
// inKilocalories: 15000,
// },
// metadata: {
// id: '239a8cfd-990d-42fc-bffc-c494b829e8e1',
// lastModifiedTime: '2023-01-17T21:06:23.335Z',
// clientRecordId: null,
// dataOrigin: 'com.healthconnectexample',
// clientRecordVersion: 0,
// device: 0,
// },
// },
// ],
// }
};
- + \ No newline at end of file diff --git a/docs/intro/index.html b/docs/intro/index.html index 47dedb3..79c2bb3 100644 --- a/docs/intro/index.html +++ b/docs/intro/index.html @@ -4,13 +4,13 @@ Introduction | React Native Health Connect - +

Introduction

React Native Health Connect


This library is a wrapper around Health Connect for react native. Health Connect is an Android API and platform. It unifies data from multiple devices and apps into an ecosystem. For Android developers, it provides a single interface for reading and writing a user’s health and fitness data. For Android users, it offers a place for control over which apps have read and/or write access to different types of data. Health Connect also provides on-device storage. Read more here.

note

If your app integrates with Health Connect, before going to production, you need to fill out a form explaining what data types the app reads/writes, and how this data is used. For more information, see How do I request access to read/write data types?.

note

Health Connect is now currently on alpha channel. Check here for more information.

Read more about health connect architecture here.

Features

  • Typescript ✅
  • Supports both old and new architecture ✅

Tips

  1. Keep in mind that this library is Android only.
  2. Health Connect is now currently on alpha version. Check here.
  3. If the user declines your permission request twice, your app is permanently locked out, and cannot request permissions again.

Read more about health connect architecture here.

License

MIT

- + \ No newline at end of file diff --git a/docs/permissions/index.html b/docs/permissions/index.html index bf46dcb..f1d37d6 100644 --- a/docs/permissions/index.html +++ b/docs/permissions/index.html @@ -4,13 +4,13 @@ Permissions | React Native Health Connect - +

Permissions

Setting up permissions

To access health data from the Health Connect app in your own app, you need to add the necessary permissions and filters to the app manifest.

  • Add the necessary permissions to AndroidManifest.xml:
android/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.health.READ_HEART_RATE"/>
+ <uses-permission android:name="android.permission.health.WRITE_HEART_RATE"/>
+ <uses-permission android:name="android.permission.health.READ_STEPS"/>
+ <uses-permission android:name="android.permission.health.WRITE_STEPS"/>
</manifest>
  • Add the following highlighted code inside the activity tag as well:
android/src/main/AndroidManifest.xml
    <activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <intent-filter>
+ <action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
+ </intent-filter>
</activity>

Setting up permissions in Expo

You will need to use EAS Build and Config plugins in your project.

  • Edit app.json and add the permissions you need.
{
"expo": {
...
"android": {
...
"permissions": [
"android.permission.health.READ_STEPS",
"android.permission.health.WRITE_STEPS",
"android.permission.health.READ_ACTIVE_CALORIES_BURNED"
]
},
...
}
}

Complete list of permissions

Record class typeRead permission declarationWrite permission declaration
ActiveCaloriesBurnedandroid.permission.health.READ_ACTIVE_CALORIES_BURNEDandroid.permission.health.WRITE_ACTIVE_CALORIES_BURNED
BasalBodyTemperatureandroid.permission.health.READ_BASAL_BODY_TEMPERATUREandroid.permission.health.WRITE_BASAL_BODY_TEMPERATURE
BasalMetabolicRateandroid.permission.health.READ_BASAL_METABOLIC_RATEandroid.permission.health.WRITE_BASAL_METABOLIC_RATE
BloodGlucoseandroid.permission.health.READ_BLOOD_GLUCOSEandroid.permission.health.WRITE_BLOOD_GLUCOSE
BloodPressureandroid.permission.health.READ_BLOOD_PRESSUREandroid.permission.health.WRITE_BLOOD_PRESSURE
BodyFatandroid.permission.health.READ_BODY_FATandroid.permission.health.WRITE_BODY_FAT
BodyTemperatureandroid.permission.health.READ_BODY_TEMPERATUREandroid.permission.health.WRITE_BODY_TEMPERATURE
BoneMassandroid.permission.health.READ_BONE_MASSandroid.permission.health.WRITE_BONE_MASS
CervicalMucusandroid.permission.health.READ_CERVICAL_MUCUSandroid.permission.health.WRITE_CERVICAL_MUCUS
CyclingPedalingCadenceandroid.permission.health.READ_EXERCISEandroid.permission.health.WRITE_EXERCISE
Distanceandroid.permission.health.READ_DISTANCEandroid.permission.health.WRITE_DISTANCE
ElevationGainedandroid.permission.health.READ_ELEVATION_GAINEDandroid.permission.health.WRITE_ELEVATION_GAINED
ExerciseSessionandroid.permission.health.READ_EXERCISEandroid.permission.health.WRITE_EXERCISE
FloorsClimbedandroid.permission.health.READ_FLOORS_CLIMBEDandroid.permission.health.WRITE_FLOORS_CLIMBED
HeartRateandroid.permission.health.READ_HEART_RATEandroid.permission.health.WRITE_HEART_RATE
Heightandroid.permission.health.READ_HEIGHTandroid.permission.health.WRITE_HEIGHT
Hydrationandroid.permission.health.READ_HYDRATIONandroid.permission.health.WRITE_HYDRATION
LeanBodyMassandroid.permission.health.READ_LEAN_BODY_MASSandroid.permission.health.WRITE_LEAN_BODY_MASS
MenstruationFlowandroid.permission.health.READ_MENSTRUATIONandroid.permission.health.WRITE_MENSTRUATION
MenstruationPeriodandroid.permission.health.READ_MENSTRUATIONandroid.permission.health.WRITE_MENSTRUATION
Nutritionandroid.permission.health.READ_NUTRITIONandroid.permission.health.WRITE_NUTRITION
OvulationTestandroid.permission.health.READ_OVULATION_TESTandroid.permission.health.WRITE_OVULATION_TEST
OxygenSaturationandroid.permission.health.READ_OXYGEN_SATURATIONandroid.permission.health.WRITE_OXYGEN_SATURATION
Powerandroid.permission.health.READ_POWERandroid.permission.health.WRITE_POWER
RespiratoryRateandroid.permission.health.READ_RESPIRATORY_RATEandroid.permission.health.WRITE_RESPIRATORY_RATE
RestingHeartRateandroid.permission.health.READ_RESTING_HEART_RATEandroid.permission.health.WRITE_RESTING_HEART_RATE
SexualActivityandroid.permission.health.READ_SEXUAL_ACTIVITYandroid.permission.health.WRITE_SEXUAL_ACTIVITY
SleepSessionandroid.permission.health.READ_SLEEPandroid.permission.health.WRITE_SLEEP
Speedandroid.permission.health.READ_SPEEDandroid.permission.health.WRITE_SPEED
StepsCadenceandroid.permission.health.READ_STEPSandroid.permission.health.WRITE_STEPS
Stepsandroid.permission.health.READ_STEPSandroid.permission.health.WRITE_STEPS
TotalCaloriesBurnedandroid.permission.health.READ_TOTAL_CALORIES_BURNEDandroid.permission.health.WRITE_TOTAL_CALORIES_BURNED
Vo2Maxandroid.permission.health.READ_VO2_MAXandroid.permission.health.WRITE_VO2_MAX
Weightandroid.permission.health.READ_WEIGHTandroid.permission.health.WRITE_WEIGHT
WheelchairPushesandroid.permission.health.READ_WHEELCHAIR_PUSHESandroid.permission.health.WRITE_WHEELCHAIR_PUSHES
WriteExerciseRouteandroid.permission.health.WRITE_EXERCISE_ROUTEN/A

You can read more about data types and permissions here.

- + \ No newline at end of file diff --git a/docs/troubleshooting/index.html b/docs/troubleshooting/index.html index 368c0aa..9760757 100644 --- a/docs/troubleshooting/index.html +++ b/docs/troubleshooting/index.html @@ -4,13 +4,13 @@ Troubleshooting | React Native Health Connect - + - + \ No newline at end of file diff --git a/index.html b/index.html index 79ecc9a..a995b4a 100644 --- a/index.html +++ b/index.html @@ -4,13 +4,13 @@ React Native Health Connect - +
- + \ No newline at end of file diff --git a/markdown-page/index.html b/markdown-page/index.html index c386538..67b9352 100644 --- a/markdown-page/index.html +++ b/markdown-page/index.html @@ -4,13 +4,13 @@ Markdown page example | React Native Health Connect - +

Markdown page example

You don't need React to write simple standalone pages.

- + \ No newline at end of file