Skip to content

Support bridgeless architecture lazy loaded functions#396

Open
andrewzey wants to merge 2 commits into
agencyenterprise:masterfrom
andrewzey:patch-1
Open

Support bridgeless architecture lazy loaded functions#396
andrewzey wants to merge 2 commits into
agencyenterprise:masterfrom
andrewzey:patch-1

Conversation

@andrewzey
Copy link
Copy Markdown

Description

Exports functions properly for bridgeless architecture that is default as of react native 0.76.0

Fixes #395

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have checked my code and corrected any misspellings

Copy link
Copy Markdown

@Ashalbulk Ashalbulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!
Small adjustment:

import { Activities, Observers, Permissions, Units } from './src/constants'

const { AppleHealthKit } = require('react-native').NativeModules

export const HealthKit = {
  initHealthKit: AppleHealthKit.initHealthKit,
  isAvailable: AppleHealthKit.isAvailable,
  getBiologicalSex: AppleHealthKit.getBiologicalSex,
  getBloodType: AppleHealthKit.getBloodType,
  getDateOfBirth: AppleHealthKit.getDateOfBirth,
  getLatestWeight: AppleHealthKit.getLatestWeight,
  getWeightSamples: AppleHealthKit.getWeightSamples,
  saveWeight: AppleHealthKit.saveWeight,
  getLatestHeight: AppleHealthKit.getLatestHeight,
  getHeightSamples: AppleHealthKit.getHeightSamples,
  saveHeight: AppleHealthKit.saveHeight,
  getLatestWaistCircumference: AppleHealthKit.getLatestWaistCircumference,
  getWaistCircumferenceSamples: AppleHealthKit.getWaistCircumferenceSamples,
  saveWaistCircumference: AppleHealthKit.saveWaistCircumference,
  getLatestPeakFlow: AppleHealthKit.getLatestPeakFlow,
  getPeakFlowSamples: AppleHealthKit.getPeakFlowSamples,
  savePeakFlow: AppleHealthKit.savePeakFlow,
  saveLeanBodyMass: AppleHealthKit.saveLeanBodyMass,
  getLatestBmi: AppleHealthKit.getLatestBmi,
  getBmiSamples: AppleHealthKit.getBmiSamples,
  saveBmi: AppleHealthKit.saveBmi,
  getLatestBodyFatPercentage: AppleHealthKit.getLatestBodyFatPercentage,
  getBodyFatPercentageSamples: AppleHealthKit.getBodyFatPercentageSamples,
  getLatestLeanBodyMass: AppleHealthKit.getLatestLeanBodyMass,
  getLeanBodyMassSamples: AppleHealthKit.getLeanBodyMassSamples,
  getStepCount: AppleHealthKit.getStepCount,
  getSamples: AppleHealthKit.getSamples,
  getAnchoredWorkouts: AppleHealthKit.getAnchoredWorkouts,
  getDailyStepCountSamples: AppleHealthKit.getDailyStepCountSamples,
  saveSteps: AppleHealthKit.saveSteps,
  saveWalkingRunningDistance: AppleHealthKit.saveWalkingRunningDistance,
  getDistanceWalkingRunning: AppleHealthKit.getDistanceWalkingRunning,
  getDailyDistanceWalkingRunningSamples: AppleHealthKit.getDailyDistanceWalkingRunningSamples,
  getDistanceCycling: AppleHealthKit.getDistanceCycling,
  getDailyDistanceCyclingSamples: AppleHealthKit.getDailyDistanceCyclingSamples,
  getFlightsClimbed: AppleHealthKit.getFlightsClimbed,
  getDailyFlightsClimbedSamples: AppleHealthKit.getDailyFlightsClimbedSamples,
  getEnergyConsumedSamples: AppleHealthKit.getEnergyConsumedSamples,
  getProteinSamples: AppleHealthKit.getProteinSamples,
  getFiberSamples: AppleHealthKit.getFiberSamples,
  getTotalFatSamples: AppleHealthKit.getTotalFatSamples,
  saveFood: AppleHealthKit.saveFood,
  saveWater: AppleHealthKit.saveWater,
  getWater: AppleHealthKit.getWater,
  saveHeartRateSample: AppleHealthKit.saveHeartRateSample,
  getWaterSamples: AppleHealthKit.getWaterSamples,
  getHeartRateSamples: AppleHealthKit.getHeartRateSamples,
  getRestingHeartRate: AppleHealthKit.getRestingHeartRate,
  getWalkingHeartRateAverage: AppleHealthKit.getWalkingHeartRateAverage,
  getActiveEnergyBurned: AppleHealthKit.getActiveEnergyBurned,
  getBasalEnergyBurned: AppleHealthKit.getBasalEnergyBurned,
  getAppleExerciseTime: AppleHealthKit.getAppleExerciseTime,
  getAppleStandTime: AppleHealthKit.getAppleStandTime,
  getVo2MaxSamples: AppleHealthKit.getVo2MaxSamples,
  getBodyTemperatureSamples: AppleHealthKit.getBodyTemperatureSamples,
  getBloodPressureSamples: AppleHealthKit.getBloodPressureSamples,
  getRespiratoryRateSamples: AppleHealthKit.getRespiratoryRateSamples,
  getHeartRateVariabilitySamples: AppleHealthKit.getHeartRateVariabilitySamples,
  getHeartbeatSeriesSamples: AppleHealthKit.getHeartbeatSeriesSamples,
  getRestingHeartRateSamples: AppleHealthKit.getRestingHeartRateSamples,
  getBloodGlucoseSamples: AppleHealthKit.getBloodGlucoseSamples,
  getCarbohydratesSamples: AppleHealthKit.getCarbohydratesSamples,
  saveBloodGlucoseSample: AppleHealthKit.saveBloodGlucoseSample,
  saveCarbohydratesSample: AppleHealthKit.saveCarbohydratesSample,
  deleteBloodGlucoseSample: AppleHealthKit.deleteBloodGlucoseSample,
  deleteCarbohydratesSample: AppleHealthKit.deleteCarbohydratesSample,
  getSleepSamples: AppleHealthKit.getSleepSamples,
  getInfo: AppleHealthKit.getInfo,
  getMindfulSession: AppleHealthKit.getMindfulSession,
  saveMindfulSession: AppleHealthKit.saveMindfulSession,
  getWorkoutRouteSamples: AppleHealthKit.getWorkoutRouteSamples,
  saveWorkout: AppleHealthKit.saveWorkout,
  getAuthStatus: AppleHealthKit.getAuthStatus,
  getLatestBloodAlcoholContent: AppleHealthKit.getLatestBloodAlcoholContent,
  getBloodAlcoholContentSamples: AppleHealthKit.getBloodAlcoholContentSamples,
  saveBloodAlcoholContent: AppleHealthKit.saveBloodAlcoholContent,
  getDistanceSwimming: AppleHealthKit.getDistanceSwimming,
  getDailyDistanceSwimmingSamples: AppleHealthKit.getDailyDistanceSwimmingSamples,
  getOxygenSaturationSamples: AppleHealthKit.getOxygenSaturationSamples,
  getElectrocardiogramSamples: AppleHealthKit.getElectrocardiogramSamples,
  saveBodyFatPercentage: AppleHealthKit.saveBodyFatPercentage,
  saveBodyTemperature: AppleHealthKit.saveBodyTemperature,
  getEnvironmentalAudioExposure: AppleHealthKit.getEnvironmentalAudioExposure,
  getHeadphoneAudioExposure: AppleHealthKit.getHeadphoneAudioExposure,
  getClinicalRecords: AppleHealthKit.getClinicalRecords,
  getActivitySummary: AppleHealthKit.getActivitySummary,
  getInsulinDeliverySamples: AppleHealthKit.getInsulinDeliverySamples,
  saveInsulinDeliverySample: AppleHealthKit.saveInsulinDeliverySample,
  deleteInsulinDeliverySample: AppleHealthKit.deleteInsulinDeliverySample,

  Constants: {
    Activities,
    Observers,
    Permissions,
    Units,
  },
}

