Apple's face-scanning tech should work with the vast majority of sunglasses. However, if you happen to own a pair of sunglasses that Face ID just doesn't work with, don't fret -- a simple change of settings should help.
Each time Face ID is used to unlock your phone, a combination of sensors invisibly project thousands of infrared dots onto your face, before matching these dots to your facial fingerprint, all in a fraction of a second. Most sunglasses still allow the infrared light through for Face ID to verify you are looking at your phone. However, if you happen to own sunglasses that block the specific IR light Apple uses with Face ID, each scan will inevitably fail.
You can either take your sunglasses off to use Face ID, or you can disable Face ID's attention detection requirement. Open Settings > Face ID & Passcode and scroll down to the Attention section. Slide the switch next to Require Attention for Face ID to the Off position and accept the warning.
With this feature turned off, Face ID will no longer require you to look at the screen or your eyes to be clearly open before it will unlock your device via Face ID. In turn, eliminating this requirement will allow Face ID to work with sunglasses that blocked Face ID from seeing your eyes.
If you're not comfortable with Face ID potentially unlocking your phone when you're not actively looking at the screen, then you're only other option is to find a different pair of sunglasses.
Apple - USE TAG
reading•Having trouble with Face ID and sunglasses? Try this
Aug 15•iOS 12: Release date, new features and hidden features
Aug 15•The 2018 iPhone X's and the Galaxy Note 9 could share these features
Aug 15•Twitter suspends Infowars host Alex Jones' ability to tweet
Aug 15•Alex Jones video that spurred Twitter suspension remained live on Periscope