Cordova healthkit plugin functions for iOS are returning undefined?

匿名 (未验证) 提交于 2019-12-03 02:33:02

问题:

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.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!