Apple Watch Water Lock

See how to use the enableWaterLock() API of WatchKit to disable the Apple Watch touch screen to prevent accidental taps.

Francesco Leoni

1 min read

Availability

watchOS 6.1

Are you planning to create an app that will be used while swimming or doing water activities?

If so, you will need to lock the Apple Watch touch screen to prevent accidental taps while submerged.

Usage

The WatchKit framework provides a method to lock the screen programmatically, but only the user will be able to unlock it.

To use this feature you must call:

WKInterfaceDevice.current().enableWaterLock()

Warning

enableWaterLock() must be called from the main thread.

Warning

To be able to activate enableWaterLock() the app must be running on a supported device and the WKInterfaceDevice.current().waterResistanceRating must be wr50.

Additional features

To detect whether the screen is locked, Apple provides this property:

WKInterfaceDevice.current().isWaterLockEnabled

Conclusion

Now you can prevent accidental taps while your users are having fun in water!

I hope I helped you with you journey with watchOS development.

See you in the next guide.

If you have any question about this article, feel free to email me or tweet me @franceleonidev and share your opinion.

Thank you for reading and see you in the next article!

Share this article

Related articles


Autocompletion for Images and Colours in Xcode 15

Automatically generate colors and images resources from .xcassets and avoid typos in your code with autocompletion in Xcode 15.

2 min read

Xcode

Make your Chart Scrollable with SwiftUI Charts (iOS 17)

Discover the new SwiftUI Charts APIs that enables you to create scrollable chart easily. Available for Xcode 15 and iOS 17.

2 min read

ChartsSwiftUI

How to Let User Paste Data Into your App in SwiftUI

Discover the handy PasteButton available in iOS 16 and SwiftUI, that will allow users to easily paste content in your app.

1 min read

SwiftUI