module.exports = HealthKit

@andrewzey
Copy link
Copy Markdown
Author

@Ashalbulk Thanks for the review. I updated the code accordingly as well as my yarn patch and confirmed this works properly on React Native 0.76.0 bridgeless architecture both in development (using Xcode 16.1 running on iOS 18.1 simulator) as well as in production physically on a device (iPhone 15 Pro @ iOS 18.0.1 built via Bitrise using XCode 16.0)

@andrewzey andrewzey requested a review from Ashalbulk October 31, 2024 23:09
@willashley23
Copy link
Copy Markdown

Thanks for putting this PR up! Are there any blockers with merging this in? I rely on this library and would love to be able to update to the new arch!

@ben-edge
Copy link
Copy Markdown

Also relying on this to upgrade to 0.76! Would be great to get this in please.

@garywongzc
Copy link
Copy Markdown

Thanks for the PR! Is there anything preventing it from being merged? Would love to see this released soon. Thanks

@andrewzey
Copy link
Copy Markdown
Author

image

Copy link
Copy Markdown

@garywongzc garywongzc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@garywongzc
Copy link
Copy Markdown

Hey @GGGava @ruan-azevedo can you help us with this PR please? 🙏

garywongzc added a commit to garywongzc/lucid-react-native-health that referenced this pull request Dec 11, 2024
@ghure
Copy link
Copy Markdown

ghure commented Dec 14, 2024

Guys can you please merge this PR.

Copy link
Copy Markdown

@ghure ghure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good to me

Copy link
Copy Markdown

@carozo carozo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, using this on Android is throwing this error:
Screenshot 2024-12-24 at 1 58 43 PM
I was able to fix it using optional chaining:

  initHealthKit: AppleHealthKit?.initHealthKit,
  isAvailable: AppleHealthKit?.isAvailable,
  getBiologicalSex: AppleHealthKit?.getBiologicalSex,
  getBloodType: AppleHealthKit?.getBloodType,
  getDateOfBirth: AppleHealthKit?.getDateOfBirth,
  getLatestWeight: AppleHealthKit?.getLatestWeight,
  getWeightSamples: AppleHealthKit?.getWeightSamples,
  saveWeight: AppleHealthKit?.saveWeight,
  getLatestHeight: AppleHealthKit?.getLatestHeight,
  getHeightSamples: AppleHealthKit?.getHeightSamples,
  saveHeight: AppleHealthKit?.saveHeight,
  getLatestWaistCircumference: AppleHealthKit?.getLatestWaistCircumference,
  getWaistCircumferenceSamples: AppleHealthKit?.getWaistCircumferenceSamples,
  saveWaistCircumference: AppleHealthKit?.saveWaistCircumference,
  getLatestPeakFlow: AppleHealthKit?.getLatestPeakFlow,
  getPeakFlowSamples: AppleHealthKit?.getPeakFlowSamples,
  savePeakFlow: AppleHealthKit?.savePeakFlow,
  saveLeanBodyMass: AppleHealthKit?.saveLeanBodyMass,
  getLatestBmi: AppleHealthKit?.getLatestBmi,
  getBmiSamples: AppleHealthKit?.getBmiSamples,
  saveBmi: AppleHealthKit?.saveBmi,
  getLatestBodyFatPercentage: AppleHealthKit?.getLatestBodyFatPercentage,
  getBodyFatPercentageSamples: AppleHealthKit?.getBodyFatPercentageSamples,
  getLatestLeanBodyMass: AppleHealthKit?.getLatestLeanBodyMass,
  getLeanBodyMassSamples: AppleHealthKit?.getLeanBodyMassSamples,
  getStepCount: AppleHealthKit?.getStepCount,
  getSamples: AppleHealthKit?.getSamples,
  getAnchoredWorkouts: AppleHealthKit?.getAnchoredWorkouts,
  getDailyStepCountSamples: AppleHealthKit?.getDailyStepCountSamples,
  saveSteps: AppleHealthKit?.saveSteps,
  saveWalkingRunningDistance: AppleHealthKit?.saveWalkingRunningDistance,
  getDistanceWalkingRunning: AppleHealthKit?.getDistanceWalkingRunning,
  getDailyDistanceWalkingRunningSamples: AppleHealthKit?.getDailyDistanceWalkingRunningSamples,
  getDistanceCycling: AppleHealthKit?.getDistanceCycling,
  getDailyDistanceCyclingSamples: AppleHealthKit?.getDailyDistanceCyclingSamples,
  getFlightsClimbed: AppleHealthKit?.getFlightsClimbed,
  getDailyFlightsClimbedSamples: AppleHealthKit?.getDailyFlightsClimbedSamples,
  getEnergyConsumedSamples: AppleHealthKit?.getEnergyConsumedSamples,
  getProteinSamples: AppleHealthKit?.getProteinSamples,
  getFiberSamples: AppleHealthKit?.getFiberSamples,
  getTotalFatSamples: AppleHealthKit?.getTotalFatSamples,
  saveFood: AppleHealthKit?.saveFood,
  saveWater: AppleHealthKit?.saveWater,
  getWater: AppleHealthKit?.getWater,
  saveHeartRateSample: AppleHealthKit?.saveHeartRateSample,
  getWaterSamples: AppleHealthKit?.getWaterSamples,
  getHeartRateSamples: AppleHealthKit?.getHeartRateSamples,
  getRestingHeartRate: AppleHealthKit?.getRestingHeartRate,
  getWalkingHeartRateAverage: AppleHealthKit?.getWalkingHeartRateAverage,
  getActiveEnergyBurned: AppleHealthKit?.getActiveEnergyBurned,
  getBasalEnergyBurned: AppleHealthKit?.getBasalEnergyBurned,
  getAppleExerciseTime: AppleHealthKit?.getAppleExerciseTime,
  getAppleStandTime: AppleHealthKit?.getAppleStandTime,
  getVo2MaxSamples: AppleHealthKit?.getVo2MaxSamples,
  getBodyTemperatureSamples: AppleHealthKit?.getBodyTemperatureSamples,
  getBloodPressureSamples: AppleHealthKit?.getBloodPressureSamples,
  getRespiratoryRateSamples: AppleHealthKit?.getRespiratoryRateSamples,
  getHeartRateVariabilitySamples: AppleHealthKit?.getHeartRateVariabilitySamples,
  getHeartbeatSeriesSamples: AppleHealthKit?.getHeartbeatSeriesSamples,
  getRestingHeartRateSamples: AppleHealthKit?.getRestingHeartRateSamples,
  getBloodGlucoseSamples: AppleHealthKit?.getBloodGlucoseSamples,
  getCarbohydratesSamples: AppleHealthKit?.getCarbohydratesSamples,
  saveBloodGlucoseSample: AppleHealthKit?.saveBloodGlucoseSample,
  saveCarbohydratesSample: AppleHealthKit?.saveCarbohydratesSample,
  deleteBloodGlucoseSample: AppleHealthKit?.deleteBloodGlucoseSample,
  deleteCarbohydratesSample: AppleHealthKit?.deleteCarbohydratesSample,
  getSleepSamples: AppleHealthKit?.getSleepSamples,
  getInfo: AppleHealthKit?.getInfo,
  getMindfulSession: AppleHealthKit?.getMindfulSession,
  saveMindfulSession: AppleHealthKit?.saveMindfulSession,
  getWorkoutRouteSamples: AppleHealthKit?.getWorkoutRouteSamples,
  saveWorkout: AppleHealthKit?.saveWorkout,
  getAuthStatus: AppleHealthKit?.getAuthStatus,
  getLatestBloodAlcoholContent: AppleHealthKit?.getLatestBloodAlcoholContent,
  getBloodAlcoholContentSamples: AppleHealthKit?.getBloodAlcoholContentSamples,
  saveBloodAlcoholContent: AppleHealthKit?.saveBloodAlcoholContent,
  getDistanceSwimming: AppleHealthKit?.getDistanceSwimming,
  getDailyDistanceSwimmingSamples: AppleHealthKit?.getDailyDistanceSwimmingSamples,
  getOxygenSaturationSamples: AppleHealthKit?.getOxygenSaturationSamples,
  getElectrocardiogramSamples: AppleHealthKit?.getElectrocardiogramSamples,
  saveBodyFatPercentage: AppleHealthKit?.saveBodyFatPercentage,
  saveBodyTemperature: AppleHealthKit?.saveBodyTemperature,
  getEnvironmentalAudioExposure: AppleHealthKit?.getEnvironmentalAudioExposure,
  getHeadphoneAudioExposure: AppleHealthKit?.getHeadphoneAudioExposure,
  getClinicalRecords: AppleHealthKit?.getClinicalRecords,
  getActivitySummary: AppleHealthKit?.getActivitySummary,
  getInsulinDeliverySamples: AppleHealthKit?.getInsulinDeliverySamples,
  saveInsulinDeliverySample: AppleHealthKit?.saveInsulinDeliverySample,
  deleteInsulinDeliverySample: AppleHealthKit?.deleteInsulinDeliverySample,

@bfblackjack
Copy link
Copy Markdown

Can we get this reviewed/merged, please?

@fmmattioni
Copy link
Copy Markdown

I believe this is a more actively developed project: https://github.com/kingstinct/react-native-healthkit

@tremblerz
Copy link
Copy Markdown

Fixed the issue for me

@colinharris05
Copy link
Copy Markdown

Friendly ping hoping to see this merged!

Copy link
Copy Markdown

@mrtncode mrtncode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything works fine!

Copy link
Copy Markdown

@D0Dam D0Dam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@timtres-eylo
Copy link
Copy Markdown

Please merge this one. Why is it still open?

@sfkaos
Copy link
Copy Markdown

sfkaos commented Mar 27, 2025

Great job on this! would love to see it merged as well :)

@shobith
Copy link
Copy Markdown

shobith commented Apr 3, 2025

when will this be merged?

@shobith
Copy link
Copy Markdown

shobith commented Apr 3, 2025

when will this be merged?

To be honest, I think never 😄 I would choose another package..

any recommendations?? 😄

@G2Jose
Copy link
Copy Markdown

G2Jose commented May 17, 2025

I hope this gets merged soon, but if you're blocked by this and use yarn 2+, here's how you can get these changes.

  1. Make a new .yarn/patches/react-native-health-npm-1.19.0-8b07baa40c.patch file with the following content:
