Skip to main content

UI Kit


Metric supports both Cocoapods and Swift Package Manager for dependency management.


With Cocoapods, add the following to your Podfile:

pod 'HekaUIKit'

Then, run pod install.

Swift Package Manager

With Swift Package Manager, add the following dependency to your Package.swift:

dependencies: [
.package(url: "", .upToNextMajor(from: "0.0.1"))


  1. Append the Info.plist with the following 2 entries:
<string>We will sync your data with the Apple Health app to give you better insights</string>
<string>We will sync your data with the Apple Health app to give you better insights</string>
  1. Open your Flutter project in Xcode by right-clicking on the ios folder and selecting Open in Xcode. Next, enable HealthKit by adding a capability inside the Signing & Capabilities tab of the Runner target's settings. Also, make sure to enable the background delivery option.

  2. To make sure that health data is being synced even while on background, initialize the sync observers in application:didFinishLaunchingWithOptions method of AppDelegate.swift:

import HekaCore     // Make sure you import HekaCore

// ...

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// ....
return true


Import the SDK by adding the following:

import HekaUIKit

To render the UI component with state management and syncing logic plugged in, add the following lines:

uuid: "<user-uuid-goes-here>",
apiKey: "<your-api-key-goes-here>"

To better understand api key and user uuid, please refer to the important concepts section.


Q. If the user denies Apple Healthkit permission, it doesn't show any error and connects. Shouldn't it prevent connecting and show an error message about permission not being granted?

Ans. Unfortunately, Apple Healthkit provides no way to detect if a user has granted permission or not due to privacy reasons. The queries that get data from Healthkit don't return an error and rather return an empty list if permissions are not granted. We think the best way to handle this is to ask users to make sure permissions are granted from the health app if data is not getting synced.