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 (via PIN-Code). 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("1234")
.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.)
Selecting any option will automatically load the page