Closed
Description
Describe the bug
Hello, Looks like AppleHealthKit.saveWorkout() doesn't save a workout
To Reproduce
Steps to reproduce the behavior:
I do in this way
let options = {
type: 'AmericanFootball', // See HealthActivity Enum
startDate: new Date(2021, 5, 12, 12, 0, 0).toISOString(),
endDate: new Date(2021, 5, 12, 13, 30, 0).toISOString(),
energyBurned: 50, // In Energy burned unit
distance: 50, // In Distance unit
}
AppleHealthKit.saveWorkout(
(options),
(err, results) => {
if (err) {
console.log('error saving workout to Healthkit: ', err)
return
}
// workout successfully saved
console.log(results, 'workout successfully saved')
},
)
The interestiong thing is thay I do receive console.log result 'workout successfully saved' with the UUIDString.
Also, what about saveWeight method, it is working and I do saved data in apple health
All necessary permissions are granted in this way:
const permissions = {
permissions: {
read: [AppleHealthKit.Constants.Permissions.HeartRate],
write: [
AppleHealthKit.Constants.Permissions.Steps,
AppleHealthKit.Constants.Permissions.Weight,
AppleHealthKit.Constants.Permissions.Workout,
],
},
}
AppleHealthKit.initHealthKit(permissions, (error) => {
/* Called after we receive a response from the system */
AppleHealthKit.getAuthStatus(permissions, (err, results) => {
console.log(err, results, 'AUTH STATUS')
})
if (error) {
console.log('[ERROR] Cannot grant permissions!')
}
})
Expected behavior
I do expect, that this activity will appear in apple health app
Screenshots
Screenshot
Smartphone:
- Device: iPhone 8 simulator, iPhone 11 real
- OS: iOS 14.4
- Version "react-native-health": "^1.7.2"