Come join our happy hour in Seattle! – Click here.

Making Use of Split SDK User Consent Features in Your WatchOS App


Split - Split-With-WatchOS-Apps

With very recent new laws on data privacy coming into effect, user consent is gaining momentum. Since the far-reaching General Data Protection Regulation (GDPR) took force on May 25, 2018, companies that cater to or track EU citizens must demonstrate compliance with its data protection and accountability principles. In 2019, the French national data protection authority CNIL used the GDPR to take an immense bite out of Google’s revenues: Oh là là!

Even if you don’t dine with fine wine, or even if Europe may not be your cup of tea, there is a significant need for awareness also in North America and globally. The California Consumer Privacy Act (CCPA) went into effect Jan 1, 2020, with additional protections effective Jan 1, 2023. There are also the Canadian Consumer Privacy Protection Act (CPPA), the Australian Privacy Act reforms, and others on the horizon.

The trend is evident. It’s time to learn to ride the wave. If you are a dev, then you are already out on the water. Surf’s up, so let’s see how Split helps you catch the momentum, pop up and fly.

In this article, we will show you how to use Split SDK’s user consent capabilities, newly available in iOS, to stay on top of the game. You can clone our demo project on GitHub, coded with Swift 5 in Xcode 14.2, supporting iOS 15.0+, and watchOS 8.0+. This tutorial builds on the earlier code example in Setting Up Event Tracking in Your WatchOS App.

Let’s use Split’s new support for user consent to control what data is sent to Split Cloud easily. Specifically, the Split SDK allows you to start with an unknown, granted or denied state for user consent. The user consent can then be toggled between granted or denied. If user consent is granted, the Split SDK will send encrypted tracked events and feature flag evaluation information to a private data center. If user consent is denied, this data will not be cached nor sent out.

In our SplitWrapper class initializer, we will set the new userConsent property of the SplitClientConfig class to unknown:

let config = SplitClientConfig()
config.userConsent = UserConsent.unknown

We next pass the UserConsent.unknown value to the Split factory.

factory = DefaultSplitFactoryBuilder().setConfig(config)

This unknown user consent value sets up the Split SDK to create feature flag evaluation and event data and initially cache this data only on the watch (on the physical device). Note that the information is not sent to Split Cloud, and if the app is terminated in this state, this locally cached data is permanently deleted.

We also define a private @Published variable to make use of the Combine reactive programming framework to update the views when the user makes a choice.

@Published private var userConsentValue: Bool?

Now, we can expose the ability to set user consent values in the Split SDK using the following two property definitions for isUserConsentUnknown and isUserConsentGranted.

public var isUserConsentUnknown: Bool {
  get {
    return UserConsent.unknown == factory.userConsent

public var isUserConsentGranted: Bool {
  get {
    return UserConsent.granted == factory.userConsent
  set {
    factory.setUserConsent(enabled: newValue)
    DispatchQueue.main.async {
      self.userConsentValue = newValue

These changes in our SplitWrapper.swift class equip us to set up a prompt to request consent to store the user’s workout choices, giving the user full control of the event data generated in the app.

In our accompanying code example, our prompt is defined in SplitUserConsentView.swift, and looks like this:

Split - Making Use of Split SDK User Consent Features in Your WatchOS App - 1

Great progress so far! Now, at this point in your coding, you will need to familiarize yourself with the privacy laws that you are aiming to meet. This will determine how you will persist and display the user consent value. For example, the GDPR requires that the user can view and modify the app’s data collection and usage settings at any time. This means you will need to add these settings to an accompanying iOS app, and then listen for changes to these settings in your watchOS app. Though this is not covered here, you can learn how to do this by looking up the WatchKit Settings Bundle.


Split iOS SDK’s user consent capabilities give you perfect control over user data, including pseudonymous data, that may be stored in Swift cloud or passed to third parties. Now you can widen your horizons geographically and reach out to the ocean of possibilities before you, while you skillfully comply with regulations set forth by the relevant data protection authorities.

Split provides the equipment you need to get ahead of the swell and, dude, you’ll be ripping up the waves.

Check out the full code on GitHub, with a shaka thrown to Javier Avrudsky on the Split SDK Team for some great code reviews.

Get Split Certified

Split Arcade includes product explainer videos, clickable product tutorials, manipulatable code examples, and interactive challenges.

Switch It On With Split

Split gives product development teams the confidence to release features that matter faster. It’s the only feature management and experimentation solution that automatically attributes data-driven insight to every feature that’s released—all while enabling astoundingly easy deployment, profound risk reduction, and better visibility across teams. Split offers more than a platform: It offers partnership. By sticking with customers every step of the way, Split illuminates the path toward continuous improvement and timely innovation. Switch on a trial account, schedule a demo, or contact us for further questions.

Want to Dive Deeper?

We have a lot to explore that can help you understand feature flags. Learn more about benefits, use cases, and real world applications that you can try.

Create Impact With Everything You Build

We’re excited to accompany you on your journey as you build faster, release safer, and launch impactful products.