Skip to content

AppleHealthKit.saveWorkout() doesn't save a workout #99

Closed
@tagirahmad

Description

@tagirahmad

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 ![Simulator Screen Shot - iPhone 8 - 2021-05-16 at 10 38 52](https://user-images.githubusercontent.com/43289913/118389508-f03bc100-b632-11eb-9ca5-2dd4c0f5d64f.png)

Smartphone:

  • Device: iPhone 8 simulator, iPhone 11 real
  • OS: iOS 14.4
  • Version "react-native-health": "^1.7.2"

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions