perfood / capacitor-healthkit Goto Github PK
View Code? Open in Web Editor NEWCapacitor plugin to interact with HealthKit
Home Page: https://www.npmjs.com/package/@perfood/capacitor-healthkit
Capacitor plugin to interact with HealthKit
Home Page: https://www.npmjs.com/package/@perfood/capacitor-healthkit
following is the error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @capacitor/[email protected]
npm ERR! node_modules/@capacitor/core
npm ERR! @capacitor/core@"5.0.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @capacitor/core@"^4.0.0" from @perfood/[email protected]
npm ERR! node_modules/@perfood/capacitor-healthkit
npm ERR! @perfood/capacitor-healthkit@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
my ionic env:
Ionic:
Ionic CLI : 7.1.1 (/Users/bhanu/.nvm/versions/node/v16.16.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 7.0.7
@angular-devkit/build-angular : 16.0.2
@angular-devkit/schematics : 16.0.2
@angular/cli : 16.0.2
@ionic/angular-toolkit : 9.0.0
Capacitor:
Capacitor CLI : 5.0.3
@capacitor/android : not installed
@capacitor/core : 5.0.3
@capacitor/ios : not installed
Utility:
cordova-res : not installed globally
native-run : 1.7.2
System:
NodeJS : v16.16.0 (/Users/bhanu/.nvm/versions/node/v16.16.0/bin/node)
npm : 9.6.5
OS : macOS Monterey
While querying the IOS health Sleep data not able to fetch REM, Core, Deep sleep state values.I'm adding sample output when querying for sleep data,
[{"uuid":"2C360D2F-DA6B-4DDA-8A07-8D09B4CE0F39","timeZone":"+05:30","endDate":"2023-11-15T18:09:00Z","sleepState":"Asleep","startDate":"2023-11-15T06:01:00Z","source":"Health","duration":12.133333333333333,"sourceBundleId":"com.apple.Health","device":null},{"timeZone":"+05:30","uuid":"AD94453E-0CB4-4E45-A9BF-6D44DB0EAD65","duration":9,"sleepState":"InBed","source":"Health","endDate":"2023-11-16T02:00:00Z","device":null,"sourceBundleId":"com.apple.Health","startDate":"2023-11-15T17:00:00Z"},{"device":null,"source":"Health","timeZone":"+05:30","sleepState":"Asleep","uuid":"6B62AF8F-7689-41C0-A60E-6A9E5D83D414","duration":1,"startDate":"2023-11-15T18:08:00Z","endDate":"2023-11-15T19:08:00Z","sourceBundleId":"com.apple.Health"},{"sourceBundleId":"com.apple.Health","device":null,"duration":2,"startDate":"2023-11-15T19:11:00Z","sleepState":"Asleep","source":"Health","uuid":"E61337A6-3952-4262-83A6-CD2F6336F4A4","timeZone":"+05:30","endDate":"2023-11-15T21:11:00Z"},{"timeZone":"+05:30","sleepState":"Asleep","endDate":"2023-11-15T21:11:00Z","source":"Health","sourceBundleId":"com.apple.Health","startDate":"2023-11-15T20:11:00Z","device":null,"duration":1,"uuid":"06CFBD06-4966-4A81-8553-0DC6080D84F5"}]
Hello! Thank you for your work on this plugin so far.
Are there plans to introduce an API that leverages HKObserverQuery
so that we can subscribe to background events?
I have found this gist which seems to lay out how to enable background delivery for HKObjectType
s. Please forgive my ignorance if this example is not helpful as I am not familiar with Swift.
Thanks.
We are not able to install with the latest ionic (using capacitor 5.x)
Found: @capacitor/[email protected] node_modules/@capacitor/core
@capacitor/core@"5.1.1" from the root project
Could not resolve dependency: peer @capacitor/core@'^4.0.0"
from @perfood/[email protected]
node_modules/@perfood/capacitor-healthkit
@perfood/capacitor-healthkit@'*' from the root project
querying multiple options.
Error: [Error] Error: Must provide startDate
CapacitorException — index.js:85
returnResult — user-script:2:768
(anonymous function) — user-script:2:750
if (Capacitor.getPlatform() == 'ios') {
this.getIosData(new Date('07/10/2023').toISOString(), new Date('07/15/2023').toISOString());
}
async getIosData(startDate: string, endDate: string) {
try {
const queryOptions: MultipleQueryOptions = {
sampleNames: [SampleNames.STEP_COUNT, SampleNames.WEIGHT],
startDate: startDate,
endDate: endDate,
limit: 0,
};
console.log(queryOptions)
let res = await CapacitorHealthkit.multipleQueryHKitSampleType(queryOptions);
console.log(res);
} catch (error) {
console.error(error);
}
}
Hey folks 👋
Thanks for your work on this plugin! I'd like to understand if you're having plans to actively maintain and further develop the plugin? If yes, do you see it feasible to support Capacitor 4.x?
Do you plan on wrapping methods such as HKWorkoutSession to allow a user to initiate a workout from the capacitor app?
Hey! Thanks so much for making this, it's super cool!
I've run into a problem when trying to to get Sleep data from HealthKit. Instead of getting sleep data back I get this:
{
"errorDescription": "sampleTypeFailed"
}
I don't have much experience with Swift/iOS development, otherwise I'd make a PR request instead!
If there's anything I'm doing wrong as well, please let me know, I'm querying with the sample name: "sleepAnalysis", and as far as I understand, sleep falls under the "activity" Authorisation permission? Maybe Apple has changed this?
Hi perfood,
thank you for your plugin,
I need to read from healthkit the quantities of carbohydrates, total fats and proteins from the dietary.
I notice that are not managed the keys: dietaryFatTotal, dietaryCarbohydrates, dietaryProtein.
How can I do to read other types of samples from the healthkit's api?
Thank you,
Leonardo
Hi there,
I'm having problems with requesting authorization and getting started with it.
I'm on capacitor 5.7.5 and when I installed this plugin using npm i --save @perfood/capacitor-healthkit
I got a dependency error:
Could not resolve dependency: ERR! peer @capacitor/core@"^4.0.0" from @perfood/[email protected]
I then installed it via --legacy-peer-deps
, but when I wanted to request authorization, I would get Error getting Authorization: Error: Could not get permission
.
I reinstalled using the fork that Bin had made, but still no luck and may not be relevant to my Capacitor version.
const connectAppleHealth = async () => {
await requestPermissions();
}
const requestPermissions = async () => {
const READ_PERMISSIONS = ['calories', 'activity', 'steps'];
try {
await CapacitorHealthkit.requestAuthorization({
all: [''],
read: READ_PERMISSIONS,
write: [''],
});
} catch (error) {
console.error('[HealthKitService] Error getting Authorization:', error);
}
}
And I'm testing on iOS 17.4.1
Your help is much appreciated!
I am having a difficult time getting Apple HealthKit integration to work. Even though I have been following the documented basic example for requesting authorization (ie. CapacitorHealthkit.requestAuthorization
), I have been unable to to trigger the confirmation screen to pop up.
Assuming I have followed the instructions as provided, is there some else I should be doing to enable Apple HealthKit integration in my app (any settings, etc)? Perhaps there is some build setting that needs to be enabled? Any suggestions as to what I should try to troubleshoot this issue?
Thanks!
Let's allow to read and write Medications (pills) on HealthKit.
How I can check that user is already authorised or not.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.