Navigating Health Data Storage on iOS

Understanding Apple’s Guidelines

Ra9r
3 min readMar 10, 2024

As an iOS developer, building applications that handle sensitive health information comes with unique challenges and strict guidelines set by Apple. At the forefront of this is the question of data storage: when to use HealthKit, the potential for Core Data, and how to handle custom health data scenarios. Let’s delve into the nuances of health data storage on iOS.

Apple’s Emphasis on HealthKit

Apple strongly encourages, and in many cases mandates, the use of HealthKit for storing and managing health-related data. Here’s why:

  • Privacy: HealthKit offers robust privacy controls and user-centric consent mechanisms.
  • Data Format Standardization: It ensures health data is stored in standardized formats, promoting seamless interoperability with other health apps and devices.
  • Health App Integration: Data stored in HealthKit can be directly accessed within Apple’s Health app, enhancing the user experience.

When Core Data Might Be Considered

While Apple strongly prefers HealthKit, there are a few specific scenarios where using Core Data for health data storage could be explored:

  • Temporary Storage: If your app needs to temporarily store health information before promptly transferring it to HealthKit, Core Data might be acceptable.
  • Highly Custom, Non-Standard Data: When dealing with specific health-related research metrics that have no existing counterpart in HealthKit, you might have a stronger justification for Core Data (but be prepared to make a very strong case to Apple during review).

Important: iCloud and Sensitive Data

Storing any kind of protected health information directly in iCloud is generally prohibited due to privacy and regulatory concerns. Always consult Apple’s guidelines and consider legal counsel if your app handles sensitive health data.

The Challenge of Custom User-Defined Symptoms

One common scenario that highlights the tension between HealthKit and flexibility is the need to track custom, user-defined symptoms. HealthKit offers a predefined set of symptom types, which might not be sufficient for specialized use cases. Here are strategies to consider:

  • Metadata (Least Ideal): Utilize existing HealthKit categories and store additional details in the metadata field. This greatly limits searchability and integration.
  • Limited Custom Categories with Quantities: Define a few of your own broader custom categories within HealthKit and record symptom severity or details using HKQuantitySamples.
  • Core Data Hybrid (Riskiest): Use HealthKit alongside a separate Core Data model for fully customized symptom tracking. Be aware of potential App Store review hurdles and ensure exceptional privacy handling.

Key Takeaways

  • Prioritize HealthKit: Whenever possible, design your app around HealthKit’s data types and structure.
  • App Store Review: Prepare for a more rigorous review process if you choose to deviate from using HealthKit entirely.
  • Transparency: Implement clear privacy policies and user consent mechanisms, especially when handling custom health data.
  • Seek Guidance: Consider contacting Apple’s review team in advance if your app requires a complex data storage solution.

Remember, Apple’s focus on HealthKit prioritizes user privacy and seamless integration within their health ecosystem. Finding creative ways to work within those guidelines, whenever possible, will increase the chances of a smooth App Store experience for your health-focused iOS app.

--

--

Ra9r

Startup-Founder • Code-Monkey • Travel-Enthusiast • Aspiring-Health-Nut • Cancer Warrior • FI/RE'd