Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support bridgeless architecture lazy loaded functions #396

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

andrewzey
Copy link

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

@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
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)

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
2 participants