如何使用api从angular2 nativescript获取ISHEALTHDATA

如何使用api从angular2 nativescript获取ISHEALTHDATA,nativescript,angular2-nativescript,Nativescript,Angular2 Nativescript,由于ios HealthKit不支持nativescript,我正在尝试使用api 首先,我尝试为isHealthDataAvailable()获取一个简单的布尔值: 怎么做? 声明变量NSBundle:any constructor() { if (Platform.isIOS){ let healthStore = NSBundle.mainBundle.HKHealthStore(); let is_avail = heal

由于ios HealthKit不支持nativescript,我正在尝试使用api

首先,我尝试为isHealthDataAvailable()获取一个简单的布尔值:

怎么做? 声明变量NSBundle:any

  constructor() { 


 if (Platform.isIOS){   
            let healthStore = NSBundle.mainBundle.HKHealthStore();
            let is_avail = healthStore.isHealthDataAvailable();
        }
}

(in promise): TypeError: NSBundle.mainBundle.HKHealthStore is not a function. (In 'NSBundle.mainBundle.HKHealthStore()', 'NSBundle.mainBundle.HKHealthStore' is undefined)
这是对NativeScript的引用:


我不同意…

这不是
HKHealthStore
的所在,请参阅我对您的另一个问题的回答,我建议您安装平台声明(
npm I tns平台声明-保存开发
)。这将极大地帮助您:

回答这个问题:应该是
HKHealthStore.isHealthDataAvailable()
,如下面的屏幕截图所示(这是前面提到的iOS类型脚本声明的一个片段:


您需要使用正确的语法进行数据转换(在Objective-C Apple API和JavaScript之间),如前所述

e、 g


可以在

tns平台声明不起作用中找到非常详细的逐步解释…我不能做var-healthStore:HKHealthStore;-->[ts]找不到名称“HKHealthStore”。已安装版本-tns平台-declarations@3.0.1Dudes在nativescript。你在吗?你喜欢stackoverflow,但你似乎对评论你的框架不感兴趣。越来越明显的是,nativescript的使用还没有为黄金时间做好准备。你的文档已经过时了
 var healthStore = HKHealthStore.new();

And this is how to use HealthKit API in NativeScript. Yes, it is THAT simple.
var healthStore = HKHealthStore.new();