Hello, I have an app for a research study that has been approved and authorized to use SensorKit. All my permissions, entitlements and authorizations are in order, but I still can't get any data. The didFetchResult is not being called even though didCompleteFetch is called. I have waited for over 24 hours, but it still returns no samples. Please, I would appreciate any help on this issue. Thank you
func sensorReader(
_ reader: SRSensorReader,
fetchingRequest: SRFetchRequest,
didFetchResult result: SRFetchResult<AnyObject>
) {
receivedResultsInCurrentFetch = true
print("✅ SensorKit fetch result received for: \(sensorKey)")
AppLogger.shared.log("SensorKit fetch result received for \(sensorKey)")
if let sample = result.sample as? T {
print("✅ SensorKit sample matched expected type for \(sensorKey): \(T.self)")
AppLogger.shared.log("SensorKit sample matched expected type for \(sensorKey): \(T.self)")
processSample(sample)
} else {
print("❌ SensorKit sample did not match expected type for \(sensorKey): \(T.self)")
AppLogger.shared.log("SensorKit sample did not match expected type for \(sensorKey): \(T.self)")
}
}
func sensorReader(_ reader: SRSensorReader, didCompleteFetch request: SRFetchRequest) {
if receivedResultsInCurrentFetch, let lastRequestedUpperBound {
session.setSensorKitLastFetchTime(lastRequestedUpperBound, for: sensorKey)
print("✅ SensorKit fetch completed with samples for \(sensorKey). Checkpoint updated.")
} else {
print("⚠️ SensorKit fetch completed for \(sensorKey) with no samples.")
AppLogger.shared.log("SensorKit fetch completed for \(sensorKey) with no samples. Keeping previous checkpoint so delayed SensorKit data is not skipped.")
}
isFetchInFlight = false
completePendingFetches(success: true)
print("✅ SensorKit fetch completed for: \(sensorKey)")
AppLogger.shared.log("Fetch request completed for sensor type: \(T.self)")
}