简体   繁体   English

适用于iOS的Cordova healthkit插件函数返回未定义?

[英]Cordova healthkit plugin functions for iOS are returning undefined?

I am trying to use the cordova-plugin-health plugin for a phonegap app I am working on. 我正在尝试对正在使用的phonegap应用程序使用cordova-plugin-health插件。 Whenever I use the app every plugin works but this one. 每当我使用该应用程序时,除此插件外,每个插件均有效。 I am using the phonegap mac app to test on an iPhone 6s. 我正在使用phonegap mac应用在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 使用cordova plugin add cordova-plugin-health --variable HEALTH_READ_PERMISSION='App needs read access' --variable HEALTH_WRITE_PERMISSION='App needs write access'安装的插件cordova plugin add cordova-plugin-health --variable HEALTH_READ_PERMISSION='App needs read access' --variable HEALTH_WRITE_PERMISSION='App needs write access'我也做了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. 稍后在尝试过的window.plugin.health.requestAuthorization上使用了navigator.health.requestAuthorization ,我的WebStorm能够检测到第二个但不是第一个。

Is there anything I missed/can I use this plugin using the phonegap mac app? 我有什么想念的吗/我可以在phonegap mac应用程序中使用此插件吗?

Thanks! 谢谢!

Phonegap Developer App is a tool to easily preview your apps. Phonegap Developer App是一个可以轻松预览您的应用程序的工具。 Phonegap Developer App is a Cordova app itself, that loads your app code from a local web server. Phonegap Developer应用程序本身就是Cordova应用程序,可从本地Web服务器加载您的应用程序代码。 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. 关于Phonegap Developer应用程序的事情是,因为它是预编译的应用程序,所以它只能运行在构建时Phonegap Developer应用程序中包含的插件。 That means, most 3rd party plugins (like the heathkit one) won't work as they are not included in the Phonegap Developer App. 这意味着,大多数第三方插件(如heathkit插件)将无法正常工作,因为它们未包含在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 CLI并插入设备的情况下运行:

phonegap run ios

If you have Cordova CLI installed, this should also work 如果您安装了Cordova CLI,这也应该可以工作

cordova run ios . cordova run ios

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM