Giter Site home page Giter Site logo

Comments (10)

aggarwalankush avatar aggarwalankush commented on September 13, 2024 1

@dariosalvi78 I forked the project and worked on some issues I was facing. All changes are backward compatible.

  1. Added read or write only permissions in requestAuthorization for both iOS and Android.
    See datatypes in https://github.com/aggarwalankush/cordova-plugin-health#requestauthorization. It now accepts an object specifying read or write only permissions.

  2. #35 This issue is closed but the solution isn't working. I standardized it like other plugins and added iOS keys strings as variables. See commit description on how to use it- aggarwalankush@0f8985e

  3. I also added a .editorconfig file which I generally like in projects to maintain code formatting.

Full commits here - https://github.com/aggarwalankush/cordova-plugin-health/commits/master

Let me know if I should raise a PR.

from cordova-plugin-health.

dariosalvi78 avatar dariosalvi78 commented on September 13, 2024

Difference between read and write is not supported at the moment. On the to-do list.
Actually the health kit part is ready, the Google fit bit needs an update.
You're welcome to try to fix it.

from cordova-plugin-health.

aggarwalankush avatar aggarwalankush commented on September 13, 2024

@dariosalvi78 Thanks for the quick reply and your contributions. I am looking forward to using and contribute to this repo.

Can you tell me how to just ask for 'read' permissions in health kit? I can implement same in android and raise a PR soon. I'm focusing on this issue because 'isAuthorized' returns true only if user give both read and write permissions.

Also, in docs, you mentioned to always call 'requestAuthorization' before query method. I'm testing in iPhone and it's not helping at all. If I disable health kit permission from settings for my app, 'requestAuthorization' doesn't show popup to ask for health permissions again. Don't you think it's a bug?

from cordova-plugin-health.

dariosalvi78 avatar dariosalvi78 commented on September 13, 2024

Can you tell me how to just ask for 'read' permissions in health kit?

as for iOS, my plugin wraps Telerik's, so you could use that for asking read-only permissions

I can implement same in android and raise a PR soon.

that would be very welcome, it should be quite easy to achieve but requires a little change in the API too

you mentioned to always call 'requestAuthorization' before query method.

in iOS it doesn't make a big difference, but in Android it does, because the method also initialises the Google APIs

If I disable health kit permission from settings for my app, 'requestAuthorization' doesn't show popup to ask for health permissions again. Don't you think it's a bug?

It's how it works in HealthKit I'm afraid:

If the user has already chosen to grant or prohibit access to all of the types specified, the completion is called without prompting the user.

from cordova-plugin-health.

 avatar commented on September 13, 2024

thanks, impressive work!

could you please submit a PR?
I'd love to merge it officially.

from cordova-plugin-health.

 avatar commented on September 13, 2024

coolio,

I've tested it on Android and works like a charm!

from cordova-plugin-health.

aggarwalankush avatar aggarwalankush commented on September 13, 2024

@dariosalviwork I am facing one more issue in Android. I am using 'isAuthorized' and 'requestAuthorization' method and sometimes getting GoogleApiClient is not connected yet. As both methods run in threads, that could be causing the issue. I don't know how to test Cordova plugins so couldn't figure out the cause. Maybe you could fix this issue someday or tell me how to build/test Cordova plugin.

from cordova-plugin-health.

 avatar commented on September 13, 2024

testing the plugin is easy: create a sample cordova app, add the plugin, then open the Android project in Android studio by importing it from the "platforms" folder. That's it really.
I wonder how you managed to extend the plugin without testing it!

About your issue:

  • be aware that the phone needs to be connected to the Internet, at least when requesting authorization the first time
  • the thread shouldn't be a problem as all communication is asynchronous. Actually the use of threads is recommended by Cordova
  • be sure you nest your calls and make sure you call, eg, a query() only AFTER your requestAuthorization() has called the successCallback

from cordova-plugin-health.

aggarwalankush avatar aggarwalankush commented on September 13, 2024

I have an ionic app, I tested using plugin in that app. I was wondering if there was an easy way. I'll see if I can figure out the issue sometime this weekend.

from cordova-plugin-health.

dariosalvi78 avatar dariosalvi78 commented on September 13, 2024

the easiest way is to forget Ionic and use a starter cordova app, then just open the console using chrome://inspect and run all the code from there

from cordova-plugin-health.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.