Releases: shubhamsinghshubham777/KHealth
1.1.0
What's Changed
- KHealth now supports basic Exercise/Workout records (#14)
- The library uses Kotlin version
2.1.0
now (#13)
To check for Exercise
/Workout
permissions:
val response = kHealth
.checkPermissions(KHPermission.Exercise(read = true, write = true))
.filterIsInstance<KHPermission.Exercise>()
.firstOrNull()
if (response != null) {
println("Is read granted? ${response.read} -- Is write granted? ${response.write}")
}
Use the same syntax for requesting Exercise
permissions:
val response = kHealth
.requestPermissions(KHPermission.Exercise(read = true, write = true))
.filterIsInstance<KHPermission.Exercise>()
.firstOrNull()
if (response != null) {
println("Is read granted? ${response.read} -- Is write granted? ${response.write}")
}
To save an Exercise
record:
val response = kHealth.writeRecords(
KHRecord.Exercise(
type = KHExerciseType.Golf,
startTime = Clock.System.now().minus(36.minutes),
endTime = Clock.System.now()
)
)
println(
if (response == KHWriteResponse.Success) "Writing exercise succeeded ✅"
else "Writing exercise failed ❌"
)
To read an Exercise
record:
val records = kHealth.readRecords(
KHReadRequest.Exercise(
startTime = Clock.System.now().minus(1.days),
endTime = Clock.System.now()
)
)
println("Exercise records: $records")
Full Changelog: 1.0.0...1.1.0
1.0.0
This version introduces the following changes:
- Add ability to interact with the
Nutrition
data type (i.e. check/request permission and read/write data). Example:// Check permission kHealth.checkPermissions( KHPermission.Nutrition( readBiotin = true, writeBiotin = true, readCaffeine = true, writeCaffeine = true // This class allows you to request for the precise permissions // that you require with total 38 food/nutrition values ), ) // Request permission kHealth.requestPermissions( KHPermission.Nutrition( readBiotin = true, writeBiotin = true, readCaffeine = true, writeCaffeine = true // and many more params in this class (like VitaminA, Zinc, Protein, etc.) ), ) // Write Nutrition kHealth.writeRecords( KHRecord.Nutrition( name = "KHealth Sample Meal", startTime = Clock.System.now() - 10.minutes, endTime = Clock.System.now(), mealType = KHMealType.Snack, solidUnit = KHUnit.Mass.Gram, biotin = 0.00003, caffeine = 0.45, // and many more... ), ) // Read Nutrition kHealth.readRecords( KHReadRequest.Nutrition( startTime = startTime, endTime = endTime, // Optional solidUnit = KHUnit.Mass.Gram, energyUnit = KHUnit.Energy.KiloCalorie ) )
Note
Nutrition supports the following types of food items
Biotin, Caffeine, Calcium, Chloride, Cholesterol, Chromium, Copper, DietaryFiber, Energy, FolicAcid, Iodine, Iron, Magnesium, Manganese, Molybdenum, MonounsaturatedFat, Niacin, PantothenicAcid, Phosphorus, PolyunsaturatedFat, Potassium, Protein, Riboflavin, SaturatedFat, Selenium, Sodium, Sugar, Thiamin, TotalCarbohydrate, TotalFat, VitaminA, VitaminB12, VitaminB6, VitaminC, VitaminD, VitaminE, VitaminK, Zinc
- Remove
KHDataType
andKHPermissionStatus
classes to make user's learning curve easier
Warning
THIS IS A MAJOR CHANGE 👆🏼
0.0.1
🎉 Initial Release 🎉
Meet KHealth
, a simple & easy-to-use Kotlin Multiplatform wrapper over Health Connect and HealthKit APIs on Android and Apple platforms respectively.
This release provides you with some core features like:
1. Check SDK Availability 📱 ⌚️
Use kHealth.isHealthStoreAvailable
to know if the health store is available on your system.
2. Check Permission Statuses ✅ / ❌
Use kHealth.checkPermissions()
with your desired permission entries to check if the user has provided your app the permission to Read/Write that particular kind of data.
3. Request Permissions 🔐
Use kHealth.requestPermissions()
with your desired permission entries to request the user to provide you the permission to Read/Write a particular kind of data.
4. Write Records 📝
Use kHealth.writeRecords()
with your desired data records to write multiple types of data into the health store.
5. Read Records 📚
Use kHealth.readRecords()
with your desired read requests to read a single type of data from the health store.
Important
The library is being actively developed and with your support, we can target to cover 100% of the features from both Android and Apple APIs as soon as possible 🙌🏼 So please feel free to try it out, experiment with it, and provide your feedback 🌟