App Store 连接操作错误:ITMS-90164 [] 密钥 com.apple.developer.healthkit.access

swiftApple

1个回答

写回答

13696527652

2025-06-16 18:20

+ 关注

Apple
Apple

App Store 连接操作错误:ITMS-90164 [] 密钥 com.Apple.developer.healthkit.access

近年来,移动应用程序的快速发展为人们的生活带来了极大的便利。App Store作为苹果公司的应用分发平台,为开发者提供了一个广阔的市场。然而,有时候开发者在提交应用程序时会遇到一些错误,其中一个常见的错误是:ITMS-90164 [] 密钥 com.Apple.developer.healthkit.access。本文将探讨这个错误的原因以及如何解决它。

错误原因:

ITMS-90164 错误是与苹果公司的HealthKit框架相关的错误。HealthKit框架是一种苹果公司提供的开发工具,用于处理与用户健康相关的数据。它允许开发者访问用户的健康数据,例如心率、步数等。然而,在使用HealthKit框架时,开发者需要获取用户的许可,并在应用程序中声明使用HealthKit的权限。这就涉及到了密钥 com.Apple.developer.healthkit.access。

解决方法:

要解决ITMS-90164错误,开发者需要按照以下步骤操作:

1. 检查应用程序的Info.plist文件:在Xcode中,打开应用程序的Info.plist文件,确保已添加对应的密钥 com.Apple.developer.healthkit.access,并设置其值为布尔型的true。

XML

<key>NSHealthShareUsageDescription</key>

<string>需要您的许可才能访问健康数据。</string>

<key>com.Apple.developer.healthkit.access</key>

<true/>

2. 配置应用程序的Capabilities:在Xcode中,选择应用程序的Targets,然后选择Signing & Capabilities。确保已启用HealthKit,并在下拉菜单中选择访问权限。

3. 更新应用程序版本号:如果以上步骤都正确配置,但仍然遇到ITMS-90164错误,则可能是由于之前版本的应用程序没有正确声明HealthKit权限。在这种情况下,开发者需要更新应用程序的版本号,并重新提交应用程序。

案例代码:

以下是一个使用HealthKit框架的简单案例代码,展示如何获取用户的步数数据:

Swift

import HealthKit

let healthStore = HKHealthStore()

func requestAuthorization() {

let stepCountType = HKQuantityType.quantityType(forIdentifier: .stepCount)!

healthStore.requestAuthorization(toShare: nil, read: [stepCountType]) { (success, error) in

if success {

print("用户已授权访问步数数据")

self.queryStepCount()

} else {

print("用户未授权访问步数数据")

}

}

}

func queryStepCount() {

let stepCountType = HKQuantityType.quantityType(forIdentifier: .stepCount)!

let calendar = Calendar.current

let today = calendar.startOfDay(for: Date())

let predicate = HKQuery.predicateForSamples(withStart: today, end: Date(), options: .strictEndDate)

let query = HKStatisticsQuery(quantityType: stepCountType, quantitySamplePredicate: predicate, options: .cumulativeSum) { (query, result, error) in

if let result = result, let sum = result.sumQuantity() {

let stepCount = sum.doubleValue(for: .count())

print("今天步数:\(stepCount)")

}

}

healthStore.execute(query)

}

requestAuthorization()

以上代码首先请求用户授权访问步数数据,然后查询当天的步数。如果用户授权成功,则会打印出当天的步数数据。

ITMS-90164错误是由于在使用HealthKit框架时未正确声明访问权限所致。通过按照上述步骤检查和配置应用程序,开发者可以解决这个错误,并顺利提交应用程序到App Store。使用HealthKit框架可以为用户提供更加个性化和健康的移动应用体验。

举报有用(4分享收藏

Copyright © 2025 IZhiDa.com All Rights Reserved.

知答 版权所有 粤ICP备2023042255号