diff --git a/index.js b/index.js
index 06e5105d5057fc403ed92584821c6b22ff210ff3..ad5a54b08491491bb4fa30ea3d726dff4e73ddbd 100644
--- a/index.js
+++ b/index.js
@@ -2,13 +2,105 @@ import { Activities, Observers, Permissions, Units } from './src/constants'
 
 const { AppleHealthKit } = require('react-native').NativeModules
 
-export const HealthKit = Object.assign({}, AppleHealthKit, {
+export const HealthKit = {
+  initHealthKit: AppleHealthKit.initHealthKit,
+  isAvailable: AppleHealthKit.isAvailable,
+  getBiologicalSex: AppleHealthKit.getBiologicalSex,
+  getBloodType: AppleHealthKit.getBloodType,
+  getDateOfBirth: AppleHealthKit.getDateOfBirth,
+  getLatestWeight: AppleHealthKit.getLatestWeight,
+  getWeightSamples: AppleHealthKit.getWeightSamples,
+  saveWeight: AppleHealthKit.saveWeight,
+  getLatestHeight: AppleHealthKit.getLatestHeight,
+  getHeightSamples: AppleHealthKit.getHeightSamples,
+  saveHeight: AppleHealthKit.saveHeight,
+  getLatestWaistCircumference: AppleHealthKit.getLatestWaistCircumference,
+  getWaistCircumferenceSamples: AppleHealthKit.getWaistCircumferenceSamples,
+  saveWaistCircumference: AppleHealthKit.saveWaistCircumference,
+  getLatestPeakFlow: AppleHealthKit.getLatestPeakFlow,
+  getPeakFlowSamples: AppleHealthKit.getPeakFlowSamples,
+  savePeakFlow: AppleHealthKit.savePeakFlow,
+  saveLeanBodyMass: AppleHealthKit.saveLeanBodyMass,
+  getLatestBmi: AppleHealthKit.getLatestBmi,
+  getBmiSamples: AppleHealthKit.getBmiSamples,
+  saveBmi: AppleHealthKit.saveBmi,
+  getLatestBodyFatPercentage: AppleHealthKit.getLatestBodyFatPercentage,
+  getBodyFatPercentageSamples: AppleHealthKit.getBodyFatPercentageSamples,
+  getLatestLeanBodyMass: AppleHealthKit.getLatestLeanBodyMass,
+  getLeanBodyMassSamples: AppleHealthKit.getLeanBodyMassSamples,
+  getStepCount: AppleHealthKit.getStepCount,
+  getSamples: AppleHealthKit.getSamples,
+  getAnchoredWorkouts: AppleHealthKit.getAnchoredWorkouts,
+  getDailyStepCountSamples: AppleHealthKit.getDailyStepCountSamples,
+  saveSteps: AppleHealthKit.saveSteps,
+  saveWalkingRunningDistance: AppleHealthKit.saveWalkingRunningDistance,
+  getDistanceWalkingRunning: AppleHealthKit.getDistanceWalkingRunning,
+  getDailyDistanceWalkingRunningSamples:
+    AppleHealthKit.getDailyDistanceWalkingRunningSamples,
+  getDistanceCycling: AppleHealthKit.getDistanceCycling,
+  getDailyDistanceCyclingSamples: AppleHealthKit.getDailyDistanceCyclingSamples,
+  getFlightsClimbed: AppleHealthKit.getFlightsClimbed,
+  getDailyFlightsClimbedSamples: AppleHealthKit.getDailyFlightsClimbedSamples,
+  getEnergyConsumedSamples: AppleHealthKit.getEnergyConsumedSamples,
+  getProteinSamples: AppleHealthKit.getProteinSamples,
+  getFiberSamples: AppleHealthKit.getFiberSamples,
+  getTotalFatSamples: AppleHealthKit.getTotalFatSamples,
+  saveFood: AppleHealthKit.saveFood,
+  saveWater: AppleHealthKit.saveWater,
+  getWater: AppleHealthKit.getWater,
+  saveHeartRateSample: AppleHealthKit.saveHeartRateSample,
+  getWaterSamples: AppleHealthKit.getWaterSamples,
+  getHeartRateSamples: AppleHealthKit.getHeartRateSamples,
+  getRestingHeartRate: AppleHealthKit.getRestingHeartRate,
+  getWalkingHeartRateAverage: AppleHealthKit.getWalkingHeartRateAverage,
+  getActiveEnergyBurned: AppleHealthKit.getActiveEnergyBurned,
+  getBasalEnergyBurned: AppleHealthKit.getBasalEnergyBurned,
+  getAppleExerciseTime: AppleHealthKit.getAppleExerciseTime,
+  getAppleStandTime: AppleHealthKit.getAppleStandTime,
+  getVo2MaxSamples: AppleHealthKit.getVo2MaxSamples,
+  getBodyTemperatureSamples: AppleHealthKit.getBodyTemperatureSamples,
+  getBloodPressureSamples: AppleHealthKit.getBloodPressureSamples,
+  getRespiratoryRateSamples: AppleHealthKit.getRespiratoryRateSamples,
+  getHeartRateVariabilitySamples: AppleHealthKit.getHeartRateVariabilitySamples,
+  getHeartbeatSeriesSamples: AppleHealthKit.getHeartbeatSeriesSamples,
+  getRestingHeartRateSamples: AppleHealthKit.getRestingHeartRateSamples,
+  getBloodGlucoseSamples: AppleHealthKit.getBloodGlucoseSamples,
+  getCarbohydratesSamples: AppleHealthKit.getCarbohydratesSamples,
+  saveBloodGlucoseSample: AppleHealthKit.saveBloodGlucoseSample,
+  saveCarbohydratesSample: AppleHealthKit.saveCarbohydratesSample,
+  deleteBloodGlucoseSample: AppleHealthKit.deleteBloodGlucoseSample,
+  deleteCarbohydratesSample: AppleHealthKit.deleteCarbohydratesSample,
+  getSleepSamples: AppleHealthKit.getSleepSamples,
+  getInfo: AppleHealthKit.getInfo,
+  getMindfulSession: AppleHealthKit.getMindfulSession,
+  saveMindfulSession: AppleHealthKit.saveMindfulSession,
+  getWorkoutRouteSamples: AppleHealthKit.getWorkoutRouteSamples,
+  saveWorkout: AppleHealthKit.saveWorkout,
+  getAuthStatus: AppleHealthKit.getAuthStatus,
+  getLatestBloodAlcoholContent: AppleHealthKit.getLatestBloodAlcoholContent,
+  getBloodAlcoholContentSamples: AppleHealthKit.getBloodAlcoholContentSamples,
+  saveBloodAlcoholContent: AppleHealthKit.saveBloodAlcoholContent,
+  getDistanceSwimming: AppleHealthKit.getDistanceSwimming,
+  getDailyDistanceSwimmingSamples:
+    AppleHealthKit.getDailyDistanceSwimmingSamples,
+  getOxygenSaturationSamples: AppleHealthKit.getOxygenSaturationSamples,
+  getElectrocardiogramSamples: AppleHealthKit.getElectrocardiogramSamples,
+  saveBodyFatPercentage: AppleHealthKit.saveBodyFatPercentage,
+  saveBodyTemperature: AppleHealthKit.saveBodyTemperature,
+  getEnvironmentalAudioExposure: AppleHealthKit.getEnvironmentalAudioExposure,
+  getHeadphoneAudioExposure: AppleHealthKit.getHeadphoneAudioExposure,
+  getClinicalRecords: AppleHealthKit.getClinicalRecords,
+  getActivitySummary: AppleHealthKit.getActivitySummary,
+  getInsulinDeliverySamples: AppleHealthKit.getInsulinDeliverySamples,
+  saveInsulinDeliverySample: AppleHealthKit.saveInsulinDeliverySample,
+  deleteInsulinDeliverySample: AppleHealthKit.deleteInsulinDeliverySample,
+
   Constants: {
     Activities,
     Observers,
     Permissions,
     Units,
   },
-})
+}
 
 module.exports = HealthKit
  1. Change your package.json reference to react-native-health to "react-native-health": "patch:react-native-health@npm%3A1.19.0#~/.yarn/patches/react-native-health-npm-1.19.0-8b07baa40c.patch",
  2. Run yarn

