Skip to main content

Migrate From Apple Health or Health Connect

Only use this migration guide if you want to include the both sdks Apple Health and Health Connect in one integration

The current integration of Apple Health and Health Connect is still operational and continues to receive support and updates. The propuse of this is to guide to have only one integration for the both services

Installation

You need to install rook-sdk package and linked properly according to the case in android and iOS

npm i react-native-rook-sdk

For iOS you have to run npx pod-install and for android you don't have to do anything else for install.

Configuration

If you have already configured Health Connect and Apple Health services, you don't need to take any further action. However, if you haven't, please refer to the fundamentals documentation for instructions on how to do so.

Imports

-import { RookSyncGate } from 'react-native-rook-sdk-health-connect';
-import { RookSyncGate } from 'react-native-rook-sdk-apple-health';
+import { RookSyncGate } from 'react-native-rook-sdk';

-import {useRookSyncConfiguration} from 'react-native-rook-sdk-health-connect'
-import {useRookConfiguration} from 'react-native-rook-sdk-apple-health'
+import {useRookConfiguration} from 'react-native-rook-sdk'

-import {useRookSyncEvents} from 'react-native-rook-sdk-health-connect'
-import {useRookEvents} from 'react-native-rook-sdk-apple-health'
+import {useRookEvents} from 'react-native-rook-sdk'

-import {useRookSyncPermissions} from 'react-native-rook-sdk-health-connect'
-import {useRookPermissions} from 'react-native-rook-sdk-apple-health'
+import {useRookPermissions} from 'react-native-rook-sdk'

-import {useRookSyncSummaries} from 'react-native-rook-sdk-health-connect'
-import {useRookSummaries} from 'react-native-rook-sdk-apple-health'
+import {useRookSummaries} from 'react-native-rook-sdk'

-import {useRookBackground} from 'react-native-rook-sdk-apple-health'
+import {useRookAppleHealth} from 'react-native-rook-sdk'

RookSyncGate

You no longer need to use both gates. By switching the import to react-native-rook-sdk, you only need one gate to add your credentials.
-import { RookSyncGate } from 'react-native-rook-sdk-health-connect';
-import { RookSyncGate } from 'react-native-rook-sdk-apple-health';
+import { RookSyncGate } from 'react-native-rook-sdk';

export const ExampleComponent = () => {

return (
<RookSyncGate
environment="sandbox"
clientUUID="YOUR-CREDENTIALS"
password="YOUR-CREDENTIALS"
>
<YOUR-COMPONENTS />
</RookSyncGate>
)
}

Manual Sync

Changes for manual sync of summaries

-import {useRookSyncSummaries} from 'react-native-rook-sdk-health-connect'
-import {useRookSummaries} from 'react-native-rook-sdk-apple-health'
+import {useRookSummaries} from 'react-native-rook-sdk'

export const ExampleComponent = () => {

-const rookSummaries = useRookSyncSummaries();
-const rookSummaries = useRookSummaries(); // For Apple Health
+const rookSummaries = useRookSummaries();

const handleManualSyncSummaries = async () => {
try {
await rookSummaries.{pillar-to-sync}()
}
catch(error) {
console.log(error)
}
}

return (
<Button title="Sync" onPress={handleManualSyncSummaries}/>
)
}

The rest of the functions of react-native-rook-sdk.useRookSummaries are named as useRookSyncSummaries and react-native-rook-sdk-apple-health.useRookSummaries

Changes for manual sync of Events

-import {useRookSyncEvents} from 'react-native-rook-sdk-health-connect'
-import {useRookEvents} from 'react-native-rook-sdk-apple-health'
+import {useRookEvents} from 'react-native-rook-sdk'

export const ExampleComponent = () => {

-const rookEvents = useRookSyncEvents();
-const rookEvents = useRookEvents(); // For Apple Health
+const rookEvents = useRookEvents();

const handleManualSyncSummaries = async () => {
try {
await rookEvens.{events-to-sync}()
}
catch(error) {
console.log(error)
}
}

return (
<Button title="Sync" onPress={handleManualSyncSummaries}/>
)
}

The rest of the functions of react-native-rook-sdk.useRookEvents are named as useRookSyncEvents and react-native-rook-sdk-apple-health.useRookEvents but with an 's' at the end.

const {
ready,
syncYesterdayEvents,
syncTrainingEvent,
syncBloodGlucoseEvent,
syncBloodPressureEvent,
syncBodyMetricsEvent,
syncBodyHeartRateEvent,
syncPhysicalHeartRateEvent,
syncHealthConnectHydrationEvents,
syncHealthConnectNutritionEvents,
syncPhysicalOxygenationEvent,
syncBodyOxygenationEvent,
syncTemperatureEvent,
reSyncFailedEvents,
} = useRookEvents();

Background Sync

You need reference how to activete please refer to the documentation

Apple Health

import {useEffect} from 'react'
-import {useRookBackGround} from 'react-native-rook-sdk-apple-health'
+import {useRookAppleHealth} from 'react-native-rook-sdk'

export const ExampleComponent = () => {

-const { enableBackgroundForSummaries, enableBackgroundForEvents } = useRookSyncEvents();
+const { enableBackGroundUpdates } = useRookAppleHealth();

useEffect(() => {
-enableBackgroundForSummaries().then().cath()
-enableBackgroundForEvents().then().cath()
+enableBackGroundUpdates().then().cath()
}, [])

return (
...
)
}

Health Connect

import {useEffect} from 'react'
-import {useRookSyncConfiguration} from 'react-native-rook-sdk-health-connect'
+import {useRookConfiguration} from 'react-native-rook-sdk'

export const ExampleComponent = () => {

-const { sheduleYesterdaySync } = useRookSyncEvents();
+const {scheduleAndroidYesterdaySync} = useRookAppleHealth();

useEffect(() => {
scheduleAndroidYesterdaySync().then().cath()
}, [])

return (
...
)
}