Cordova healthkit plugin functions for iOS are ret

2019-02-26 00:09发布

问题:

I am trying to use the cordova-plugin-health plugin for a phonegap app I am working on. Whenever I use the app every plugin works but this one. I am using the phonegap mac app to test on an iPhone 6s.

Steps I have taken:

  1. Installed plugin with cordova plugin add cordova-plugin-health --variable HEALTH_READ_PERMISSION='App needs read access' --variable HEALTH_WRITE_PERMISSION='App needs write access' also I did cordova platform add ios

  2. Used navigator.health.requestAuthorization later on tried window.plugin.health.requestAuthorization my ide WebStorm was able to detect the second but not the first.

Is there anything I missed/can I use this plugin using the phonegap mac app?

Thanks!

回答1:

Phonegap Developer App is a tool to easily preview your apps. Phonegap Developer App is a Cordova app itself, that loads your app code from a local web server. The thing about the Phonegap Developer App is, as it's a precompiled app, it can only run the plugins that were included on the Phonegap Developer App at the moment of the build. That means, most 3rd party plugins (like the heathkit one) won't work as they are not included in the Phonegap Developer App.

What you can do is to run your app in your device instead of previewing it.

To do it, run, with the Phonegap CLI installed and your device plugged in:

phonegap run ios

If you have Cordova CLI installed, this should also work

cordova run ios.