WigetKit does not hide sensitive information on lock screen when locked

Hi there,

We've built a lock screen widget for our app, which displays sensitive information which we would love to hide when the device is locked. The widget contains a VStack with in there a Text with the subject name and another Text with the actual value of the subject. The last Text component with the value should be redacted.

During development, we've tried already some things like fully hiding the content on locked (setting Data protection to "Complete protection" on the App ID), but that was not really the result we were looking for.

We also tried to set .redacted(reason: .privacy) on the Text component, but that does not result in masking the value when locked. Same goes for setting the component with privacySensitive(). What can I do to make this behaviour work as expected?

The view:

 VStack(alignment: .leading) {
          Text("Name of Subject")
            .font(.system(size: 15.0))
          Text(entry.dataIsOutdated ? "-.--" : entry.valueAsString!)
            .font(.system(size: 28.0))
            .fontWeight(.bold)
            .minimumScaleFactor(0.5)
            .redacted(reason: .privacy)
}
.frame(maxWidth: .infinity, alignment: .leading)
.widgetURL(URL(string: "app-scheme://deeplink"))

Thanks for helping!

Here is what I did on my project.

  1. Use .privacySensitive(false) and .unredacted() if you want your text to be visible even when the device is locked AND the settings in Face ID & Passcode>Allow Access when Locked>Lock Screen Widgets is enable.

I am not sure why it has to be these two modifiers or why I did this way but using these 2 modifiers together works for me. Please keep in mind that I apply this modifiers to the entire view, not just some texts.

  1. If you don't use these two modifiers, it means that it will follow that settings here (Face ID & Passcode>Allow Access when Locked>Lock Screen Widgets).

So...

First I would suggest you check the settings in Settings first and make sure that the Lock Screen Widgets is disabled. This way you can then test your code.

Second, if you want to hide the second Text, you should do the opposite by applying the modifier to the first Text instead. Like this

          Text("Name of Subject")
            .font(.system(size: 15.0))
            .privacySensitive(false)
            .unredacted()
          Text(entry.dataIsOutdated ? "-.--" : entry.valueAsString!)
            .font(.system(size: 28.0))
            .fontWeight(.bold)
            .minimumScaleFactor(0.5)

If this doesn't work you may try to put .privacySensitive(true) to your second Text.

Note that sometimes I have to delete the widget and re-add it to have it worked.

Hope this might help.

Hi Boonyaway,

Thanks for your reply and help! Unfortunately, I've tried all these things already before, haha. I've decided to create a DTS ticket to ask tech support directly.

WigetKit does not hide sensitive information on lock screen when locked
 
 
Q