0

I am looking for a way to hide sensitive information on my Complication, basically whenever the user does not actively look at it. That includes

  • Always-On state
  • Locked State (e.g. Watch not on wrist)

I could observe differences in behavior between Preview, Simulator and Real Device. In general it looks like the .privacySensitive() modifier does not do anything for my purpose (except if the user enables redaction in settings). For the always-on state I could use @Environment(\.isLuminanceReduced) to conditionally apply .redacted(reason: .placeholder). This works most of the time.

@ViewBuilder func preservePrivacy(_ isLuminanceReduced: Bool) -> some View {
    if isLuminanceReduced {
        self
            .redacted(reason: .placeholder)
    } else {
        self
    }
}

However I still cannot hide the information when the Watch is locked completely. I still believe that .privacySensitive() should take care of it, but apparently it doesn't. So the question is: How can I hide sensitive information when the Watch is locked?

This is my widget:

Text(entry.code)
    .privacySensitive()
    .preservePrivacy(isLuminanceReduced)
    .widgetCurvesContent()
    .widgetLabel {
        Text("PIN")
            .widgetAccentable()
            .foregroundStyle(.secondary)
    }
    .containerBackground(.teal.gradient, for: .widget)

(I included the whole story, because possibly my whole approach is wrong.)

1 Answer 1

0

On this thread an Apple Engineer provided the solution to the problem.

Apparently privacySensitive() only takes effect if the user deactivates Show Complication Data for Always On in the Watch Settings. In order to overwrite the user's choice you need to add the Data Protection entitlement as documented here. By doing that, you prevent the widget to access/show any privacy sensitive data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.