Open NguyenHoangMinhkkkk opened 3 years ago
I had the same issue, I think the error message you receive from the Google Fit API is incorrect.
For heart rate you also need to request the android.permission.BODY_SENSORS
permission. You can do so by using react-native-permissions.
This Error happen with
getHeartRate
method while the othes methods are working fine after sign in and allow permissions (permission HeartRate included).const permissions = [ { kind: Fitness.PermissionKinds.Steps, access: Fitness.PermissionAccesses.Read, }, { kind: Fitness.PermissionKinds.Calories, access: Fitness.PermissionAccesses.Read, }, { kind: Fitness.PermissionKinds.Distances, access: Fitness.PermissionAccesses.Read, }, { kind: Fitness.PermissionKinds.HeartRate, access: Fitness.PermissionAccesses.Read, }, ];
let currentDate = new Date(); let start = new Date(2021, 1, 1, 0, 0, 0); let end = new Date( currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate(), 23, 59, 59,);
const getHeartRate = () => { Fitness.getHeartRate({ startDate: start, endDate: end, interval: 'days' }) .then((res) => { console.log('getHeartRate', res); }) .catch((e) => { console.log('error', e); }); };