Open melsheikh92 opened 3 years ago
@melsheikh92 mind to share the code? The FitData
contains the source
field which you can use to properly calculate sum of steps for users with more than one device.
Fortunately, I have modified the plugin to do that 😁
Use this in the pubspec.yaml as fitkit plugin.
fit_kit:
git:
url: git://github.com/dinithherath/FitKit.git
And in your code to get the exercise_minutes use this snippet.
if (!permissions) {
log.d('RequestPermissions: Denied');
} else {
try {
final now = DateTime.now();
FitDataStatistics resultAllSteps;
FitDataStatistics resultAllExercise;
try {
resultAllSteps = await FitKit.readStatistics(
DataType.STEP_COUNT,
dateFrom: DateTime(now.year, now.month, now.day),
dateTo: now,
);
} catch (e) {
resultAllSteps = null;
}
try {
resultAllExercise = await FitKit.readStatistics(
DataType.EXERCISE_TIME,
dateFrom: DateTime(now.year, now.month, now.day),
dateTo: now,
);
} catch (e) {
resultAllExercise = null;
}
} on UnsupportedException catch (e) {
print(e.toString());
}
}
This reads data from the health kit using the iOS cumulative sum method which will eliminate duplicates from your phone and apple watch.
If you get the work done please star my repo of Fitkit and follow me on GitHub ❤ Thanks.
@melsheikh92 mind to share the code? The
FitData
contains thesource
field which you can use to properly calculate sum of steps for users with more than one device.
while using Apple watch and mobile together, the library gives me the sum of the number of steps on mobile and on apple watch as an aggregation which is not correct and makes double the value.
while the summary is correct on mobile but it doesn't return like it: