AppStoreConnect 要求应用有一个指示 "where the user can choose which health data they want to share"

AppStoreConnect requires app to have an indication "where the user can choose which health data they want to share"

我们的应用被拒绝,因为我们的应用不提供 select 共享数据的选项。

Next Steps

Please provide detailed answers to the following questions in your reply to this message in Resolution Center:

Provide steps where we can locate the HealthKit integration in your app where the user can choose which health data they want to share. We only located a "Apple Health" import feature.

但是,根据指南 (https://developer.apple.com/design/human-interface-guidelines/healthkit/overview/),这根本不应该由应用程序完成,而是由 iOS 设置完成。

Manage health data sharing solely through the system’s privacy settings. People expect to globally manage access to their health information in Settings > Privacy. Don’t confuse people by building additional screens in your app that affect the flow of health data.

Apple 对我们有什么期望?

您需要请求本机屏幕的权限。

@IBAction func enableHealthKit(sender: AnyObject) {
    var shareTypes = Set<HKSampleType>()
    shareTypes.insert(HKSampleType.workoutType())

    var readTypes = Set<HKObjectType>()
    readTypes.insert(HKObjectType.workoutType())

    healthStore.requestAuthorizationToShareTypes(shareTypes, readTypes: readTypes) { (success, error) -> Void in
        if success {
            print("success")
        } else {
            print("failure")
        }

        if let error = error { print(error) }
    }
}

这里是询问锻炼类型,但您可以询问不同的类型或其中的几种。然后用户可以在设置中更改他们想要共享的内容。有关此代码示例的更多信息 https://cocoacasts.com/managing-permissions-with-healthkit.

如果这对 Apple 来说还不够,您可以随时在打开 iOS 设置的设置中创建一些具有此健康数据权限的按钮。