blood pressure query issue

My Blood Pressure query isn't working correctly. Front end is React Native. Trying to access healthkit through RN's native modules.

In the below code if I remove the predicate, I get ALL the values (I can log it) with an error:
"Illegal callback invocation from native module. This callback type only permits a single invocation from native code."

If I add a predicate I do not get any error, it just doesn't work.

I want it to return just today's BP values. Where am I going wrong here?

Code Block
func getBloodPressure(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
guard let type = HKQuantityType.correlationType(forIdentifier: HKCorrelationTypeIdentifier.bloodPressure),
let systolicType = HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bloodPressureSystolic),
let diastolicType = HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.bloodPressureDiastolic) else {
return
}
let startDate = Date()
let endDate = Date()
let predicate = HKQuery.predicateForSamples(withStart: startDate, end: endDate, options: .strictStartDate)
let sampleQuery = HKSampleQuery(sampleType: type, predicate: predicate, limit: 0, sortDescriptors: nil) { (sampleQuery, results, error) in
if let dataList = results as? [HKCorrelation] {
for data in dataList {
if let data1 = data.objects(for: systolicType).first as? HKQuantitySample,
let data2 = data.objects(for: diastolicType).first as? HKQuantitySample {
let value1 = data1.quantity.doubleValue(for: HKUnit.millimeterOfMercury())
let value2 = data2.quantity.doubleValue(for: HKUnit.millimeterOfMercury())
print("BP:", "\(value1) / \(value2)")
resolve("\(value1) / \(value2)")
}
}
}
}
healthStore.execute(sampleQuery)
}


Log:
Code Block
2021-01-22 15:20:48.155422+0800 nativehealth[67473:3946249] Metal API Validation Enabled
BP: 118.0 / 65.0
BP: 122.0 / 78.0
2021-01-22 15:20:51.598068+0800 nativehealth[67473:3946249] [native] Illegal callback invocation from native module. This callback type only permits a single invocation from native code.
2021-01-22 15:20:51.601640+0800 nativehealth[67473:3946264] [javascript] 118


Where do you call getBloodPressure ? (unless it is an optional func in React Native API, which I'm not familiar with ?)
blood pressure query issue
 
 
Q