matinzd / react-native-health-connect

React native library for health connect (Android only)
http://matinzd.github.io/react-native-health-connect
MIT License
228 stars 43 forks source link

deleteRecordsByUuids or deleteRecordsByTimeRange never resolves and no exceptions thrown #161

Open RM-Smilamind opened 1 month ago

RM-Smilamind commented 1 month ago

Describe the bug Calling deleteRecordsByUuids or deleteRecordsByTimeRange never resolves and no exceptions are thrown but the record is deleted from Health Connect.

To Reproduce 1) Add an Exercise in Health Connect 2) Try to delete that Exercise using UUID or time range

Expected behavior
Exercise should be deleted from Health Connect and call to deleteRecordsByUuids should resolve The code below will print "DELETE EXERCISE SESSION XXX" and nothing else. My app has read and write permission for Exercise in Health Connect and I can see the Exercise added and successfully removed (if I stop execution before to delete the records).

Minimal Reproducible

import { deleteRecordsByUuids, ExerciseType, insertRecords } from 'react-native-health-connect';
export async function testHealthConnectDelete(): Promise<boolean> {
  try {
    const uuid = (await insertRecords([{
      recordType: 'ExerciseSession',
      exerciseType: ExerciseType.OTHER_WORKOUT,
      startTime: new Date('2024-09-26 15:00:00').toISOString(),
      endTime: new Date('2024-09-26 16:00:00').toISOString()
    }]))[0];
    console.log(`DELETE EXERCISE SESSION ${uuid}`);
    await deleteRecordsByUuids('ExerciseSession', [uuid], []);
    console.log('EXERCISE SESSION DELETED');
    return true;
  } catch (error) {
    console.log(error);
  }
  return false;
}

Environment:

blopa commented 1 day ago

Same here