【问题标题】:How to gain permission in HealthKit for writing workout route using Cordova如何在 HealthKit 中获得使用 Cordova 编写锻炼路线的许可
【发布时间】:2017-10-01 18:38:32
【问题描述】:

如何在 iPhone 上的 CordovaApp 中请求用户对 WorkoutRoute 的许可?

意思是通过HKWorkoutRouteBuilder.insertRouteData将锻炼位置写入HealthKit,这是由原生WatchKit App完成的。

我试过(通过使用 telerik.plugin.healthkit)

var supportedTypes = [
  'HKQuantityTypeIdentifierActiveEnergyBurned',
  'HKQuantityTypeIdentifierHeartRate',
  'HKQuantityTypeIdentifierDistanceWalkingRunning',
  'HKWorkoutRouteTypeIdentifier',
  'HKWorkoutTypeIdentifier'
];

window.plugins.healthkit.requestAuthorization(...

但到目前为止还没有机会获得:锻炼路线(图像中标记为棕色)-这是来自 Speedysloth 示例:

【问题讨论】:

  • 请说明您使用的 healthkit 插件。正在创建自己的?
  • 我正在使用来自 GitHub 的“com.telerik.plugins.healthkit”(不,我是初学者,不是自己创建的)。

标签: cordova permissions telerik healthkit


【解决方案1】:

最后,我通过扩展文件中的插件 (telerik.plugin.health) 管理请求访问“锻炼路线”:Healthkit.m / function getHKSampleType() 我添加了:

if (@available(iOS 11.0, *)) {
        type = [HKObjectType seriesTypeForIdentifier:elem];
        if (type != nil) {
            return type;
    } else {
        // Fallback on earlier versions
    }
}

因为 seriesType 是从 iOS 11 开始的新类型。

【讨论】:

    猜你喜欢
    • 2020-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多