For every complication you provide, it’s important to think about its privacy implications. For our water example, it’s probably not a big deal if the user’s watch is locked but their water consumption is still displayed on the watch face. For a calendar, that can be trickier—you may not want your co-workers to know about your upcoming midnight snack! Other apps are pretty clearly privacy concerns: a complication that shows your bank account balance, for instance, should definitely not display when the user’s watch is locked.
One of the CLKComplicationDataSource methods you’ll implement in your ComplicationController is getPrivacyBehaviorForComplication(_:withHandler:). The handler for this method takes a CLKComplicationPrivacyBehavior enum, which can be either .ShowOnLockScreen or .HideOnLockScreen. For your app, you’ll hide the calendar items, lest someone ends up with a secret meeting visible on their locked device!
| func getPrivacyBehaviorForComplication(complication: CLKComplication, |
| withHandler handler: (CLKComplicationPrivacyBehavior) -> Void) { |
| handler(.HideOnLockScreen) |
| } |
This method is pretty straightforward, but you’re still going to want to test it. Unfortunately, there’s no way to display the lock screen on the watch simulator, so to see this in action you’ll need to test on a real device. Refer to the section on running your app on a hardware watch for more help with that. When disabled, your Modular Large complication looks like the screenshot.
Now that you know how to properly secure your complications, let’s look at some other configuration you can do in your app to tailor your complication experience for your users when they go to add your complication to their watch face.
3.139.81.143