The app no longer requires root to function. The article has been updated accordingly.

Stock Android has three settings for displaying notification content on your lockscreen: no notifications, hide notification content and show notification and content. This does give you a good control about what is displayed on your device, but it does not tailor preferences on any external context. What if you wanted to know the notifications straight from your lockscreen when it is you that is viewing it, but hide them when the phone does not recognize the viewer? FaceNotify by XDA Senior Member kacperes00 lets your phone display notifications only when you are looking.

The app is basic in its UI and does what it claims to. FaceNotify has been tested to work on the OnePlus 5T, OnePlus 6 and OnePlus 6T. It may also work on other devices.

FaceNotify XDA Thread

If you are looking for alternate solutions and do not mind dipping your hands into Tasker, you can achieve similar functionality using the Smart Lock feature combined with Tasker.