If you're on npm or another package manager, you can do something similar with patch-package

@Puyush6889
Copy link
Copy Markdown

Is this getting merged soon? I see this is open since last year....

@dinesh-brilworks
Copy link
Copy Markdown

I am getting error on prepare eas build, it's working fine in debug mode,

Error: react-native-health@patch:react-native-health@npm%3A1.19.0#./.yarn/patches/react-native-health-npm-1.19.0-8b07baa40c.patch::locator=patient-engage%40workspace%3A.: ENOENT: no such file or directory, open '/private/var/folders/vx/wqk3fjq56mb28x4rdjyhnj880000gn/T/eas-build-local-nodejs/8e25056b-c83d-47c5-904e-0323d60811b5/build/.yarn/patches/react-native-health-npm-1.19.0-8b07baa40c.patch

@Axster
Copy link
Copy Markdown

Axster commented Jul 23, 2025

Great work!
But since it's not being merged, I'm forced to fork it for my organization.
I'd like to install directly from npm.

@francescoRobin
Copy link
Copy Markdown

Any new about this PR getting merged?

@goleary
Copy link
Copy Markdown

goleary commented Jan 15, 2026

ffs

tktcorporation added a commit to tktcorporation/good-morning that referenced this pull request Feb 27, 2026
react-native-health の index.js が Object.assign({}, AppleHealthKit, ...)
でネイティブモジュールをエクスポートしているが、New Architecture (Bridgeless)
では NativeModules のメソッドがプロトタイプ上に遅延ロードされるため、
Object.assign() では own enumerable property しかコピーされず
initHealthKit / getSleepSamples 等のメソッドが全て消失していた。

Object.create(AppleHealthKit) に変更し、プロトタイプチェーンを維持して
メソッドへのアクセスを確保する。

参考: agencyenterprise/react-native-health#404
参考: agencyenterprise/react-native-health#396
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doesn't work with new bridgeless architecture on 0.76.0